How to integrate Opencv with specific camera control libs from the manufacturer?

asked 2014-02-19 06:14:52 -0600

tiho_bg gravatar image

updated 2014-02-19 06:32:50 -0600

berak gravatar image

Hi I am using the camera ProgRes speedxt core 5. I wanted to work with this camera using opencv but unfortunately it is not possible in fact. I have startet to read the libs of the camera sent by the manufacturer. Now I can open the camera but I would like to visualize the image on the desctop using opencv library. Could somebody help me? Here is my code for opening the camera:

#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\opencv.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>
#include <time.h>
#include <Windows.h>
#include "MexCam.h"
#include "MexCC.h"
#include <iomanip>
#include <process.h>


using namespace cv;
using namespace std;

int __stdcall CompletionProc (unsigned long status, mexImg* pImg, mexUsrVal completionUser);

int imageCounter=0;
mexImg Imgs[3]; // 3 images for CC-Live
mexImg* ImgPointerList[3]={&Imgs[0],&Imgs[1],&Imgs[2]}; // List of pointers to use in calls to mexAcquire
mexAcquisParams Pars;
//HANDLE hThread=NULL;
DWORD dwThreadID=0;

unsigned long channelBytes;

int main(){

unsigned __int64 GuidList[5]={0,0,0,0,0};
unsigned int NumberOfCameras=5;
unsigned char *pRgbI = new unsigned char[channelBytes];

    // MexConsole must announce begin of session with MexJCam.dll
mexInit(NULL,0); // By NULL,0 no callback are requested with respect to plug and play events for FireWire-cameras

  // Find all present ProgRes-cameras
  long mexResult=mexFindCameras(&NumberOfCameras,GuidList);

  long mexOpen=NOCAMERA;
  char q='q';
  int i=0;

  for(i=0; i<3; i++)
  {
    memset(&Imgs[i],0,sizeof(mexImg));
    Imgs[i].Bytes=sizeof(mexImg);
    Imgs[i].Version=MEXIMGVERSION;
  }

  if(NOERR==mexResult && NumberOfCameras>0)
  {
    mexCameraTypeSummary camTS;
    mexGetCameraTypeSummary(GuidList[0],&camTS);
    cout << "Try to open Camera " << camTS.TypeName << endl << endl;
    mexOpen=mexOpenCamera(GuidList[0]); // Use the first found camera
    if(NOERR==mexOpen)
    {
      cout << "Camera " << camTS.TypeName << " successful opened." << endl;
      cout << "Camera GUID " << setbase(16)<< setw(16) << setfill('0') << GuidList[0] << endl << endl;
      mexCamInfo camInfo;

      memset(&camInfo,0,sizeof(mexCamInfo));

      mexImageInfo imgInfo;
      memset(&imgInfo,0,sizeof(mexImageInfo));

      memset(&Pars,0,sizeof(mexAcquisParams));
      Pars.Bytes=sizeof(mexAcquisParams);
      Pars.Version=MEXACQUISPARAMSVERSION;
      mexCamType camtype=mexGetCameraType(GuidList[0]);
      mexResult=mexGetCameraInfo(GuidList[0],&camInfo);
      if(NOERR==mexResult)
      {
        // prepare acquisition parameter
    //    Pars.runas=runas_snap;
        Pars.runas=runas_cclive;
        switch(camtype)
        {
          case cam10plus:
          case cam12plus:
            Pars.mode=mexShot2F_lowqualitycol;
            break;
          case cam14Cplus:
            Pars.mode=mexc14_Shot_colhighres;
            break;
          case cam14Mplus:
            Pars.mode=mexm14_Shot_bwhighres;
            break;
          case camCt3:
            Pars.mode=mexct3_std;
            break;
          case camC7:
            Pars.mode=mexC7_colhighspeed1;
            break;
          case camC3usb:
               //LinCi
               Pars.mode = mexC3usb_bin2col;
               break;
          case camC5usb:
              Pars.mode = mexShot2F_Raw;// This is my camera;
              cout << "My camera" << endl;
              break;


        }
        ::SetRect(&Pars.rcsensorBounds,0,0,camInfo.SensorX,camInfo.SensorY);
        Pars.buseblackref=FALSE;
        Pars.busewhiteref=FALSE;
        Pars.bwhitebalance=FALSE;
        Pars.correctColors=0;
        Pars.ciCode=0;
        Pars.ccdtransferCode=0;
        Pars.notifymask=0;
        Pars.stdTicks=::mexMSecToTicks(GuidList[0],10,Pars.mode,0); // 10 milliseconds
        Pars.addTicks=0;
        Pars.complProc=&CompletionProc;
        Pars.completionUser=0;
        Pars.progressProc=NULL;
        Pars.progressUser=0;

        mexResult=mexGetAcquisitionInfo(GuidList[0],&Pars,&imgInfo);
        if(NOERR==mexResult)
        {
               channelBytes=imgInfo.DimY*imgInfo.DimX*imgInfo.PlaneBytes;        
          if(mex_chan_dib==imgInfo.Channels)
          {
            channelBytes=((3*imgInfo.DimX+3)&0xfffffffc)*imgInfo.DimY;
          } 

          // attention: Set all available information into ...
(more)
edit retag flag offensive close merge delete