Quyền Phạm Danh
Quyền Phạm Danh

Reputation: 29

Flutter Camera is lagging while stream image

Have you used CameraController's startImageStream() yet? Can you give me some experience? I need to process the frame right while recording the video and then send the frame to the server. I have put everything into Isolate for processing but the camera is still lagging, and on some weak devices, the app even crashes. I have researched but there is no improvement.

My code:

await cameraCtrl?.startVideoRecording(
          onAvailable: (image) async {
            if (isRecording.isTrue && totalFrames % 6 == 0) {
              await processCameraFrame(image);
            }
            totalFrames++;
          },
        );
Future<void> processCameraFrame(CameraImage cameraImage) async {
    final isolateModel = IsolateModel(
      cameraImage: cameraImage,
    );
    ReceivePort sendDataResPort = ReceivePort();
    _isolateHelper.sendPort
        .send(isolateModel..sendDataPort = sendDataResPort.sendPort);
    final data = await sendDataResPort.first;
    if (data is String) {
      if (isRecording.isTrue) {
        // Send data to Server via web socket
      }
    }

I hope you guys can advise me on your experience or give me key words to research. Thank you.

Upvotes: 1

Views: 111

Answers (0)

Related Questions