2/29/2012

Pattern Image for Camera Calibration


[ Download Pattern.pdf ]

To convert from MyVisionUSB to OpenCV and Display (source code)



This is sample source to convert MyVision USB to OpenCV.
You need MyVision USB library to handle image buffer.

This link is included "MVULib.lib, MVULib.dll, MyVision.h".
Lib Download
And you can download driver file on the http://withrobot.com/157.


The below source is sample code to convert MyVision USB to OpenCV.
This code don't use memcpy. so it is little bit slow. The code needs upgrade to speed up.

#include < stdio.h >
#include < cv.h >
#include < cxcore.h >
#include < highgui.h >
#include < cvaux.h >
#include "MyVision.h"

using namespace std;

void main()
{

 //////////////////////////////////////////////////
 //MyVisionUSB Setting
 HBUF m_hBuf;
 HDIG m_hDig;
 char* ver = sysGetLibVer();
 if(strcmp(ver, MV_LIB_VER) != 0)
  printf("incorrect library version\n");
 m_hBuf = bufAlloc(640,480, MV_RGB32 | MV_DOUBLE);
 if(!m_hBuf)
  printf("Cann't Alloc Buffer\n");
 m_hDig = digAlloc(MV_DEV0);
 if(!m_hDig)
  printf("Cann't Alloc Digitizer");
 digGrabContinuous(m_hDig, m_hBuf);
 RGB32_T** pixel = (RGB32_T**)bufGetPtr2D(m_hBuf);
 ////////////////////////////////////////////////////



 //////////////////////////////////////////////////////////////////////////
 //OpenCV Setting
 cvNamedWindow("MyVisionUSBtoOpenCV",CV_WINDOW_AUTOSIZE);
 IplImage * img = cvCreateImage(cvSize(640,480), 8, 3);


 int color, R, G, B, c; 
 while(1)
 {  
  digGrabWait(m_hDig, MV_FIELD_EVEN);

  for(int i=0; i<480 color="color" for="for" i="i" int="int" j="j" r="RGB32_TO_R(color);" xff0000="xff0000">>16);
    G = RGB32_TO_G(color);  // (((color)&0x00ff00)>>8);
    B = RGB32_TO_B(color);  // (((color)&0x0000ff));

    img->imageData[i*img->widthStep+j*3+0] = B;
    img->imageData[i*img->widthStep+j*3+1] = G;
    img->imageData[i*img->widthStep+j*3+2] = R;
   }
  }

  cvShowImage("MyVisionUSBtoOpenCV",img);    
  if( cvWaitKey(10) > 0 )
   break;
 }


 //////////////////////////////////////////////////////////////////////////
 //release memory
 cvReleaseImage(&img);
 cvDestroyAllWindows();
 //
 digHalt(m_hDig);
 digFree(m_hDig);
 bufFree(m_hBuf);


}