From 3b8c83c0ecc9d16a0df941ee27b3334fdd21ac83 Mon Sep 17 00:00:00 2001 From: shreedhar-sde Date: Mon, 7 Apr 2025 23:59:37 +0530 Subject: [PATCH 1/3] Update py_houghlines.rst The current code identified only one random line on the example image. This could be confusing for the novice perusing this for their study. Modified the code to detect all the lines in the image --- .../py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst index ba3c0b3..ba753d6 100644 --- a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst +++ b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst @@ -51,12 +51,13 @@ Everything explained above is encapsulated in the OpenCV function, **cv2.HoughLi import cv2 import numpy as np - img = cv2.imread('dave.jpg') + img = cv2.imread('dave.png') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,50,150,apertureSize = 3) lines = cv2.HoughLines(edges,1,np.pi/180,200) - for rho,theta in lines[0]: + for line in lines: + rho,theta= line[0] a = np.cos(theta) b = np.sin(theta) x0 = a*rho From acb0a404bf859fe9784b635d744912f9a2ff835f Mon Sep 17 00:00:00 2001 From: shreedhar-sde Date: Tue, 8 Apr 2025 00:12:06 +0530 Subject: [PATCH 2/3] Update py_houghlines.rst The current code identified only one random line on the example image. This could be confusing for the novice perusing this for their study. Modified the code to detect all the lines in the image [Created a same change for non-probabilistic algorithm] --- .../py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst index ba753d6..50f0168 100644 --- a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst +++ b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst @@ -102,10 +102,11 @@ Best thing is that, it directly returns the two endpoints of lines. In previous minLineLength = 100 maxLineGap = 10 lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap) - for x1,y1,x2,y2 in lines[0]: + for line in lines: + x1,y1,x2,y2=line[0] cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2) - cv2.imwrite('houghlines5.jpg',img) + cv2.imwrite('houghlines5.jpg',img) See the results below: From cb339749cffbfa7a036f2d6a73750501bedf56f7 Mon Sep 17 00:00:00 2001 From: shreedhar-sde Date: Tue, 8 Apr 2025 00:18:27 +0530 Subject: [PATCH 3/3] Update py_houghlines.rst Made the example text match the actual output of the code. fix: changed the extension to match the one from original repo --- source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst index 50f0168..a10572c 100644 --- a/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst +++ b/source/py_tutorials/py_imgproc/py_houghlines/py_houghlines.rst @@ -51,7 +51,7 @@ Everything explained above is encapsulated in the OpenCV function, **cv2.HoughLi import cv2 import numpy as np - img = cv2.imread('dave.png') + img = cv2.imread('dave.jpg') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,50,150,apertureSize = 3)