- CVI 정보나눔(www.cvi.kr)
- 스터디
- 질문답변
질문,답변
글 수 1,629
>
>안녕하세요. CVI를 사용한지 얼마 되지 않는 초보유저입니다.
>
>현재 하고 있는 일이 CCD 카메라를 CVI 환경으로 구동하는 프로그램을 만들고 있습니다.
>
>판넬의 도구에서 보면 picture가 있던데, 여기에 CCD에서 얻어진 영상을 뿌려보고 싶습니다.
>
>판넬상에서 view 버튼을 눌렀을 때 그림이 보이도록 만들고 싶은데, 함수나 프로시저를 어떤걸 사용해야 하는지 모르겠습니다.
>일단 OK 버튼을 눌렀을 때 CCD로부터 값을 얻어서 변수에 저장하는것까지는 만든 상태입니다.
>
>어떤 라이브러리들을 써야하는지, 그리고 간단한 예를 보여주셨음 좋겠습니다.
>
>부탁드립니다.
NI사의 NI PCI-1411그래버 보드를 사용하였을 때의 제가 사용한 예제 입니다.
[Grab]버튼을 누르면 설정을 마치고 영상을 얻어오는 타이머를
Enable시킵니다. 영상을 얻는 부분은 timer함수에 있습니다.
Picture가아닌 CANVAS를 사용하셔야 합니다.
예제가 있던 걸로 기억합니다만...^^
=================================================================
int CVICALLBACK Grab (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char intfName[64];
unsigned long bitDepth;
switch (event)
{
case EVENT_COMMIT:
// Get the interface name
GetCtrlVal(panelHandle, PANEL_STRING_INTFNAME, intfName);
//Open an interface and a session
imgInterfaceOpen(intfName, &Iid);
imgSessionOpen(Iid, &Sid);
// Check that the Acquisition window is not smaller than the Canvas
imgGetAttribute(Sid, IMG_ATTR_ROI_WIDTH, &AcqWinWidth);
imgGetAttribute(Sid, IMG_ATTR_ROI_HEIGHT, &AcqWinHeight);
if(CanvasWidth < AcqWinWidth)
AcqWinWidth = CanvasWidth;
if(CanvasHeight < AcqWinHeight)
AcqWinHeight = CanvasHeight;
// Set the ROI to the size of the Canvas so that it will fit nicely
imgSetAttribute(Sid, IMG_ATTR_ROI_WIDTH, AcqWinWidth);
imgSetAttribute(Sid, IMG_ATTR_ROI_HEIGHT, AcqWinHeight);
imgSetAttribute(Sid, IMG_ATTR_ROWPIXELS, AcqWinWidth);
// Set the plot Flag depending on the bitDepth
imgGetAttribute(Sid, IMG_ATTR_BITSPERPIXEL, &bitDepth);
switch(bitDepth)
{
case 10:
PlotFlag = IMGPLOT_MONO_10;
break;
case 12:
PlotFlag = IMGPLOT_MONO_12;
break;
case 14:
PlotFlag = IMGPLOT_MONO_14;
break;
case 16:
PlotFlag = IMGPLOT_MONO_16;
break;
case 24:
case 32:
PlotFlag = IMGPLOT_COLOR_RGB32;
break;
default:
PlotFlag = IMGPLOT_MONO_8;
break;
}
// Setup and launch the grap operation
imgGrabSetup(Sid, TRUE);
//Let NI-IMGQ manage the memory
ImaqBuffer = NULL;
//Activate the IMAQ loop
SetCtrlAttribute(panelHandle, PANEL_TIMER_VISION, ATTR_ENABLED, TRUE);
break;
}
return 0;
}
/***********************************************************/
/* */
/* TIMER */
/* */
/***********************************************************/
int CVICALLBACK Imaq_loop (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
static int nbFrame;
static float t1, t2;
switch (event)
{
case EVENT_TIMER_TICK:
t2 = Timer();
// Get the frame after the next Vertical Blank
imgGrab(Sid, (void **)&ImaqBuffer, TRUE);
// Display using NI_IMAQ
imgPlot(CVIWndHndl, ImaqBuffer, 0, 0, AcqWinWidth, AcqWinHeight, CanvasLeft, CanvasTop, PlotFlag);
// Calculate the number of frame per seconds every 10 frames
nbFrame++;
if(nbFrame > 10)
{
SetCtrlVal(panelHandle, PANEL_NUM_FRAMERAE, nbFrame/(t2-t1));
t1 = t2;
nbFrame=0;
}
break;
}
return 0;
}
======================================================================
답변 감사합니다. ^^