c语言中cv的作用,c-cv :: add在openCV中不起作用

当您在OpenCV C接口中有可用的运算符时,无需显式调用add函数.这是平均指定帧数的方法.

void main()

{

cv::VideoCapture cap(-1);

if(!cap.isOpened())

{

cout<

}

//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

{

cap>>frame;

if(frame.empty())

{

cout<

}

//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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值