IplImage* m_pCameraBuffer ; // 카메라 영상이 저장되는 버퍼
DrawIplImage(m_pCameraBuffer, Image1->Canvas->Handle) ;
void __fastcall threadCamera::DrawIplImage(IplImage* iplImg, HDC dc)
{
/************************************************************
Function : 카메라에서 들어온 영상을 화면 DC 에 뿌려준다.
Parameter 1 : 카메라에서 들어온 영상이 저장된 이미지 버퍼 포인터
Parameter 2 : 영상이 출력될 화면의 DC
************************************************************/
BITMAPINFO bitmapInfo;
bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bitmapInfo.bmiHeader.biPlanes=1;
bitmapInfo.bmiHeader.biCompression=BI_RGB;
bitmapInfo.bmiHeader.biXPelsPerMeter=100;
bitmapInfo.bmiHeader.biYPelsPerMeter=100;
bitmapInfo.bmiHeader.biClrUsed=0;
bitmapInfo.bmiHeader.biClrImportant=0;
bitmapInfo.bmiHeader.biWidth=iplImg->width;
bitmapInfo.bmiHeader.biHeight=iplImg->height;
bitmapInfo.bmiHeader.biBitCount=iplImg->depth * iplImg->nChannels;
bitmapInfo.bmiHeader.biSizeImage=0;
::StretchDIBits(dc ,0, 0, iplImg->width, iplImg->height, 0, 0, iplImg->width, iplImg->height,
iplImg->imageData, &bitmapInfo, DIB_RGB_COLORS, SRCCOPY );
}
한시운 님이 쓰신 글 :
: 어떻게 C++ builder XE2로 예제 코드를 돌리긴 했는대 어떻게 하면 촬영된 이미지를 VCL폼으로 불러올수 있는지 모르겠습니다.
: 가능하면 VCL폼에 TImage의 함수인 Image1->Picture->LoadFromFile(ImageName);를 이용해서 촬영된 이미지를 VCL 폼으로 불러오고 싶은대 어떻게 하면 경로명을 불러올수 있는지 이해가 안됩니다.
:
: 예제코드의 이미지를 VCL폼으로 불러 올수 없을까요?
:
: 상세한 코드는 첨부파일에 있습니다.
:
:
: // 이미지 촬영 핵심코드
: /* Grab some images in a loop. */
: for (i = 0; i < numGrabs; ++i) {
: unsigned char min, max;
: PylonGrabResult_t grabResult;
: bool bufferReady;
:
: /* Grab one single frame from stream channel 0. The
: camera is set to single frame acquisition mode.
: Wait up to 500 ms for the image to be grabbed. */
: GR_check(PylonDeviceGrabSingleFrame(hDev, 0, imgBuf , payloadSize,
: &grabResult, &bufferReady, 500), "PylonDeviceGrabSingleFrame");
:
: /* Check to see if the image was grabbed successfully. */
: if (grabResult.Status == Grabbed) {
: /* Success. Perform image processing. */
: getMinMax(imgBuf, grabResult.SizeX, grabResult.SizeY, &min, &max);
: printf("Grabbed frame #%2d. Min. gray value = %3u, Max. gray value = %3u\n"
: , i + 1, min, max);
:
: #ifdef GENAPIC_WIN_BUILD
: /* Display image */
: GR_check(PylonImageWindowDisplayImageGrabResult(0, &grabResult),
: "PylonImageWindowDisplayImageGrabResult");
: #endif
: }
: //VCL에서 이미지 불러오기(미완성)
: // Image1->Picture->LoadFromFile();
: }
: