- Added max attempts limit to avoid infinite loops which would let the flash on continuously
Additional cleanups:
- Removed redundant frame buffer handling
- Added error handling for semaphore take failure
- Ensured semaphore release on capture failure