Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalizing Hough lines tutorial #228

Open
jwhendy opened this issue Feb 5, 2020 · 0 comments
Open

Generalizing Hough lines tutorial #228

jwhendy opened this issue Feb 5, 2020 · 0 comments

Comments

@jwhendy
Copy link

jwhendy commented Feb 5, 2020

I'm fairly new to opencv and am finding documentation/tutorials pretty brutal. There is an immense amount of "magic incantation" unexplained code out there.

Here is the example from the Hough lines tutorial:

lines = cv2.HoughLines(edges,1,np.pi/180,200)
for rho,theta in lines[0]:
    a = np.cos(theta)
    b = np.sin(theta)
    x0 = a*rho
    y0 = b*rho
    x1 = int(x0 + 1000*(-b))
    y1 = int(y0 + 1000*(a))
    x2 = int(x0 - 1000*(-b))
    y2 = int(y0 - 1000*(a))

    cv2.line(img,(x1,y1),(x2,y2),(0,0,255),2)

image

  • why lines[0]? It would appear this plots one line, but the soduku puzzle is all marked up
  • Expanding out, x1 = (cos(theta)*rho) - (1000*sin(theta)*rho). Where is 1000 coming from?
  • what is the unit of the threshold? I'm assuming pixels?
  • the line color is (0, 0, 255), but red is shown on the example

Some of these probably seem like nitpicks, but for someone who is pretty new and the fact that these tutorials rank high on google, it would seem advantageous to have things match up and not be confusing.

If someone could expand on some of the questions, I'd be happy to update the tutorial. I'm guessing this should be for line in lines, for rho,theta in line: and that the 1000 should match the output of img.shape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant