cv::add 在 openCV 中不起作用
cv::add doesn't work in openCV
我尝试建立10帧的平均值,所以我尝试:
.....
cv::Mat frame,outf,resultframe1, resultframe2;
VideoCapture cap(1);
cap>> frame;
resultframe1 = Mat::zeros(frame.rows,frame.cols,CV_32F);
resultframe2 = Mat::zeros(frame.rows,frame.cols,CV_32F);
while(waitKey(0) != 27}{
cap>> frame;
if ( waitKey(1) = 'm'){
for ( int j = 0 ; j <= 10 ; j++){
cv::add(frame,resultframe1,resultframe2);// here crashes the program ?????
....
}
}
any Idea我该如何解决这个问题?提前感谢
当OpenCV c++接口中有操作符可用时,不需要显式调用add函数。下面是如何计算指定帧数的平均值。
void main()
{
cv::VideoCapture cap(-1);
if(!cap.isOpened())
{
cout<<"Capture Not Opened"<<endl; return;
}
//Number of frames to take average of
const int count = 10;
const int width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
const int height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cv::Mat frame, frame32f;
cv::Mat resultframe = cv::Mat::zeros(height,width,CV_32FC3);
for(int i=0; i<count; i++)
{
cap>>frame;
if(frame.empty())
{
cout<<"Capture Finished"<<endl; break;
}
//Convert the input frame to float, without any scaling
frame.convertTo(frame32f,CV_32FC3);
//Add the captured image to the result.
resultframe += frame32f;
}
//Average the frame values.
resultframe *= (1.0/count);
/*
* Result frame is of float data type
* Scale the values from 0.0 to 1.0 to visualize the image.
*/
resultframe /= 255.0f;
cv::imshow("Average",resultframe);
cv::waitKey();
}
在创建矩阵时始终指定完整类型,例如CV_32FC3
而不仅仅是CV_32F
。
相关文章:
- Opencv GStreamer管道在Raspberry Pi 4上不起作用
- 用于 N 个最佳匹配的 OpenCV 模板匹配不起作用
- Opencv在2013年第5季度不起作用.应用程序总是在窗口中崩溃
- Opencv 链接 CMAKE 不起作用 Ubuntu 16.04 Docker
- OPENCV C IMSHOW不起作用
- 我的OPENCV不起作用
- Opencv ml 头文件不起作用
- OpenCV Canny 之后的 ConvexPoly 不起作用
- OpenCV像素操作有时不起作用
- 套接字不起作用,当添加 opencv libriary
- 在Linux(Raspbian)中,OpenCV集(CV_CAP_PROP_FPS,60)不起作用
- opencv 将较小的图片放在较大的副本中不起作用
- 为什么 openCV 的转换功能不起作用?
- 使用 OpenCV 的琐碎随机森林不起作用,与 sklearn 不同
- 视频抓取不起作用 OpenCV
- 将opencv图像转换为gdi位图不起作用取决于图像大小
- OpenCV c++HoughLines转换不起作用
- opencv中的Core.add方法在Android上不起作用
- OpenCV - 网络摄像头不起作用
- OpenCV imshow() 不起作用