简体   繁体   中英

OpenCV 2.2: bad argument in unknown function, file ..\..\..\..\ocv\opencv\modules\core\src\array.cpp

i have the above error when I'm trying to compile my code. Its a very very very simple function and I cant figure out why I have the problem. The worst is that i cant even find where array.cpp is in the opencv folder so i cant see whats wrong. Does anyone know? pls help!

int imgreg_capture_image()
{
    /*********************Try capturing an image from the camera first*************************************/

    CvCapture* imgregCapture = cvCaptureFromCAM( CV_CAP_ANY );
   if ( !imgregCapture ) {
     fprintf( stderr, "ERROR: capture is NULL \n" );

     exit(-1);
   }

     // Get one frame
     IplImage* frame = 0;
     frame = cvQueryFrame(imgregCapture);
     if ( !frame ) {
       fprintf( stderr, "ERROR: frame is null...\n" );
       return -1;
     }

   //save the image into a file
    cvSaveImage( CAPTURE_FILE, frame );

   // Release the capture device housekeeping

    cvReleaseCapture(&imgregCapture);

    cvReleaseImage(&frame);

   return 0;
   /***************Finish Try capturing an image from the camera first*************************************/
}

It is stated in the documentation that the images returned by cvQueryFrame don't have to be released. In your case delete

cvReleaseImage(&frame);

The de/allocation of frame is managed internally by the capturing device.

Hope that helps!

EDIT: If you wish to further process your image, use cvCopy(frame, yourManagedImage); , and work with yourManagedImage instead of the original frame .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM