saki4510t / UVCCamera

library and sample to access to UVC web camera on non-rooted Android device
2.99k stars 1.2k forks source link

how can i preview fast? #494

Open 0x7962 opened 5 years ago

0x7962 commented 5 years ago

hi, saki.

Is very slow(low fps) when i preview my USB camera with resolution 4196x3104, but i use other app is ok. like this one https://play.google.com/store/apps/details?id=com.shenyaocn.android.usbcamera (this app also use your lib) or on the windows/Mac use same camera.

My cam data is MJPEG, i tried to modify here :

diff --git a/libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp b/libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp
index 02c1a60..16f9e18 100644
--- a/libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp
+++ b/libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp
@@ -530,7 +530,7 @@ void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) {
                                frame_mjpeg = waitPreviewFrame();
                                if (LIKELY(frame_mjpeg)) {
                                        frame = get_frame(frame_mjpeg->width * frame_mjpeg->height * 2);
-                                       result = uvc_mjpeg2yuyv(frame_mjpeg, frame);   // MJPEG => yuyv
+                                       result = uvc_mjpeg2rgbx(frame_mjpeg, frame);   // MJPEG => yuyv
                                        recycle_frame(frame_mjpeg);
                                        if (LIKELY(!result)) {
                                                frame = draw_preview_one(frame, &mPreviewWindow, uvc_any2rgbx, 4);

but just a little improvement and the preview sometimes flicker.

zipswich commented 2 years ago

@0x7962 Have you solved the problem? I am facing a similar issue.