mercredi 27 février 2019

Can't get live video with uEye and OpenCV

i'm using an IDS camera, and I would like to do some video processing but i can't get the video live. I'm using QtCreator (C++) with OpenCV and uEye, the problem is that, i'm getting soms errors.

Here's my code :

`

// camera initialization
int returnedStatus = is_InitCamera(&hCam, NULL);
cout<<"Status Init: "<<returnedStatus<<endl;

// set image size
int imgWidth=792, imgHeight=480;

char *capturedImage = NULL;
int memoryId = 0;

// allocate memory for image capturing
returnedStatus = is_AllocImageMem(hCam, imgWidth, imgHeight, 24, &capturedImage, &memoryId);
cout<<"Status AllocImage: "<<returnedStatus<<endl;

returnedStatus = is_SetImageMem(hCam, capturedImage, memoryId);
cout<<"Status SetImageMem: "<<returnedStatus<<endl;

for(;;){
    // capture frame
    is_CaptureVideo(hCam, IS_DONT_WAIT);
    IplImage* tmpImg;
    tmpImg = cvCreateImageHeader(cvSize(imgWidth, imgHeight), IPL_DEPTH_8U, 3);
   // tmpImg = cvCreateImage(cvSize(imgWidth,imgHeight),CV_8UC3,3);
    tmpImg->imageData = capturedImage;
    cv::Mat mat_img;//(imgWidth, imgHeight,3);
     // To IplImage
    IplImage ipltemp=mat_img;
    cvCopy(&ipltemp,tmpImg);
    // display captured image
    cv::imshow( "Display window", mat_img);
    cv::waitKey(0);

}

`

The error is :

terminate called after throwing an instance of 'cv::Exception' what(): OpenCV(4.0.1-dev) /home/sabrina/Téléchargements/opencv-master/modules/core/src/matrix_c.cpp:185: error: (-5:Bad argument) Unknown array type in function 'cvarrToMat'

Please help me to solve this problem

Thank you

Aucun commentaire:

Enregistrer un commentaire