我想使用OpenCV和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)
a4870126sdo 回答:我想使用OpenCV和python反转鼠标移动

如果仅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))
本文链接:https://www.f2er.com/3060360.html

大家都在问