Trooble with OpenCV with cvarrToMat

asked 2012-12-05 05:03:11 -0500

fabio gravatar image
Hi,

I have issues when I execute my program (see below):

#include "opencv2/video/tracking.hpp"

#include "opencv2/imgproc/imgproc.hpp"

#include "opencv2/highgui/highgui.hpp"

#include <time.h>

#include <stdio.h>

#include <ctype.h>

int main(int argc, char** argv) {

CvCapture *capture;
IplImage *FrameRef;
IplImage *NextFrame;
IplImage *NextFrameGrey;
IplImage *BitImage;
IplImage *ImageResultSubstract;
IplImage *FrameRefGrey;

// Capture the Image from the webcam
capture = cvCreateCameraCapture(0);

// Get the frame
FrameRef = cvQueryFrame(capture);

// Image bufferised
cvCloneImage(FrameRef);

// Convert color image in grey image
cvCvtColor(FrameRef,FrameRefGrey,CV_RGB2GRAY);

while(1){

    // Capturing the next frame
    NextFrame = cvQueryFrame(capture);

    // Image bufferised
    cvCloneImage(NextFrame);

    // Convert color image in grey image
    cvCvtColor(NextFrame,NextFrameGrey,CV_RGB2GRAY);

    // Substrac FrameRefGrey and NextFrameGrey
    cvAbsDiff(FrameRefGrey,NextFrameGrey,ImageResultSubstract);

    // public static double cvThreshold(
    //  IntPtr image_source,
    //  IntPtr image_destination,
    //  double threshold,
    //  double maxValue,
    //  THRESH thresholdType)

    // Apply a threshold
    cvThreshold(ImageResultSubstract,BitImage,100,255,CV_THRESH_BINARY);

    // 
    cvShowImage("CamSub", BitImage);

    if(cvWaitKey(10) >= 0 ){
            break;
    }

    cvReleaseCapture( &capture );
    cvDestroyWindow( "Motion" );

}

}

When I execute, my webcam works 2 sec and after I see this message on command windows

-> OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /home/morbiducci/OpenCV-2.3.1/modules/core/src/matrix.cpp, line 646 terminate called after throwing an instance of 'cv::Exception' what(): /home/morbiducci/OpenCV-2.3.1/modules/core/src/matrix.cpp:646: error: (-5) Unknown array type in function cvarrToMat

Abandon

Someone had had this problem? I need help because I dont know openCV completely :s

Sicerely

Faab

edit retag flag offensive close merge delete