quantum6 / Android-USB-OTG-Camera

Apache License 2.0
120 stars 37 forks source link

Camera Preview #20

Open super0610 opened 1 year ago

super0610 commented 1 year ago

In specific Android, camera preview is green. Can you guide me how to solve this? image_2023_07_31T19_32_28_541Z

super0610 commented 1 year ago

I tested with several phones, Galaxy S8, Pixel 3, S21, preview works with these phones. But when I try with Doogee S51 phone, preview is green colored.

https://www.doogee.cc/s51/specs.html

https://play.google.com/store/apps/details?id=net.usb.usby4 This app works with S51 doogee phone.

Hope your reply asap, thanks.

quantum6 commented 1 year ago

Is the preview OK?

super0610 commented 1 year ago

The preview from this repo is like the above screenshot that I need to solve. But the Endoscope app from google play is okay (Preview is okay) Thanks for the reply, Hope you can guide me.

quantum6 commented 1 year ago

1, Save a video and send to me: quantum6@yeah.net 2, Try this: https://github.com/quantum6/Android-UVC-Camera-Bulk-Transfer

super0610 commented 1 year ago

Hi @quantum6 I've sent email with video attached. Hope you can check and help me how to fix it. Thanks.

quantum6 commented 1 year ago

1, When you move camera, is video frame changed? 2, Point to a obj, create 3 files: video, take photo, use a phone take photo.

super0610 commented 1 year ago

Hi @quantum6 I tried to take picture and record video , but it didn't work, file size is 0B. Anyway, I attached preview screen with camera movement, as you can see preview is changed,

https://github.com/jiangdongguo/AndroidUSBCamera I tried to debug with this repo(built in my side, and put debug code in native library), UVCPreview.cpp.

But the preview data is almost 0x00, also preview data is rarely updated (maybe fps is less than 1), for working phone, preview frame data is updated very fast.

Can you know the reason?

https://github.com/quantum6/Android-USB-OTG-Camera/assets/44995535/146b4b25-a3eb-4c18-9ab0-5f09e587e49d

super0610 commented 1 year ago

hi @quantum6 , when I debug with above repo, the preview frame data size is different with working phone. for same resolution (640 x 480)

super0610 commented 1 year ago

Hi @quantum6 , any suggestion?

quantum6 commented 1 year ago

I tried and record video OK. So you should: Is the app has permission? Is the save path right? If you can save and upload the video, I can check the format.

super0610 commented 1 year ago

Hi @quantum6 Please check videos, hope you can find reason. image1 image2

As you can see from the image, frame byte is different with working phone (it is 614400)

Also, fps is 1 from video.

https://github.com/quantum6/Android-USB-OTG-Camera/assets/44995535/09fe3026-038a-464d-8b1b-239e54164cc8

m6/Android-USB-OTG-Camera/assets/44995535/44b10844-08d8-4a9c-afd4-9acb93a8887a

https://github.com/quantum6/Android-USB-OTG-Camera/assets/44995535/8b74042e-c5a4-4453-9960-720a8731c8b5

quantum6 commented 1 year ago

It's seems easy to fix. I add a "Record YUV" menu on this repo:

https://github.com/quantum6/Quantum6-Android-USB-OTG-Camera

Use "Record YUV" and upload the file(like 123785-640x480.yuv). I will check it.

super0610 commented 1 year ago

case R.id.menu_recording_yuv: if (mCameraHelper == null || !mCameraHelper.isCameraOpened()) { showShortMsg("sorry,camera open failed"); return super.onOptionsItemSelected(item); } if (isRecordYuv) { isRecordYuv = false; FileUtils.releaseFile(); showShortMsg("stop record..."); } else { isRecordYuv = true; FileUtils.createFile(getRecordFileName()); showShortMsg("start record..."); } break;

            what this code will do? anyway I tried to build your project (Q6 app), but file size is 0B

just clicked "Recording YUV" to start record, and clicked again to stop.

quantum6 commented 1 year ago

The code save yuv format to fille. And I tested again it work well. You can click recodr to comfirm. And I upload my apk, you can try it. Good luck!

super0610 commented 1 year ago

Where is apk to try? I built app in my side and tried yuv record, however video file size is 0. (mine is Samsung Galaxy S8, preview works) But with Doogee phone, preview didn't work, almost green like before. I think, *.so files needs to be updated?

quantum6 commented 1 year ago

https://github.com/quantum6/Quantum6-Android-USB-OTG-Camera/tree/main/OTGCamera/release

quantum6 commented 1 year ago

1, Do you open the repo? 2, Is the apk size OK? 3, When Record(not Record YUV), the file is OK?

super0610 commented 1 year ago

Screenshot_39 Hi, as you can see from my screen, all file size is 0B I downloaded your apk and tried both yuv, and recording. my phone is samsung galaxy s8 (android 9) Thanks.

quantum6 commented 1 year ago

Did you plug the camera?

super0610 commented 1 year ago

Sure, I did.

quantum6 commented 1 year ago

1, the mp4 you upload, use which apk? 2, what the info on screen? 3, try other phone.

super0610 commented 1 year ago

https://github.com/jiangdongguo/AndroidUSBCamera

I've built apk from this repo and above videos are from this apk. I think, you are using same .so files? Camera preview are green in both apks, so I think it can't be fixed if .so files are not modified. Can't use other phone, only apk is not working with Doogee phone. Thanks.

super0610 commented 1 year ago

do you know why fps is 1? actually one frame every few seconds, so actually fps is less than 1.

super0610 commented 1 year ago

Hi @quantum6 I tried to make some log with AndroidUSBCamera repo, preview.zip Please check this file, and let me know your thought.

fps As you can see from this image, one frame in 3 seconds, can you help?

quantum6 commented 1 year ago

1, This code is forked from that. I rebuild and upload, anyone can download and build directly. 2, fps=1means no video frame received. 3, How you record the video file?

super0610 commented 1 year ago

I built this repo (https://github.com/jiangdongguo/AndroidUSBCamera) and used apk to record. Record works even the preview is almost green, and low fps (= 1). Did you check yuv file? can know anything?

quantum6 commented 1 year ago

I researched that repo. By this time, I don't know (where the data come from). So I can;'t record yuv data.