-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces headless mode functionality to the application,
enhancing its flexibility, robustness, and compatibility with various environments, including development containers and Docker containers. Key Changes: 1. **Added headless mode argument**: - Introduced a `--headless` argument in the main function. This allows the application to run in headless mode, which is particularly useful in environments without a display or graphical interface. 2. **Environment Check for Display**: - Implemented `is_display_available()` to check if a display environment is available (i.e., checking the `DISPLAY` environment variable). This ensures that the application can intelligently default to headless mode when necessary. 3. **Conditional Display Rendering**: - Modified the main loop to conditionally display the video feed using `cv2.imshow` only when not in headless mode. This change prevents the application from attempting to render visuals when no display is available or when running in headless mode. 4. **Error Handling for Display Issues**: - Added a try-except block around `cv2.imshow` to gracefully handle scenarios where displaying the image is not possible. If an exception is thrown due to display issues, the application will switch to headless mode, ensuring continuous operation without manual intervention. 5. **Dynamic Adjustment to Headless Mode**: - The application now dynamically adjusts to headless mode if it detects that no display is available or if it encounters an error while attempting to show the image. This dynamic adjustment enhances the application's resilience and usability across different environments. 6. **Enhanced Container Compatibility**: - With the addition of headless mode, the application can now be run in both devcontainers and Docker containers without requiring a graphical user interface. This enables seamless operation in headless mode for various development, testing, and production scenarios, especially in containerized environments. This update significantly increases the application's deployment flexibility, allowing it to run seamlessly in various environments, from development machines with full graphical support to servers and containers where a graphical interface might not be available. Testing Done: * Added tests for ensuring headless mode is set and verified that it works * Ran the program manually in devcontainer and ensured that it worked.
- Loading branch information
Mr. ChatGPT
committed
Dec 30, 2023
1 parent
6fd3df5
commit f97cd44
Showing
3 changed files
with
148 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters