This is my code:
int main() {
VideoCapture cap;
cap.open("D:/01.avi");
if (!cap.isOpened()) {
cout << "Video cannot be opened" << endl;
system("pause");
return -1;
}
VideoWriter cap_output("D:/01_ouput.avi",
cap.get(CV_CAP_PROP_FOURCC),
cap.get(CV_CAP_PROP_FPS),
Size(cap.get(CV_CAP_PROP_FRAME_WIDTH),
cap.get(CV_CAP_PROP_FRAME_HEIGHT)));
if (!cap_output.isOpened()) {
cout << "Output video cannot be opened" << endl;
return -1;
}
Mat frame, canny_frame, frame_ouput;
while (true) {
if (!cap.read(frame))
break;
Canny(frame, canny_frame, 50, 200, 3);
cvtColor(canny_frame, frame_ouput, CV_GRAY2BGR);
vector<Vec4i> lines;
HoughLinesP(canny_frame, lines, 1, CV_PI / 180, 100, 100, 10);
for (size_t i = 0; i < lines.size(); i++) {
Vec4i l = lines[i];
line(frame, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, 8);
}
imshow("ahoho", frame);
//cap_output.write(frame_ouput);
if (waitKey(30) >= 0) {
break;
}
}
cap.release();
cap_output.release();
return 0;
}
I want to detect the lines in only 1/2 height of the frame of the video (to avoid different objects). How can I do it?