Escolar Documentos
Profissional Documentos
Cultura Documentos
2018
shafikalsalem@gmail.com
*/
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
int main()
VideoCapture cap(0);
if(!cap.isOpened())
cout<<"error";
return -1;
}
Mat frame1(640,480,CV_8UC3);
Mat whiteLane(640,480,CV_8UC3);
Mat yellowLane(640,480,CV_8UC3);
Mat LinesImg(640,480,CV_8UC3);
Mat HSV_Img(640,480,CV_8UC3);
while(1)
bool b=cap.read(frame1);
if(!b)
cout<<"err";
cap.open("laneD.mp4");
cap.read(frame1);
// break;
//resize image
cv::Scalar sumImg=sum(frame1);
//normalise by the number of pixes in the image to obtain an extimate for the
illuminant
cv::Scalar illum=sumImg/(frame1.rows*frame1.cols);
// Split the image into different channels
std::vector<cv::Mat> rgbChannels(3);
cv::split(frame1, rgbChannels);
cv::Mat redImg=rgbChannels[2];
cv::Mat greenImg=rgbChannels[1];
cv::Mat blueImg=rgbChannels[0];
//calculate scale factor for normalisation you can use 255 instead
double scale=(illum(0)+illum(1)+illum(2))/3;
redImg=redImg*scale/illum(2);
greenImg=greenImg*scale/illum(1);
blueImg=blueImg*scale/illum(0);
//Assign the processed channels back into vector to use in the cv::merge()
function
rgbChannels[0]=blueImg;
rgbChannels[1]=greenImg;
rgbChannels[2]=redImg;
Mat frame;
merge(rgbChannels, frame);
//Create a window
//namedWindow("framme");
//imshow("framme",HSV_Img);
// Morphological Operation
vector<Vec4i> lines;
double rho = 1;
int gt[4];
if((blue!=0)&&(green!=0)&&(red!=0))
printf("%d %d %d \n",blue,green,red);
//stt[0][row][col] = (LinesImg.at<uchar>(color.val[0],row,col));
//stt[1][row][col] =(double)(LinesImg.at<uchar>(color.val[1],row,col));
//stt[2][row][col] =(double)(LinesImg.at<uchar>(color.val[2],row,col));
break;
//{
//if(stt[row][col]==255)
//{
//gt[0]=row;
//gt[1]=col;
//break;
//}
//}
////printf("%d \n",gt[0]);
//{
//if(stt[row][col]==255)
//{
//gt[2]=row;
//gt[3]=col;
//break;
//}
//}
//printf("%lf \n",stt[0][yellowLane.rows]);
//{
//stt++;
//if((stt==1)||(stt==4))
//{
//}
////if(stt>4)
////stt=0;
////line( frame, Point(l2[0], l2[1]), Point(l2[2], l2[3]), redColor , 3,
CV_AA);
//}
//line(frame,Point((gt[2] + gt[0])/2,gt[1]),Point((gt[2] +
gt[0])/2,gt[3]),Scalar(255),2,8,0);
namedWindow("frame");
imshow("frame",frame);
namedWindow("YellowLane");
imshow("YellowLane",yellowLane);
//namedWindow("WhiteLane");
//imshow("WhiteLane",HSV_Img);
//vector<Mat> bgr_planes;
//{
//Scalar( 0, 0, 255), 2, 8, 0 );
//}
if(waitKey(30)==27)
cout<<"esc";
break;
return 0;