我正在尝试在磁盘上写帧:
.......
cv::Mat frame,frame32f;
char filename[40];
cv::Mat mean;
const int count =134;
const int width = 1920;
const int height = 1080;
cv::Mat resultframe = cv::Mat::zeros(height,width,CV_32FC3);
cv::Mat deviationframe = cv::Mat ::zeros(height,width,CV_32FC3);
cv::Mat deviationframe2write = cv::Mat ::zeros(height,width,CV_32FC3);
cv::Mat temp = 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;
frame.release();
}
resultframe *= (1.0/count);
for(int j =1; j<count; j++){
sprintf(filename,"d:\\BMdvideos\\images\\image%d.tiff",j);
frame = imread(filename,CV_LOAD_IMAGE_COLOR);
frame.convertTo(frame32f,CV_32FC3);
temp =(frame32f - resultframe);
deviationframe+= temp.mul(temp);
//temp.release();
}
deviationframe *= 1.0/(count -1);
deviationframe2write +=deviationframe;
cv::sqrt(deviationframe2write,deviationframe2write);
deviationframe= deviationframe/255;
cv::sqrt(deviationframe,deviationframe);
cv::imwrite("mean.tif",resultframe);
cv::imwrite("stdDev.tif",deviationframe2write);
resultframe *= 1.0/255.0;
imshow("mean ",resultframe);
imshow("deviation frame ",deviationframe);
waitKey(0);
return 0;
}
如你所见,我在将其乘以255之前写出均值但是使用deviationframe
这只是不起作用意味着我确实保存deviationframe2write
但是当我打开它时它只是黑色任何想法我在这里缺少什么?提前谢谢