我正在尝试使用opencv获取多张图片的平均值,这是我的代码:
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main(){
cv::Mat frame,frame32f;
char filename[40];
cv::Mat mean;
const int count =10;
const int width = 1920;
const int height = 1080;
cv::Mat resultframe = cv::Mat::zeros(height,width,CV_32FC3);
for(int i = 1 ; i<= count; i++){
sprintf(filename,"d:\\BMdvideos\\images\\image%d.tiff",i);
frame = imread(filename,CV_LOAD_IMAGE_COLOR);
frame.convertTo(frame32f,CV_32FC3);
resultframe +=frame32f;
cout << " i = " << i<<endl;
frame.release();
}
resultframe *= (1.0/count);
imshow("",resultframe);
waitKey(0);
return 0;
}
我在 imshow 中总是得到一个白框,不知道为什么我会得到这个。在此先感谢您的帮助 !