我想使用 OpenCV 和 python 反转我的鼠标移动
I want to invert my mouse movement using OpenCV and python
当我将指针向左移动时,鼠标向右移动,向右移动时鼠标向左移动...
我希望我的鼠标移动与我移动指针完全相同..
我的屏幕尺寸是 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)
如果只是 X 轴倒置,你可以试试这个 -
mouse.position=(1440-(1440-(int(x)*1440)/1440),900-(int(y)*900)/900)
如果 X 轴和 Y 轴都反转 -
mouse.position=(1440-(1440-(int(x)*1440)/1440),900-(900-(int(y)*900)/900))
当我将指针向左移动时,鼠标向右移动,向右移动时鼠标向左移动... 我希望我的鼠标移动与我移动指针完全相同..
我的屏幕尺寸是 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)
如果只是 X 轴倒置,你可以试试这个 -
mouse.position=(1440-(1440-(int(x)*1440)/1440),900-(int(y)*900)/900)
如果 X 轴和 Y 轴都反转 -
mouse.position=(1440-(1440-(int(x)*1440)/1440),900-(900-(int(y)*900)/900))