sendFrames method
override
Reads a frame from the camera and sends it to the dashboard.
When overriding this function, be sure to check for errors, such as:
- If the camera does not respond, alert the dashboard
- If the frame is too large, reduces the quality (increases JPG compression)
- If the quality is already low, alert the dashboard
Implementation
@override
Future<void> sendFrames() async {
if (camera == null) return;
final (success, matrix) = camera!.read();
if (!success) return;
// detectAndAnnotateFrames(matrix);
final frame = matrix.encodeJpg(quality: details.quality);
matrix.dispose();
if (frame == null) { // Error getting the frame
sendLog(LogLevel.warning, "Camera $name didn't respond");
updateDetails(CameraDetails(status: CameraStatus.CAMERA_NOT_RESPONDING));
return;
}
sendFrame(frame);
fpsCount++;
}