如何赶上出发并产生警告

时间:2015-07-14 09:48:43

标签: c++ opencv

我只是开放式CV和c ++的另一个初学者。 我使用两个摄像头通过俯视图检测车道并成功检测到并标记了车道。但现在我想在车道穿越或离开的情况下发出警告。请尽快提供帮助,因为我有截止日期。帮助将不胜感激。

cv::VideoCapture camera0 (0);
cv::VideoCapture camera1 (1);

if( !camera0.isOpened() ) return 1;
if( !camera1.isOpened() ) return 1;

while(true) {
    //capture and retrieve each frames of the video sequentially, one frame at time will be displayed 
    // capture from 1st camera
    Mat edges0, edges1;
    cv::Mat3b frame0;
    camera0 >> frame0;
    // Performing edge detection on camera 1
    Mat dst0, cdst0;

    GaussianBlur(frame0, frame0, Size(7,7), 1.5, 1.5);
    Canny(frame0, dst0, 50, 200, 3);
    cvtColor(dst0, cdst0, CV_GRAY2BGR);
    vector<Vec4i> lines;
    HoughLinesP(dst0, lines, 1, CV_PI/180, 50, 50, 100 );
    for( size_t i = 0; i < lines.size(); i++ )
    {
Vec4i l = lines[i];
line( cdst0, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
}
    //capturing frames from second camera
    cv::Mat3b frame1;
    camera1 >> frame1;
    // performing edge detection on camera 2
    Mat dst1, cdst1;

    GaussianBlur(frame1, frame1, Size(7,7), 1.5, 1.5);
   Canny(frame1, dst1, 50, 200, 3);
   cvtColor(dst1, cdst1, CV_GRAY2BGR);

  HoughLinesP(dst1, lines, 1, CV_PI/180, 50, 50, 100 );
  for( size_t i = 0; i < lines.size(); i++ )
  {
  Vec4i l = lines[i];
  line( cdst1, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
  }

    cv::imshow("Left Lane", cdst0);
    cv::imshow("Right Lane", cdst1);



    //wait for 40 milliseconds
    int c = cvWaitKey(30);

    //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27) 
    if(27 == char(c)) break;


}


return 0;

}

0 个答案:

没有答案