I have some code from a while ago that runs on an old version of OpenCV (cv2 version=$Rev: 4557 $) and I am trying to update it to work on a later version (cv2 version=3.4.2).
The problem I am having is that when given the exact same parameters, the HoughLinesP function does not always produce the exact same output in both versions.
Here is a bit of code I created that demonstrates this occurrence:
import cv2
print('cv2 version=' + cv2.__version__ + '
')
img = cv2.imread('img.png', 0)
lines = cv2.HoughLinesP(img, 1.0, 0.008726646259971648, 5, minLineLength=14, maxLineGap=9)
print(lines)
Here is the image being used:
Here is the output of each version of the code:
cv2 version=$Rev: 4557 $
[[[371 0 377 127]
[370 0 376 127]
[381 193 386 397]
[383 237 383 255]
[386 311 387 397]
[380 194 381 278]
[383 322 383 294]
[379 195 379 217]
[370 4 371 43]
[385 379 385 395]
[385 332 385 301]
[374 34 375 55]
[381 250 382 207]
[386 364 387 335]
[382 279 382 256]
[372 67 376 90]]]
cv2 version=3.4.2
[[[371 0 377 127]]
[[370 0 376 127]]
[[381 193 386 397]]
[[383 237 383 255]]
[[386 311 387 397]]
[[380 194 381 278]]
[[383 322 383 294]]
[[379 195 379 217]]
[[370 4 371 43]]
[[385 379 385 395]]
[[385 332 385 301]]
[[374 34 375 55]]
[[381 250 382 207]]
[[386 364 387 335]]
[[382 279 382 256]]]
When run with OpenCV version 3.4.2, all the same lines as the older version are found except for the last line [372 67 376 90].
Note: The HoughLinesP function also produces results in a different format, in the $Rev: 4557 $ version, the output is a single-item array, that item being an array of all the detected lines.
e.g. [[[line1],[line2],[line3],[line4]]]
Whereas on the 3.4.2 version the output is a multi-item array, where each item is a single item array containing a differnt detected line.
e.g. [[[line1]],[[line2]],[[line3]],[[line4]]]
I am aware of this difference in formats between both versions and have accounted for it in my updated code. What I need to know is why are some of the lines that were detected when using $Rev: 4557 $ not detected when using OpenCV version 3.4.2 and how can I replicate the same results on version 3.4.2.
question from:
https://stackoverflow.com/questions/65626203/opencv-python-houghlinesp-function-produces-different-results-when-run-with-dif