- CVI 정보나눔(www.cvi.kr)
- 스터디
- 질문답변
질문,답변
글 수 1,629
안녕하세요.
예전에 비슷한 질문이 있어서 올렸던 답변을 다시 올립니다.
관련 예제를 보시면 Grap이라는 셈플이 있을텐데요.
아무쪼록 성공하시길 바랍니다. ^^
=================================================================
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;
}
======================================================================
>
>안녕하세요.
>도움을 얻고자 이곳에 글을 올렸습니다.
>
>현재 제가 하고 있는일은 CCD 구동 프로그램을 CVI를 사용하여 만들어서 나오는 영상을 CVI의 panel 에 나타나도록 구현하고자 하고 있습니다.
>(판넬에 picture 가 들어갈수 있도록 uir을 제작하였습니다)
>
>현재 데이터를 얻는 것까지는 어떻게 해결했는데 이것을 CVI 판넬에 표현하는 일이 잘 되질 않고 있습니다.
>CCD에서 얻어지는 데이터가 16비트 데이터라서 8비트로 변환까지 해 두었는데, 이것을 CVI를 통해서 display 하는데 곤란을 겪고 있습니다.
>
>샘플들을 보다보니, bitmapID 라는 것이 계속 쓰이는 것 같아서
>NewBitmap 함수를 사용해서 bitmapID를 만들고자 하는데(이걸쓰면 CCD에서 얻어진 데이터에 대해서 bitmapID를 줄 수 있을것 같습니다),
>이 함수에 들어가는 인자 중에서 colortable, bits, mask 에 어떤 것들이 들어가는지 잘 모르겠습니다.
>이 인자들에 대한 설명과, 어떤 식으로 써야 할지 조언해 주시면 고맙겠습니다.
>답변 부탁드립니다.
예전에 비슷한 질문이 있어서 올렸던 답변을 다시 올립니다.
관련 예제를 보시면 Grap이라는 셈플이 있을텐데요.
아무쪼록 성공하시길 바랍니다. ^^
=================================================================
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;
}
======================================================================
>
>안녕하세요.
>도움을 얻고자 이곳에 글을 올렸습니다.
>
>현재 제가 하고 있는일은 CCD 구동 프로그램을 CVI를 사용하여 만들어서 나오는 영상을 CVI의 panel 에 나타나도록 구현하고자 하고 있습니다.
>(판넬에 picture 가 들어갈수 있도록 uir을 제작하였습니다)
>
>현재 데이터를 얻는 것까지는 어떻게 해결했는데 이것을 CVI 판넬에 표현하는 일이 잘 되질 않고 있습니다.
>CCD에서 얻어지는 데이터가 16비트 데이터라서 8비트로 변환까지 해 두었는데, 이것을 CVI를 통해서 display 하는데 곤란을 겪고 있습니다.
>
>샘플들을 보다보니, bitmapID 라는 것이 계속 쓰이는 것 같아서
>NewBitmap 함수를 사용해서 bitmapID를 만들고자 하는데(이걸쓰면 CCD에서 얻어진 데이터에 대해서 bitmapID를 줄 수 있을것 같습니다),
>이 함수에 들어가는 인자 중에서 colortable, bits, mask 에 어떤 것들이 들어가는지 잘 모르겠습니다.
>이 인자들에 대한 설명과, 어떤 식으로 써야 할지 조언해 주시면 고맙겠습니다.
>답변 부탁드립니다.