how to find corner (x, y) opencv?

75 views Asked by At

I have a picture of a pool game where I want to get the marked points from the picture (ball pocket) Meanwhile, the background of the images may be different How to get the coordinates of the table?

Exactly like the image below the orange line:

enter image description here

import cv2 as cv
import numpy as np
img = cv.imread(cv.samples.findFile('1.png',))

gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
edges = cv.Canny(gray,100,150,apertureSize = 3)
Canny = cv.Canny(img,200,200)
lines = cv.HoughLinesP(edges,1,np.pi/450,500,minLineLength=70, maxLineGap=70)


for line in lines:
    x1,y1,x2,y2 = line[0]
    cv.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv.imshow('1', img)
cv.waitKey()
0

There are 0 answers