-
Notifications
You must be signed in to change notification settings - Fork 18
Several improvements - UI, camera, code warnings, refactoring. #4
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
Conversation
216810c to
e506915
Compare
|
@SihabSahariar if you have any comments, please write me and I will fix / add / revert whatever you will ask. |
7ccc312 to
812a754
Compare
1. Refactored the "_read_video_frame()" method to be static to fix a warning, see [2]. 2. Using the class name to access class-level constants. 3. Using module level "dunders" to state the author and additional module information. This is probably a more elegant solution compared to using comments and/or a dedicated "creator()" method (the latter was removed). More info at the "PEP 8 – Style Guide for Python Code", see [1]. 4. Fixed a few additional warnings, see [3], [4] & [5]. 5. Minor "README.md" update. [1] https://peps.python.org/pep-0008/#module-level-dunder-names [2] Method '_read_video_frame' may be 'static' [3] Ui_MainWindow::setupUi() Shadows name 'MainWindow' from outer scope [4] AnalogGaugeWidget::set_MinValue() Shadows built-in name 'min' [5] AnalogGaugeWidget::set_MaxValue() Shadows built-in name 'max' Signed-off-by: Pavel Bar <pbar@redhat.com>
Refactored in "AnalogGaugeWidget" class a few conditional statements using Python's built-in "min()" and "max()" functions with clear comments. The new code is more Pythonic & readable. 1. "rescale_method()" method. 2. "update_value()" method - implemented a classic value "clamping" operation (constraining a value to stay within a min/max range). This is a well-known Python idiom for clamping values. 3. "set_MinValue()" & "set_MinValue()" methods. 4. "set_scala_main_count()" method. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
1. Display error message in the video area in the following cases (runtime error detection during frame reading): a. Camera is unavailable (at initialization or gets disconnected during use). b. Prerecorded video can't be played (file doesn't exist or video stream gets interrupted/corrupted). Created a dedicated "display_error_message()" method to display a visual error message in the exact same location where the video would appear. It uses a black background with a red border to match the UI styling. Shows white text that's bold and centered for clear readability. Maintains the exact same dimensions as the video area (321x331 pixels). The error handling ensures the application won't crash and provides a clear feedback to users about what went wrong, making the dashboard much more user-friendly and robust. 2. Hardware consideration - a more reliable camera detection. Added a small delay (0.1 seconds), to give camera time to initialize properly. Cameras (especially USB cameras) often need a brief moment to become fully operational after a "cv2.VideoCapture()" call. This ensures camera is ready before "view_video()" starts getting called every 20ms, which reduces false negatives where camera exists but isn't ready yet. Documentation was updated accordingly and a screenshot displaying the camera error was added to the "README.md" file. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
In certain cases the main UI window when opened at the small resolution display has some strange black areas at the top and right. When the UI window is repainted by "Qt", the issue is solved: 1. Minimize and maximize. 2. Move the UI window to the large display and then back to the small display. 3. Switch to another application that partially hides the dashboard's window and then switch back. Several root causes related to UI were identified and fixed: 1. Fixed window and content dimension mismatch: the main window is set to 1117x636 pixels, while background label is set to 1111x651 pixels, that's 15 pixels taller than the main window (this caused content to be drawn outside the visible area, creating overflow areas that appeared black). After the fix the background perfectly matches the main window size. To avoid such problem in the future, the magic numbers were refactored into the class-level constants. 2. Added DPI awareness and automatic high DPI scaling support to properly handle different display DPI settings and scaling factors, which caused rendering issues when moving between displays. 3. Added automatic window centering on the primary screen. This ensures consistent positioning regardless of monitor setup. 4. Also disabled the window context help button (the "?" button that appears in window title bars on some platforms). The solution was tested on both small and large displays to ensure black areas are eliminated. Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
|
@barpavel kindly integrate QThread for camera feed. I've added an issue, you can look into it. |
I'll look at it 😃 |
|
I've reviewed. Good work @barpavel |
A visual error message (white bold text, centered, on a black background with a red border) is displayed in the exact same location where the video would appear.
Documentation was updated accordingly and a screenshot displaying the camera error was added to the
README.mdfile.0.1seconds), to give camera time to initialize properly.Cameras (especially USB cameras) often need a brief moment to become fully operational.
The delay reduces false negatives where camera exists but isn't ready yet.
In certain cases the main UI window when opened at the small resolution display has some strange black areas at the top and right (see the below screenshot).
When the UI window is repainted by
Qt, the issue is solved:Several root causes related to UI were identified and fixed:
1,117x636pixels, while background label is set to1,111x651pixels.The solution was tested on both small and large displays to ensure black areas are eliminated.
dundersto state the author and additional module information.More info can be found at the PEP 8 – Style Guide for Python Code manual.
Co-authored-by: Cursor AI
Signed-off-by: Pavel Bar pbar@redhat.com