OpenCV Python: Different Versions of OpenCV produce different results when HoughLinesP() function is called with the same arguments

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:

print('cv2 version=' + cv2.__version__)
img = cv2.imread(sys.argv[1], 0)
lines = cv2.HoughLinesP(img, 1.0, numpy.pi/(1.0*360.0), 5, minLineLength=14, maxLineGap=9)
print('number of lines detected: ' + str(max(len(lines), len(lines[0]))))
print(lines)

When run with the exact same file on the different versions of OpenCV here are the results:

cv2 version=$Rev: 4557 $
number of lines detected:  16
[[[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
number of lines detected:15
[[[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]. It is worth noting that this disparity in results between versions is a rare occurrence and has only happened with a few of the images I have tested, it is still a problem as sometimes it misses important lines.

Does anyone know if it is possible to reproduce the exact results as OpenCV Rev: 4557 in OpenCV 3.4.2 or later.

do you know what version corresponds to “Rev 4557”? your code must be from 2012 or earlier.

https://answers.opencv.org/question/945/cant-checkout-from-svn-repository-version-242/

you have to expect bug fixes and improvements to code. if you think it’s missing a line that it should find according to all the parameters and the principle of its operation, please prepare a bug report including a Minimal Reproducing Example including all required data.

I’m not too sure exactly what version Rev: 4557 corresponds to. However, I have run the code on OpenCV 2.4.9.1 and that gets the exact same results as the Rev: 4557 version.