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

**URL:** <https://forum.opencv.org/t/opencv-python-different-versions-of-opencv-produce-different-results-when-houghlinesp-function-is-called-with-the-same-arguments/823>\
**Category:** Python\
**Created:** [January 13, 2021, 5:34am UTC](https://forum.opencv.org/t/opencv-python-different-versions-of-opencv-produce-different-results-when-houghlinesp-function-is-called-with-the-same-arguments/823 "2021-01-13T05:34:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cammykerr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/cammykerr/32/530_2.png) [@cammykerr](https://forum.opencv.org/u/cammykerr)\
**Post date:** [January 13, 2021, 5:34am UTC](https://forum.opencv.org/t/opencv-python-different-versions-of-opencv-produce-different-results-when-houghlinesp-function-is-called-with-the-same-arguments/823/1 "2021-01-13T05:34:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 13, 2021, 12:34pm UTC](https://forum.opencv.org/t/opencv-python-different-versions-of-opencv-produce-different-results-when-houghlinesp-function-is-called-with-the-same-arguments/823/2 "2021-01-13T12:34:19Z")

</div>

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/](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.

---

<div class="post-metadata">

**Author:** ![cammykerr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/cammykerr/32/530_2.png) [@cammykerr](https://forum.opencv.org/u/cammykerr)\
**Post date:** [January 14, 2021, 7:46am UTC](https://forum.opencv.org/t/opencv-python-different-versions-of-opencv-produce-different-results-when-houghlinesp-function-is-called-with-the-same-arguments/823/3 "2021-01-14T07:46:07Z")

</div>

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.
