Devlog 2
Added Scrolling Functionality
Today I mapped the scroll wheel with pyautogui to scroll as I move my hand up or down while keeping my finger and thumb in contact.
To do so I calculated the mid point between my thumb and finger. This point acts as the main point whose position is considered for scrolling. You can see it in the video as well, it turns red when my fingers come in contact
Next to actually scroll I use the following code ->
diff = ti_mid[1]-prev_ti_midpt_y
if abs(diff) > small_movement:
pyautogui.scroll(int(diff*sensitivity))
prev_ti_midpt_y = ti_mid[1]
Here I Compare the position of the mid pt in each iteration, calculate the difference and multiply with a constant which acts a sensitivity. Finally we use pyautogui to scroll it by that amount. Also if the magnitude of diff is too small (ie. less than small_movement variable) then the movement is not considered.
I also defined these variables at the top for easier configurations
sensitivity = 4
small_movement = 5
tap_threshold = 0.3
hand_detection_confidence=0.2
tracking_confidence=0.1
scroll_mode = True
Tap threshhold here is how close the fingers have to be to consider them in contact
Further Plans
Next I will be adding the mouse movement. I tried to implement that today but its gonna take more time so I’ll continue it in the next session. For that reason only I also added the variable, scroll_mode
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.