Skip to content

Instantly share code, notes, and snippets.

@prateekjoshi565
Created May 11, 2020 11:03
Show Gist options
  • Save prateekjoshi565/7206ae1310b234f40504290d2be547db to your computer and use it in GitHub Desktop.
Save prateekjoshi565/7206ae1310b234f40504290d2be547db to your computer and use it in GitHub Desktop.
cnt = 0
for img in tqdm_notebook(col_images):
# apply frame mask
masked = cv2.bitwise_and(img[:,:,0], img[:,:,0], mask=stencil)
# apply image thresholding
ret, thresh = cv2.threshold(masked, 130, 145, cv2.THRESH_BINARY)
# apply Hough Line Transformation
lines = cv2.HoughLinesP(thresh, 1, np.pi/180, 30, maxLineGap=200)
dmy = img.copy()
# Plot detected lines
try:
for line in lines:
x1, y1, x2, y2 = line[0]
cv2.line(dmy, (x1, y1), (x2, y2), (255, 0, 0), 3)
cv2.imwrite('detected/'+str(cnt)+'.png',dmy)
except TypeError:
cv2.imwrite('detected/'+str(cnt)+'.png',img)
cnt+= 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment