Closed mobileteamdct closed 6 months ago
Hello! It sounds like you're facing performance issues with camera frames, especially on lower-end devices. While Ultralytics primarily focuses on models and algorithms, integrating with a Flutter plugin for smoother camera frames is certainly worth exploring. Flutter's efficient rendering might help reduce the workload on your main thread.
For the "Skipped 50 frames" issue, consider optimizing your application's workload. Here are a few tips:
These adjustments can help you achieve smoother frame processing. If you're integrating with a Flutter plugin, make sure the heavy lifting doesn't happen on the main thread. For more detailed guidance on optimizing your process, you might want to explore our documentation at https://docs.ultralytics.com.
Happy coding! 😊
now i have changed the predict() to be be happen in seperate thread. (CameraPreview.java file)
private void bindPreview(int facing) { if (!busy) { busy = true; Preview cameraPreview = new Preview.Builder() .setTargetAspectRatio(AspectRatio.RATIO_4_3) .build(); CameraSelector cameraSelector = new CameraSelector.Builder() .requireLensFacing(facing) .build(); ImageAnalysis imageAnalysis = new ImageAnalysis.Builder() .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST) .setTargetAspectRatio(AspectRatio.RATIO_4_3) .build(); imageAnalysis.setAnalyzer(ContextCompat.getMainExecutor(context), new ImageAnalysis.Analyzer() { @Override public void analyze(@NonNull ImageProxy imageProxy) { Runnable predictorRunnable = new Runnable() { @Override public void run() { predictor.predict(imageProxy, facing == CameraSelector.LENS_FACING_FRONT); imageProxy.close(); } }; // Execute the predictor in a separate thread new Thread(predictorRunnable).start(); } }); // Unbind use cases before rebinding cameraProvider.unbindAll(); // Bind use cases to camera Camera camera = cameraProvider.bindToLifecycle((LifecycleOwner) activity, cameraSelector, cameraPreview, imageAnalysis); cameraControl = camera.getCameraControl(); cameraPreview.setSurfaceProvider(mPreviewView.getSurfaceProvider()); busy = false; } }
now i get smoother frame processing.
for further improvement can I send **CameraImage (from flutter camera)** bytes to image processing instead of **Native Imageproxy** is it possile??
@mobileteamdct thanks for your contribution! Looks good, can you submit a PR?
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.
For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLO 🚀 and Vision AI ⭐
While in the application camera frames getting strucked getting delay in the frames . Can we use camera of flutter plugin to make smooth frames??
in some low end devices camera frame not even loading it showing message in log Skipped 50 frames! The application may be doing too much work on its main thread.