1 | initial version |
Here is code:
#!usr/bin/env python3.5
#OpenCV 4.1.0
#using rapberry pi 3, linux, kernel 4.19.34
#Date: 18th April, 2019
import cv2
import numpy as np
img = cv2.imread('hexagon.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 150, apertureSize=3)
minLineLength = 12
maxLineGap = 8
lines = cv2.HoughLinesP(edges, 1, np.pi / 180, 5, minLineLength, maxLineGap, 25)
for line in lines:
for x1, y1, x2, y2 in line:
cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.imshow("image", edges)
cv2.imshow('img', img)
cv2.waitKey(0)
Output: