Ask Your Question
0

handling camera buffer

asked 2013-11-26 01:16:19 -0600

Aruna Vijay gravatar image

updated 2013-11-26 04:31:37 -0600

Haris gravatar image

In my project i already have camera output in a buffer

ProcessFrames(unsigned char *RefFrame,unsigned char *CurrentFrame, int width,int height)

{


    IplImage *ReferenceImage = cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,1);
    IplImage *CurrentImage     = cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,1);
    IplImage *ResultImage       = cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,1);
   // my camera input is Grey so i keep all at same depth 
    cvSetData( ReferenceImage, RefFrame, width );
    cvSetData( CurrentImage, CurrentFrame, width ); // fine until here 

    cvAbsDiff(ReferenceImage, CurrentImage, ResultImage); 
           // here is the culprit for crash  
          // can somebody point what is going wrong here    

//finally i do this 

        cvReleaseImageHeader(&ReferenceImage);
    cvReleaseImageHeader(&CurrentImage);
        cvReleaseImageHeader(&ResultImage);
}

after core dump i get the message

OpenCV Error: Bad argument (Unknown array type) in cvarrToMat
Downloads/opencv-2.4.7/modules/core/src/matrix.cpp, line 698
terminate called after throwing an instance of 'cv::Exception'
  what():  Downloads/opencv-2.4.7/modules/core/src/matrix.cpp:698: error: (-5) Unknown array type in function cvarrToMat
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-11-26 04:30:17 -0600

Haris gravatar image

The line

IplImage *ResultImage       = cvCreateImageHeader(cvSize(width,height),IPL_DEPTH_8U,1);

should be

IplImage *ResultImage       = cvCreateImage(cvSize(width,height),IPL_DEPTH_8U,1);

Or you need to use cvSetData() on ResultImage before passing to cvAbsDiff()

like

cvSetData( ResultImage, CurrentFrame, width );
edit flag offensive delete link more

Comments

thanks..it solved problem

Aruna Vijay gravatar imageAruna Vijay ( 2013-11-26 07:51:28 -0600 )edit

Question Tools

Stats

Asked: 2013-11-26 01:16:19 -0600

Seen: 695 times

Last updated: Nov 26 '13