hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
35.19k stars 4.98k forks source link

multi camera device support #556

Closed Highpressure closed 1 week ago

Highpressure commented 1 week ago

added scanning function for multi camera device support to caputrer.py and a dropdown to select the camera in ui.py did not add additional libraries to support camera name detection as this is only supported on windows

Summary by Sourcery

Add support for multi-camera devices by implementing a function to list available cameras and integrating a dropdown menu in the UI for camera selection. Update the webcam preview functionality to utilize the selected camera index.

New Features:

Enhancements:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request adds support for multiple camera devices by implementing a scanning function to detect available cameras and adding a dropdown menu in the UI to select the desired camera. The changes primarily affect the ui.py and capturer.py files, introducing new functionality without adding additional libraries for camera name detection.

File-Level Changes

Change Details Files
Implemented a function to list available cameras
  • Added a new function 'list_available_cameras' to scan for connected camera devices
  • The function tests up to 10 camera indices by default
  • Returns a list of available camera indices
modules/ui.py
modules/capturer.py
Added a dropdown menu for camera selection in the UI
  • Created a dropdown menu to display available cameras
  • Set the default selection to the first available camera
  • Added a fallback label if no cameras are found
modules/ui.py
Modified the webcam preview function to use the selected camera
  • Updated 'webcam_preview' function to accept a camera index parameter
  • Changed the camera initialization to use the selected index from the dropdown
modules/ui.py
Updated the video frame capture function to support both camera and video file inputs
  • Modified 'get_video_frame' function to handle both camera and video file sources
  • Added a flag to distinguish between camera and video file inputs
  • Adjusted frame positioning logic to only apply to video files
modules/capturer.py
Removed several UI elements to make room for the new camera selection feature
  • Removed checkboxes and switches for various options (e.g., keep fps, keep frames, face enhancer)
  • Adjusted the layout of remaining UI elements
modules/ui.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
Highpressure commented 1 week ago

committed the wrong file - now the switches are back

hacksider commented 20 hours ago

@Highpressure would like to ask if you can do a recommit on this on the updated main. Just having some issues refactoring with lots of changes that happened. Appreciate the help bro :)