Barium icon indicating copy to clipboard operation
Barium copied to clipboard

Feature: Synchronize Mouse Movements Captured by Camera with On-Screen Cursor Movement

Open KitsuneSemCalda opened this issue 9 months ago • 0 comments

Implement a system that captures the small movements of a user's hand or face via a webcam and translates these movements to control the cursor on a computer screen. This requires interpolating the smaller, captured movements to a larger scale suitable for screen coordinates.

Like:

def map_coordinates(x, y, src_width, src_height, dst_width, dst_height):
    """
    Map coordinates from source dimensions to destination dimensions.
    
    :param x: X coordinate in source
    :param y: Y coordinate in source
    :param src_width: Width of source
    :param src_height: Height of source
    :param dst_width: Width of destination
    :param dst_height: Height of destination
    :return: (new_x, new_y) in destination
    """
    new_x = int((x / src_width) * dst_width)
    new_y = int((y / src_height) * dst_height)
    return new_x, new_y

KitsuneSemCalda avatar May 26 '24 10:05 KitsuneSemCalda