Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@bohdan.inhliziian . I am not candidate to answer under moderator berak.

#!usr/bin/env python
#OpenCV 4.0
#using rapberry pi 3, linux, kernel 4.14.76

import cv2
import numpy as np

img = cv2.imread('image1.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 150, apertureSize=3)

minLineLength =2
maxLineGap = 4
lines = cv2.HoughLinesP(edges, 1, np.pi / 180, 350, minLineLength, maxLineGap, 10)
for line in lines:
    for x1, y1, x2, y2 in line:
        cv2.line(img, (x1, y1), (x2, y2), (0, 255, 0), 2)

cv2.imwrite('houghlines5.jpg', img)
cv2.imshow("image", edges)
cv2.imshow('img', img)
cv2.waitKey(0)

image description