Skip to content

Instantly share code, notes, and snippets.

@jayrambhia
Created August 3, 2012 15:15
Show Gist options
  • Save jayrambhia/3248551 to your computer and use it in GitHub Desktop.
Save jayrambhia/3248551 to your computer and use it in GitHub Desktop.
Hough Lines test
from SimpleCV import *
import time, cv2
import cv2.cv as cv
i = Image("Python/SimpleCV/line1.jpg")
g = i.getGrayNumpyCv2()
em = cv2.Canny(g, 70, 100)
l = cv2.HoughLines(em, 1.0, cv.CV_PI/180.0, 100)
print l.shape
l = l[0]
linesFS = FeatureSet()
for pt in l:
rho = pt[0]
theta = pt[1]
a = cos(theta)
b = sin(theta)
x0 = a*rho
y0 = b*rho
p1 = array([int(x0+1000*(-b)), (int(y0 + 1000*a))])
p2 = array([int(x0-1000*(-b)), (int(y0 - 1000*a))])
linesFS.append(Line(i, (p1, p2)))
linesFS.draw()
i.show()
time.sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment