我正在尝试从我的框架中获取轮廓,这是我所做的:
cv::Mat frame,helpframe,yframe,frame32f;
Videocapture cap(1);
.......
while(waitkey()){
cv::Mat result = cv::Mat::zeros(height,width,CV_32FC3);
cap >> frame; // get a new frame from camera
frame.convertTo(frame32f,CV_32FC3);
for ( int w = 0; w< 10;w ++){
result += frame32f;
}
//Average the frame values.
result *= (1.0/10);
result /= 255.0f;
cvtColor(result,yframe,CV_RGB2YCrCb); // converting to Ycbcr///// the code work fine when I use frame instead of result
extractChannel(yframe,helpframe,0); //extracting the Y channel
cv::minMaxLoc(helpframe,&minValue,&maxValue,&min,&max);
std::vector<std::vector<cv::Point>> contours;
cv::findContours(helpframe, contours,CV_RETR_LIST /*CV_RETR_EXTERNAL*/, CV_CHAIN_APPROX_SIMPLE);
程序在findcontours
处崩溃,我进行了调试,得到以下错误信息:
OpenCV错误:不支持的格式或格式组合([Start]FindContours仅支持8uC1和32sC1图像)在未知函数中,文件......\src\opencv\modules\imgproc\src\contours.cpp, line 196
@Niko 感谢帮助,我认为我需要将helpframe转换为另一种类型。
当我使用result时,我得到
helpframe.type() => 5
并且使用frame时,我得到0
但我不知道这是什么意思?但我会尝试找到一种将helpframe转换的方法。
通过以下方式转换helpframe: helpframe.convertTo(helpframe2,CV_8U)
我什么都没有得到,helpframe2=0??而当我在resultframe上进行相同操作时,转换却成功了??
您有何建议应如何更改helpframe类型,因为我使用了result而不是frame?
findContours
之前检查一下helpframe.channels()
报告的内容吗? - Niko