Skip to content

Add default camera listing and selection - #1

Draft
seanfight wants to merge 1 commit into
masterfrom
cursor/default-camera-0a83
Draft

Add default camera listing and selection#1
seanfight wants to merge 1 commit into
masterfrom
cursor/default-camera-0a83

Conversation

@seanfight

Copy link
Copy Markdown
Owner

Describe your change:

Add computer_vision/default_camera.py so a computer’s cameras can be listed, a preferred camera can be saved, and (optionally) an OS-level default can be applied.

Windows and Linux do not expose a single global “default camera” API. Apps typically open the first available capture device. This utility:

  1. Discovers cameras (Windows PnP, Linux V4L2, macOS system_profiler, OpenCV fallback)
  2. Selects one by index, name fragment, or device path
  3. Saves the choice to a JSON preference file
  4. With --system, applies an OS-level default:
    • Windows: enable the chosen camera and disable the others (run as Administrator)
    • Linux: write a udev rule and ~/.config/video-default symlink
    • macOS: preference only (no system-wide API)

Usage:

python computer_vision/default_camera.py list
python computer_vision/default_camera.py set 1
python computer_vision/default_camera.py set "usb" --system
python computer_vision/default_camera.py get

使用方法(中文):

python computer_vision/default_camera.py list          # 列出摄像头
python computer_vision/default_camera.py set 1         # 把 1 号设为默认
python computer_vision/default_camera.py set "usb" --system  # 设为系统默认(Windows 需管理员)
python computer_vision/default_camera.py get           # 查看当前默认
  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.
Open in Web Open in Cursor 

Provide a computer-vision utility that discovers capture devices, saves a preferred camera, and can apply an OS-level default by disabling other Windows cameras or creating a Linux video-default symlink.

Co-authored-by: huiyuan.dong <huiyuan.dong@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants