I have a video that records car traffic in the road and I want to do a detection and counting of these cars with opencv 3.0.0 and c ++, and here I have the following source code
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
#include<conio.h> // it may be necessary to change or remove this line if not using Windows
int main(int argc, char** argv)
{
cv::VideoCapture capVideo;
capVideo.open("CarsDrivingUnderBridge.mp4");
if (!capVideo.isOpened())
return -1;
Mat frame;
/// Create Window
namedWindow("Result", 1);
while (true) {
//grab and retrieve each frames of the video sequentially
cap >> frame;
//draw a line onto the frame
line(frame, Point(0, frame.rows / 2), Point(frame.cols, frame.rows / 2), Scalar(0), 3);
//display the result
imshow("Result", frame);
line(frame, Point(0, frame.rows / 8), Point(frame.cols, frame.rows / 8), Scalar(0), 3);
imshow("Result", frame);
//wait some time for the frame to render
waitKey(30);
}
return 0;
}
This code makes it possible to read the video and draw on this video two lines. what can i add for this source code For the lines to detect the cars and count those cars