user2735131
user2735131

Reputation:

need help understanding why I'm getting this error message in OpenCV C code...?

here is the error:

Error no Operand "<<" matches these operands

the line I get error on is:

cout << "M = "<< endl << " " << size << endl << endl;

but if I use this line I get no error:

cout << "M = "<< endl << " " << frame << endl << endl;

here is the code:

#include <cv.h>
#include <highgui.h>


using namespace std;
int main(){
CvCapture* capture =0;

capture = cvCreateCameraCapture(0);
if(!capture){
//printf("Capture failure\n");
return -1;
}

IplImage* frame=0;
int size = 0;
cvNamedWindow("Video");


//iterate through each frames of the video
while(true){

frame = cvQueryFrame(capture);
if(!frame) break;

frame=cvCloneImage(frame);

CvSize size = cvGetSize(frame);
cout << "M = "<< endl << " " << size << endl << endl;
//Clean up used images

cvReleaseImage(&frame);

//Wait 50mS
int c = cvWaitKey(10);
//If 'ESC' is pressed, break the loop
if((char)c==27 ) break;
}

cvDestroyAllWindows() ;
cvReleaseCapture(&capture);

return 0;
}
//////////////////////////////////////

why is that....please help me get output of variable "size" and please cite online resource for your answer so I may learn to get output of any OpenCV variable.

Upvotes: 0

Views: 98

Answers (2)

WhozCraig
WhozCraig

Reputation: 66194

There is no CvSize stream inserter. If you want that syntax, then define one:

std::ostream& operator <<(std::ostream& os, const CvSize& siz)
{
    os << siz.width << ',' << siz.height;
    return os;
}

Upvotes: 1

P0W
P0W

Reputation: 47784

CvSize is a structure and size is of type CvSize

You need to use it like following :

cout <<" Height:" << size.height<<" Width:"<< size.width<< endl;

However frame is pointer to a IplImage

using a cout on frame will just give you a memory address pointed by frame

Upvotes: 1

Related Questions