I have the following image containing a dartboard

After processing the image looks as follows:

In addition, I have a function that creates a theoretical dartboard:

```
import cv2
import numpy as np
def draw_dartboard():
IMG = np.ones((400, 400), 'uint8') * 255
center = (int(IMG.shape[0] // 2), int(IMG.shape[1] // 2))
size_dartboard = int(340)
r_board = int(170)
r_db = int(6.35)
r_sb = int(15.9)
r_doubles = int(162)
r_triples = int(99)
width_rings = int(8)
cv2.circle(IMG, center, r_doubles + width_rings, (0,0,0), -1)
cv2.circle(IMG, center, r_doubles, (255,255,255), -1)
cv2.circle(IMG, center, r_triples + width_rings, (0,0,0), -1)
cv2.circle(IMG, center, r_triples, (255,255,255), -1)
thetas_min = np.radians([(18 * t - 9) for t in range(20)])
thetas_max = np.radians([(18 * t + 9) for t in range(20)])
for idx, (theta_min, theta_max) in enumerate(zip(thetas_min, thetas_max)):
if (idx % 2) == 0:
x_min = int(center[0] + r_board * np.cos(theta_min))
y_min = int(center[1] + r_board * np.sin(theta_min))
x_max = int(center[0] + r_board * np.cos(theta_max))
y_max = int(center[1] + r_board * np.sin(theta_max))
cv2.fillPoly(IMG, np.array([(center, (x_min,y_min), (x_max,y_max))]), (0,0,0))
cv2.circle(IMG, center, r_sb, (0,0,0), -1)
return IMG
```

The output of this image looks as follows:

How can I “fit” the theoretical dartboard in the real image? Clearly, there is a mismatch in orientation and scale. What’s the best way to do this?

5

Since the real image orientation and perspective is different, you need to warp its perspective. wapPerspectie function can be used to do it, and you may use minAreaRect to get the inmput parameters for waprPerspective

related: forum.opencv.org/t/…

Can you post the code you used to process the image?

And please post the raw image you used to process.

Finally, can you post the processed image directly, by first using

`cv2.imwrite("processed.png", processed_img)`

, and uploading the output?