techfort / pycv

Website of the book "Learn OpenCV 3 with Python"
543 stars 320 forks source link

in chapter 3 the hough-line #5

Open yqtaowhu opened 7 years ago

yqtaowhu commented 7 years ago

this is some wrong with me,i run you code ,but this is not right for you example,have no line int the picture, i do not know what is wrong please tell me ,thank you very much!

techfort commented 7 years ago

hey @yqtaowhu can you elaborate a bit? what appears to be wrong, and in what file?

yqtaowhu commented 7 years ago

@techfort i very happy you can reply me , in the chaper3 ,and Hough_Lines.py to detect a line `import cv2 import numpy as np

img = cv2.imread('lines.jpg') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) edges = cv2.Canny(gray,50,120) minLineLength = 20 maxLineGap = 0 lines = cv2.HoughLinesP(edges,1,np.pi/180,50,minLineLength,maxLineGap) dst = edges for x1,y1,x2,y2 in lines[0]: cv2.line(edges,(x1,y1),(x2,y2),(255,0,0),2)

cv2.imshow("edges", edges) cv2.imshow("lines",img) cv2.waitKey() cv2.destroyAllWindows()` and the result not show a line detect , it is only the origin picture , i dont know why,i have not change your code . Look forward to your reply

Micah2015 commented 6 years ago

I changed lines[0] to follows for line in lines: for x1,y1,x2,y2 in line: cv2.line(img,(x1,y1),(x2,y2),(0,255,0),5)