是否可以将OpenCV设置为使用图像的左下角作为原点?在
我正在使用cv2.imshow()在一个窗口中显示一个图像,该窗口允许我单击图像并获取鼠标单击事件的坐标。我可以使用this question的部分答案来显示我想要的图像(在x轴上反转),但是当我单击图像以检索坐标时,原点仍然位于图像的左上角。在import cv2 # Version 3.4.5
import imutils as im
import numpy as np
import matplotlib.pyplot as plt
list_of_coords = []
def store_mouse_coords(event, x, y, flags, params):
global list_of_coords
if event == cv2.EVENT_LBUTTONDOWN:
list_of_coords.append((x, y))
print(list_of_coords[-3:])
return list_of_coords
def select_points_on_im(image, window_name='Select points'):
image = image.copy()
image = image[::-1, :, :]
while True:
cv2.namedWindow(window_name)
cv2.setMouseCallback(window_name, store_mouse_coords)
cv2.imshow(window_name, image)
#plt.imshow(window_name, image, plt.gca()