Когда я загружаю изображение 3840x2160 с кодом ниже:
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import matplotlib.image as image
import matplotlib.patches as patches
class SnaptoCursor(object):
def __init__(self, ax):
self.ax = ax
self.lx = ax.axhline(color='r') # the horiz line
self.ly = ax.axvline(color='r') # the vert line
self.x = 0
self.y = 0
def mouse_move(self, event):
if not event.inaxes:
return
x, y = event.xdata, event.ydata
# update the line positions
self.lx.set_ydata(y)
self.ly.set_xdata(x)
self.ax.figure.canvas.draw()
img = image.imread("exam.jpg") #3840x2160
fig,ax =plt.subplots(1)
ax.imshow(img)
snap_cursor = SnaptoCursor(ax)
fig.canvas.mpl_connect('motion_notify_event', snap_cursor.mouse_move)
plt.show()
Когда я двигаю мышь, я вижу, что длинный перекрестный курсор (две линии на самом деле) движется очень медленно. sh он сразу же перемещается курсором.
Добро пожаловать, если есть какое-либо иное хорошее решение!