#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2\imgproc\types_c.h>
#include <opencv2/opencv.hpp>
using namespace std;
float lightGray(cv::Mat img)
{
cv::Mat imgGray;
cv::cvtColor(img, imgGray, CV_BGR2GRAY);
cv::Scalar grayScalar = cv::mean(imgGray);
float imgGrayLight = grayScalar.val[0];
return imgGrayLight;
}
int main()
{
cv::VideoCapture capture("C:/Users/xxxx/Desktop/xxxx0220718-094521.mp4");
int i = 1;
float num = 0.0, ave = 0.0;
while (1)
{
cv::Mat frame;
capture >> frame;
if (frame.empty())
{
break;
}
float picLight = lightGray(frame);
cout << "NO." << i << "Light" << picLight << endl;
i++;
num = num + picLight;
cv::waitKey(1);
}
ave = num / i;
cout << "ave_Light" << ave << endl;
return 0;
}