【发布时间】:2023-03-08 13:30:01
【问题描述】:
当我向左移动指针时,鼠标向右移动,向右移动时,它向左移动... 我希望我的鼠标移动与移动指针完全相同..
我的屏幕尺寸是 1440*900
if len(cnts) > 0:
c = max(cnts, key=cv2.contourArea) #Finding the largest contour in the mask
((x, y), radius) = cv2.minEnclosingCircle(c) #Finding the minimum enclosing circle
M = cv2.moments(c) #Calculating image moment(center of mass)
center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])) #Centroid of the minimum enclosing circle
bint = int(cv2.contourArea(c))
if radius > 5:
cv2.circle(frame, (int(x), int(y)), int(radius),(255,255,255), 2) #Drawing a circle of thickness 2
cv2.circle(frame, center, 5, (226, 43, 138), -1) #Drawing centroid on the frame
mouse.release(Button.left)
mouse.position=(1440-(int(x)*1440)/1440,900-(int(y)*900)/900)
【问题讨论】:
标签: python opencv web mouseevent virtual