질문,답변

글 수 1,629

[IMAQ] 관련 질문입니다. 도와주세요 ㅠㅠ

조회 수 3820 추천 수 0 2009.09.07 16:20:01
항상건강하고 행복하세요...
Framegrabber을 이용해서 영상을 캡쳐하려고합니다.
Snap를 이용해서 버퍼에 영상을 저장하고 그리고 나서 imagPlot를 이용해서
다음과같이 출력하고있습니다.

static void* ImaqBuffer=NULL;

int CVICALLBACK Snap (int panel, int control, int event,
                void *callbackData, int eventData1, int eventData2)
{
       int        acqWinWidth, acqWinHeight;
       unsigned int    bufSize, bytesPerPixel, plotFlag, bitDepth;
       char        intfName[64];
        
       switch (event)
      {
            case EVENT_COMMIT:
      // Get the interface name
            GetCtrlVal (panelHandle, PANEL_INTFNAME, intfName);
            GetCtrlVal (panelHandle, PANEL_INTFNAME_2, intfName_2);    
        
     // 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);
            imgGetAttribute (Sid, IMG_ATTR_BYTESPERPIXEL,  &bytesPerPixel);
            imgGetAttribute (Sid, IMG_ATTR_BITSPERPIXEL, &bitDepth);  
                        
            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);
                        
                                                
     // create a buffer list with one element
            imgCreateBufList(1, &Bid);
                        
     // compute the size of the required buffer
            bufSize = acqWinWidth * acqWinHeight * bytesPerPixel;

     // create a buffer and configure the buffer list
            imgCreateBuffer(Sid, FALSE, bufSize, &ImaqBuffer);
                        
     /* the following configuration assigns the following to buffer list
                       element 0:
      
        1) buffer pointer that will contain the image
        2) size of the buffer for buffer element 0
        3) command to stop acquisition when this element is reached
            
    */
   imgSetBufferElement(Bid, 0, IMG_BUFF_ADDRESS, (uInt32)ImaqBuffer);
   imgSetBufferElement(Bid, 0, IMG_BUFF_SIZE, bufSize);
   imgSetBufferElement(Bid, 0, IMG_BUFF_COMMAND, IMG_CMD_STOP);
                        
                                
   // lock down the buffers contained in the buffer list
           imgMemLock(Bid);
                        
                        
   // configure the session to use this buffer list
           imgSessionConfigure(Sid, Bid);
                        
                                                
    // start the acquisition (synchronous function)

                
           imgSessionAcquire(Sid, TRUE, NULL);
                        
                                                
    // Display using NI-IMAQ
    // set the plot Flag depending on the 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;
        }                
                        
                        
       imgPlot (CVIWndHndl, ImaqBuffer, 0, 0, acqWinWidth, acqWinHeight,
                                                           CanvasLeft, CanvasTop, plotFlag);
                        
                                                                          
      // unlock the buffers in the buffer list
      if (Bid != 0)
           imgMemUnlock(Bid);
                        
     // dispose the buffer
      if (ImaqBuffer != NULL)
           imgDisposeBuffer(ImaqBuffer);
                        
    // close this buffer list
      if (Bid != 0)
          imgDisposeBufList(Bid, FALSE);
                                        
    // Close the interface and the session
          imgClose (Sid, TRUE);
          imgClose (Iid, TRUE);
                        
          break;
      }
      return 0;
}
현재 이미지는 288 * 576 입니다.
그런데 이상태에서 이미지를 90도 회전(576 * 288)하거나 반전해서 출력할수는 없는지요?
이미지 버퍼를 건드릴수있는지 궁금합니다. 아니면 imgPlot함수에 그런기능이있거나 또는 이미지를 회전할수있는 함수가있는지 궁금합니다.
또는 이미지를 회전해서 출력할수있는방법을 알려주세요 부탁드리겠습니다.

이중훈

2009.09.24 18:21:22
*.93.130.66

이번에 로봇을 만들며 비젼을 달게되었습니다.
그런데 비젼을 달고 보니 작업자와 로봇이 상하, 좌우가
반대로 되어 있더군요.
그래서 저는 상하와 좌우를 완전히 대칭하도록 만들었습니다.
가장 고전적인 방법으로요.

//// 화면 좌우 대칭하도록 함
for(i=0;i<480;i++)
{
for(j=0;j<640;j++)
CopyBuffer1[i*640+j] = buf_temp[i*640+640-j-1];
}

//// 화면 상하 대칭하도록 함
for(i=0;i<480;i++)
{
for(j=0;j<640;j++)
CopyBuffer[i*640+j] = CopyBuffer1[(480-i-1)*640+j];
}

// Display it using imgPlot
imgPlot ((GUIHNDL)CVIWndHndl, CopyBuffer, 0, 0, AcqWinWidth, AcqWinHeight,
CanvasLeft, CanvasTop, PlotFlag);

이렇게 하니 비젼을 촬영할때 좌우와 상하가 뒤집어져 영상이 나옵니다.
이 방법으로 90도 회전도 방법을 찾으시는 것이 어떨까요?
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 이제부터 질문은 LabWindows/CVI 카페를 이용하면 더 좋겠습니다 운영자 2020-11-11 1235
공지 파일(특히 그림파일)을 올리실 때의 유의사항 운영자 2004-07-16 100156
1249 table 관련해서 질문드립니다. Birock 2009-10-22 4343
1248 작성중인 코드의 버젼을 변경하고 싶은데요. 권순기 2009-10-15 4483
1247 [re] 프로그램 실행파일의 버전 표시 file 허창원 2009-10-16 5099
1246 ^^;계측기 control [1] 신입 2009-10-14 4544
1245 안녕하세요. CVI TEXTBOX에서 중국어 볼 수 있는 방법이요 [2] 신입 2009-10-14 5080
1244 edit and continue 기능이 있나요? [1] 권순기 2009-10-08 4979
1243 [re] edit and continue 기능이 있나요? file 야리싸내 2009-10-17 9837
1242 그래프의 snap to point 커서 기능에서 좌표를 얻을 수 있나요? [1] 권순기 2009-10-07 5113
1241 모션관련 추가 질문입니다. [1] 이중훈 2009-09-25 4200
1240 Decoration 위에 놓은 컨트롤이 보이지 않습니다. [3] 권순기 2009-09-25 4319
1239 [re] 컨트롤의 Z Plane 순서 조정 file [1] 허창원 2009-09-25 5217
1238 모션카드는 어떤걸 사용해야 하나요? [1] 이중훈 2009-09-24 4679
» [IMAQ] 관련 질문입니다. 도와주세요 ㅠㅠ [1] 김기태 2009-09-07 3820
1236 버전별 Font종류에 대해서 궁금합니다. file [1] 정재용 2009-08-26 4799
1235 컨트롤 회전 [1] dafferDON 2009-08-26 5333
1234 완전 초보입니다.. 시작하는 입장에서.. [1] 장시영 2009-08-21 4843
1233 시리얼 프로그램 궁금한점입니다 [2] 이정호 2009-07-30 4145
1232 그룹 상자에 대한 질문입니다. [2] 김도연 2009-07-23 3637
1231 GUI에 7-Segment에 관한 질문입니다. [2] 영근 2009-07-21 4947
1230 CVI에서 오픈오피스 제어가능한가요? 자겸 2009-07-20 4961