질문,답변

글 수 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;
}
======================================================================

박형민

2007.02.01 14:30:21
*.252.52.62

답변 감사합니다. ^^
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 이제부터 질문은 LabWindows/CVI 카페를 이용하면 더 좋겠습니다 운영자 2020-11-11 1235
공지 파일(특히 그림파일)을 올리실 때의 유의사항 운영자 2004-07-16 100157
» [re] panel에 이미지(영상)을 뿌리는 법에 대한질문입니다. [1] 이현호 2007-01-31 8966
988 변수값등의 변화를 모니터링 할 수 있나요? [2] 이현호 2007-01-17 1524
987 NI-SPY 에서 받은값으로 보내는법이 있나요? [4] 주니 2007-01-12 2309
986 CALENDAR 올리는 방법??? [1] 이중훈 2007-01-04 1667
985 강좌, 팁에 관한 질문? [1] 송성희 2007-01-02 1526
984 [re] CVI 정보나눔의 운영방향, 목적 [2] 허창원 2007-01-12 2234
983 [초보]vb와 cvi의 차이 [1] kk506 2006-12-30 2485
982 Table에서 칸 합치기.. [3] 장선미 2006-12-28 8904
981 PCI-6251보드용으로 전환이 가능할까요? file [1] 방승환 2006-12-27 1575
980 [질문]RS232 Read 실행시 프로그램 속도저하... [1] 서성훈 2006-12-23 2596
979 USB-6009 DAQ 질문 [1] 이제시작 2006-12-19 2821
978 Labview와 LabWindows 의 그래프 성능차이... 정재호 2006-12-14 3177
977 [re] LabWindows/CVI에서 그래프와 스트립차트 테스트 file 허창원 2006-12-15 2897
976 ADVANTECH CARD PCI1711사용시의 채널이동의 문제점 [7] cvi짱 2006-12-12 2962
975 DAQmxCreateAIVoltageChan()의 도움말 오류 file 허창원 2006-12-09 3340
974 RS232함수와 USBtoSerial케이블에 대하여 급한 질문^^ [5] 송상욱 2006-12-05 2655
973 그래프 질문?? [3] 신용기 2006-11-28 1557
972 CVI에서 DAQ할때요,, [1] 유승희 2006-11-28 1516
971 랩윈도우에서 만든 DLL사용?? [2] 박기무 2006-11-23 1941
970 강좌 신청합니다. 엑셀 다루기 편으로 ^^ [1] 송성희 2006-11-22 2124