Skip to content

Refactor main.py and fix .env saving bug#3

Open
google-labs-jules[bot] wants to merge 7 commits intomainfrom
refactor-and-bugfix
Open

Refactor main.py and fix .env saving bug#3
google-labs-jules[bot] wants to merge 7 commits intomainfrom
refactor-and-bugfix

Conversation

@google-labs-jules
Copy link

This change refactors the main application logic for better readability and maintainability and fixes a bug in the web interface related to saving environment variables.

omtoi101 and others added 6 commits August 4, 2025 14:34
- Refactored `main.py` into a class-based structure to improve readability, maintainability, and organization. The monolithic while loop has been broken down into smaller, more manageable methods.
- Encapsulated the application state within the `SecurityCamera` class to eliminate the use of numerous global-like variables.
- Standardized all path construction to use `os.path.join()` for better cross-platform compatibility.
- Fixed a bug in the `/api/save_env` endpoint in `run.py` where it was writing to `bob.txt` instead of the correct `.env` file.
…anges:

- I implemented a threaded frame-reading mechanism to decouple camera I/O from the main processing loop. A dedicated thread now reads frames into a queue, preventing the main loop from blocking and allowing for a higher camera FPS.
- I optimized the detection logic to reduce computational load. Expensive face and body detection algorithms are now run only every N frames, controlled by a `detection_interval` setting in `config.json`.
- I added resizing of frames before running detection to further improve performance.
- The last known detection results are used for frames where detection is skipped, ensuring a smooth visual experience.
- Adds a new 'Web Interface' section to the `README.md`.
- Describes the features of the Dashboard, Settings, and User Management pages.
- Includes placeholders for screenshots to be added later.
- Adds a new 'Web Interface' section to the `README.md`.
- Describes the features of the Dashboard, Settings, and User Management pages.
- Includes placeholders for screenshots to be added later.
- Adds Flask-SQLAlchemy for database management.
- Adds Flask-Login for handling user sessions.
- Adds Flask-Limiter for rate limiting login attempts.
- Adds Werkzeug for password hashing.
@omtoi101 omtoi101 marked this pull request as ready for review August 5, 2025 03:57
- Adds a complete authentication system with a database, password hashing, and a login screen.
- Implements a new admin panel for user management, including creating, editing, and deleting users.
- Integrates the new user management system with the existing face recognition functionality.
- Secures all pages and API endpoints with login and admin-only protection.
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