Hello,
i want to write a program which detects the Positon of a Dart on a Dartboard, to cout it automatically. Therefore i need a calibration program, to detect the exact position of the Dartboard. To do so, i want to detect the outer Ellipse, and two Segment Lines which cross in the middle of the Bullseye. Here is the Code i have written so far, with the result with a test picture:
import cv2 #open cv2
import cv2 as cv #open cv
import numpy as np
from threading import Thread
from threading import Event
from im2figure import *
from numpy.linalg import inv
from MathFunctions import *
from Classes import *
from Draw import *
image_proc_img = cv.imread('/Users/johannesbohmer/Documents/5. Semester/Entwicklungsprojekt/Python/Test_2/Bilder/Foto am 09.11.22 um 16.09 (1).jpg')
imCalHSV = cv2.cvtColor(image_proc_img, cv2.COLOR_BGR2HSV)
kernel = np.ones((5, 5), np.float32) / 25
blur = cv2.filter2D(imCalHSV, -1, kernel)
h, s, imCal = cv2.split(blur)
ret, thresh = cv2.threshold(imCal, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
kernel = np.ones((5, 5), np.uint8)
thresh2 = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, kernel)
thresh3 = cv2.Canny(thresh2, 250, 255)
cv2.imshow("thresh2", thresh3)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3,3))
rows = thresh3.shape[0]
circles = cv.HoughCircles(thresh3, cv.HOUGH_GRADIENT, 1, rows / 8,
param1=100, param2=30,
minRadius=300, maxRadius=1000)
if circles is not None:
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
center = (i[0], i[1])
# circle center
cv.circle(image_proc_img, center, 1, (0, 100, 100), 3)
# circle outline
radius = i[2]
cv.circle(image_proc_img, center, radius, (255, 0, 255), 3)
cv.imshow("detected circles", image_proc_img)
cv2.imshow('thresh', thresh)
cv2.imshow('image', image_proc_img)
cv.waitKey(0)