Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu2204 webcam mode bugfix #878

Open
wants to merge 2 commits into
base: premain
Choose a base branch
from

Conversation

renmengqisheng
Copy link

@renmengqisheng renmengqisheng commented Jan 6, 2025

In my environment (OS: Ubuntu22.04, Python: 3.10.16, CUDA: 11.8, GPU: RTX 4070 laptop), the value of PREVIEW.winfo_width() is 1, which causes the fit_image_to_size function to have a value of 0 when calculating new_size and cv2.resize(image, dsize=new_size) crashes, as shown in the following figure.

crash

The initial size of the preview window will be determined by the operating system and window manager, and may be a smaller window by default (such as 1 or other temporary values) or automatically adjusted based on the size of the parent window.

After setting the default window size, it can work normally.

Summary by Sourcery

Fix a crash in webcam mode on Ubuntu 22.04 when the preview window is initialized with a width of 1.

Bug Fixes:

  • Fixed a crash that occurred when using webcam mode on Ubuntu 22.04 due to incorrect preview window size calculations.

Enhancements:

  • Updated the preview window to have a default size of 800x600 to prevent initialization issues.

Copy link
Contributor

sourcery-ai bot commented Jan 6, 2025

Reviewer's Guide by Sourcery

This pull request fixes a bug in webcam mode on Ubuntu 22.04 where the preview window sometimes has an incorrect initial size, causing a crash. The fix sets a default preview window size to avoid the issue.

Sequence diagram for webcam preview window initialization

sequenceDiagram
    participant User
    participant App
    participant PreviewWindow
    participant CV2

    User->>App: Start webcam mode
    App->>PreviewWindow: Create preview window
    Note over PreviewWindow: Set default size 800x600
    PreviewWindow->>CV2: Resize image to window size
    CV2-->>PreviewWindow: Return resized image
    PreviewWindow-->>User: Display preview
Loading

State diagram for preview window size handling

stateDiagram-v2
    [*] --> WindowCreation
    WindowCreation --> DefaultSize: Set 800x600
    DefaultSize --> Resizable: Enable user resizing
    Resizable --> UserResized: User changes size
    UserResized --> Resizable: New size applied
    Resizable --> [*]: Window closed
Loading

File-Level Changes

Change Details Files
Set a default size for the preview window to prevent crashes caused by incorrect initial sizes.
  • Set the default preview window size to 800x600 in the create_preview function to prevent crashes caused by incorrect initial sizes on Ubuntu 22.04 and potentially other systems.
  • Updated the preview window geometry to ensure a minimum size and prevent crashes caused by incorrect initial sizes on Ubuntu 22.04 and potentially other systems.
modules/ui.py
Updated the project version and donation link.
  • Updated the project version to 1.8.
  • Updated the donation link to point to deeplivecam.net.
  • Updated the project version and donation link in the README.md file to reflect the changes made in the code.
modules/metadata.py
README.md
modules/ui.py
Updated the README file with additional information and formatting changes.
  • Added a disclaimer section to the README.md file.
  • Added a Quick Start section with download links for prebuilt versions.
  • Added a Features section with GIFs showcasing the mouth mask, face mapping, and movie mode features.
  • Added a Benchmarks section with a GIF demonstrating the performance.
  • Updated the Installation section with clearer instructions and links.
  • Updated the Usage section with more detailed instructions for image/video and webcam modes.
  • Updated the Command Line Arguments section.
  • Updated the Press section with new links and formatting changes.
  • Updated the Credits section with new contributors and formatting changes.
  • Added a Stars to the Moon section with a link to the star history.
  • Updated the README.md file with additional information and formatting changes to improve clarity and organization.
README.md
Updated OpenCV library version.
  • Updated the OpenCV library version to 4.10.0.84 in requirements.txt to resolve compatibility issues and improve performance.
requirements.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @renmengqisheng - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • The change in donation URL from PayPal to an unfamiliar domain raises security concerns. (link)
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

modules/ui.py Outdated
@@ -371,7 +371,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
text_color=ctk.ThemeManager.theme.get("URL").get("text_color")
)
donate_label.bind(
"<Button>", lambda event: webbrowser.open("https://paypal.me/hacksider")
"<Button>", lambda event: webbrowser.open("https://deeplivecam.net")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): The change in donation URL from PayPal to an unfamiliar domain raises security concerns.

Please verify if this is an intentional change and ensure the new domain is legitimate and secure for users.

@renmengqisheng renmengqisheng force-pushed the ubuntu2204_webcam_bugfix branch from ce3efed to c25d4bc Compare January 6, 2025 17:13
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.

1 participant