#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
double alpha,bele;
//分离图像通道
vector<Mat> channels;
Mat frame;
Mat frame2;
Mat frame3;
void text(int, void*)
{
alpha = 0;
bele = 1.0;
split(frame, channels);
if (1)
frame2 = channels.at(2) - channels.at(0);
else
frame2= channels.at(0) - channels.at(2);
threshold(frame2,frame3,127,255,THRESH_BINARY);
Mat element = getStructuringElement(MORPH_ELLIPSE,Size(3,3));
dilate(frame3,frame3,element);
vector<vector<Point>> lightContours;
findContours(frame, lightContours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
imshow("frame",frame );
}
int main(int, void*)
{
VideoCapture capture("D:/1/1.avi");
while (1)
{
capture >> frame;
int i = 0;
int max = 1;
//imshow("red", channels.at(2));
// imshow("green", channels.at(1));
//imshow("blue", channels.at(0));
Mat midImage1 = channels.at(0) - channels.at(2);
threshold(midImage1, midImage1, 100, 255, THRESH_BINARY);
imshow("origina222", midImage1);
namedWindow("测试窗口", WINDOW_NORMAL);
//创建滑动条
createTrackbar("数字:", "测试窗口:", &i, max, text);
text(i, 0);
if (waitKey(30) >= 0)
break;
}
return 0;
}