In my code I'm detecting only vertical lines via HoughLinesP (OpenCV). Here's an example of an cut out output:
It was once a door, then I applied the canny algorithm. By setting only the 90 degree angle, there will be only vertical lines detected (the red ones). But now I would like to add also the green lines to this small section above a door.
The angle is calculated like this:
double angle = atan2(ppt2.y - ppt1.y, ppt2.x - ppt1.x) * 180.0 / CV_PI;
if (angle) {
line(cdst, ppt1, ppt2, Scalar(0, 0, 255), 2, CV_AA);
}
So how could I additionally detect the green ones? And especially only those above a door? Thanks!
Your results are only showing vertical lines, and while yes you are rejecting precisely horizontal lines you might want to review what that test is actually removing. Also rejecting horizontal lines isn't the same as accepting only vertical lines, I think in this case you are basically only getting vertical lines from HoughLinesP.
Anyway, to get some more diagonal lines detected you will have to change the HoughLinesP theta parameter, from pi/2:
to, for example:
And then you probably need to make your angle reject more robust/sophisticated to reject oddly angled lines as well as precisely 0.000000000000 radians lines as returned by atan2 and anyway it would seem to be a lot more resilient to e.g. small changes in picture angle, to check for a range of angles e.g. +/-0.01