gpt4 book ai didi

c++ - 需要帮助理解为什么我在 OpenCV C 代码中收到此错误消息...?

转载 作者:行者123 更新时间:2023-11-28 03:10:51 34 4
gpt4 key购买 nike

这里是错误:

Error no Operand "<<" matches these operands

我出错的行是:

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

但是如果我使用这一行我不会出错:

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

代码如下:

#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;
}
//////////////////////////////////////

这是为什么....请帮我得到变量“size”的输出并请引用在线资源作为您的答案,这样我就可以学习获取任何 OpenCV 变量的输出。

最佳答案

没有 CvSize 流插入器。如果你想要那个语法,那么定义一个:

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

关于c++ - 需要帮助理解为什么我在 OpenCV C 代码中收到此错误消息...?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18546039/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com