I've created random points and added a list these points double. Then I've drawn graphic and save as a image.
I'm able to draw a line from one point to another point with this code :
cv2.line(img=result,pt1=,pt2=,color=(0,255,255),thickness=5)
I'have a problem there . If I use plt.show()
for graphic, I have all points coordinates in list. But when I save this graphic as a image and show with cv2 lib, then all points coordinates changes.
- How can I find these points coordinates on image ?
- For exapmle: On this graphic you can see (1,4) point. If I save this graphic as a image then this point gets a (104, 305) coordinates on image.
import numpy as np
import random
import matplotlib.pyplot as plt
import cv2
points = np.random.randint(0, 9, size=(18,2))
print(points)
plt.plot(points[:,0], points[:,1], '.',color='k')
plt.savefig("graphic.png",bbox_inches="tight")
result = cv2.imread("graphic.png")
cv2.imshow("Graphic",result)