saki4510t / UVCCamera

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

YUV420 not supported #345

Open Harishvats opened 6 years ago

Harishvats commented 6 years ago

I have a custom UVC camera which gives video in YUV420 format. I get no preview in this case. It gives error "could not negotiate with camera errpor=-51" . What can be done to support this format also?

heinrichu commented 6 years ago

Hello,

the error could also be caused by other reasons. At first you need to set set the correct frame dimensions, (maximum) frame rate, preview mode (here probably to 0 for YUV), etc. The default dimension is VGA(640x480). If you cam does not provide this, a preview will not be possible. (have alook into UVCCamera.java: setPreviewSize and the defined constants at the beginning of the code file)

I also use a custom camera and i was finally able to fix my problems by selecting the appropriate parameters.

If your camera also uses a special color format, you could try to edit the native code (which i did). Try to find the function in native code file void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) and adapt conversion function for your camera's format. The c-file frame.c (libuvc.h) offers many different functions handling many color formats.

Greetings

heaveninfosoft commented 4 years ago

Hello,

the error could also be caused by other reasons. At first you need to set set the correct frame dimensions, (maximum) frame rate, preview mode (here probably to 0 for YUV), etc. The default dimension is VGA(640x480). If you cam does not provide this, a preview will not be possible. (have alook into UVCCamera.java: setPreviewSize and the defined constants at the beginning of the code file)

I also use a custom camera and i was finally able to fix my problems by selecting the appropriate parameters.

If your camera also uses a special color format, you could try to edit the native code (which i did). Try to find the function in native code file void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) and adapt conversion function for your camera's format. The c-file frame.c (libuvc.h) offers many different functions handling many color formats.

Greetings

hey i got
E/libUVCCamera: [3386*UVCPreview.cpp:507:prepare_preview]:could not negotiate with camera:err=-51

can you help me??

B3rn4rdDL commented 2 years ago

Hey, I got the same error, did you succeed with your custom camera ? Mine gives video in YUV422 format and I can't get a preview due to this error : E/libUVCCamera: [3386*UVCPreview.cpp:517:prepare_preview]:could not negotiate with camera:err=-51