FaceRec icon indicating copy to clipboard operation
FaceRec copied to clipboard

Updated FaceRec/app/main/Edit.py

Open bhavya2021245 opened this issue 2 years ago • 3 comments

Description

Improper Resource Management: The camera resource (cv2.VideoCapture(0)) is now properly initialized and released to prevent the camera from being locked after the application stops. Functions for initializing and releasing the camera are added to ensure correct handling.

Lack of Comprehensive Error Handling and Input Validation: Input validation is implemented for the form data, ensuring that invalid or malicious inputs are not processed. Error handling has been added for camera access, file operations, and HTTP requests to avoid crashes and provide meaningful feedback to the user.

Avoidance of Global Variables Leading to Potential Race Conditions: Global variables are replaced by Flask’s g object to store request-specific data. This refactoring prevents race conditions and ensures data integrity across concurrent requests.

Fixes # (issue 73)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Test A: Tested video feed functionality to ensure the camera resource is properly managed and released. Test B: Validated input for the form on the /capture route with valid and invalid inputs, ensuring proper error handling. Test C: Simulated concurrent requests to check for race conditions and verify data consistency when using the Flask g object.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

bhavya2021245 avatar Oct 13 '24 08:10 bhavya2021245

Author's GitHub stats

Devasy avatar Oct 13 '24 13:10 Devasy

📊 Contributor Stats for @bhavya2021245:

  • Total PRs Merged: 18
    • Recent Contributions (last 10 PRs):
  • Lines Added: 43209
  • Lines Deleted: 5506 Keep up the great work! 🚀

Devasy avatar Oct 13 '24 13:10 Devasy

Hello @bhavya2021245 , I appreciate your efforts towards our project, we'll shortly review your PR It would be really helpful if you include screenshots of your changes.

@puwun please look into it

Devasy avatar Oct 15 '24 17:10 Devasy