saki4510t / UVCCamera

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

Latency in Image preview #671

Open asadasivam opened 1 year ago

asadasivam commented 1 year ago

Does latency when showing the .png file to the image preview can be reduced by showing Bitmap directly?

asadasivam commented 1 year ago

Pls need a quick support on this issue.

shengjunhu commented 1 year ago

Does latency when showing the .png file to the image preview can be reduced by showing Bitmap directly?

Image decoding and image format conversion are time-consuming, and the larger the image size, the more time-consuming it is

asadasivam commented 1 year ago

Sry my question does n't asked in a correct way.

Use case : Button Press -> Capture current frame and display in Image preview area implementing using 480P camera

Code flow:

  1. button press -> calling captureStill method in AbstractUVCCameraHandler class
  2. In handleCaptureStill method-> Capturing current frame as a bitmap and save it in a compressed file(.PNG).
  3. Using setImageBitmap(ImageView.class) and bringToFront(View.class) methods, we direct the compressed file into Image view

My question is can't we directly show the bitmap in Image preview area instead of encoding into a file and then show the file in Image preview area?

shengjunhu commented 1 year ago

Sry my question does n't asked in a correct way.

Use case : Button Press -> Capture current frame and display in Image preview area implementing using 480P camera

Code flow:

  1. button press -> calling captureStill method in AbstractUVCCameraHandler class
  2. In handleCaptureStill method-> Capturing current frame as a bitmap and save it in a compressed file(.PNG).
  3. Using setImageBitmap(ImageView.class) and bringToFront(View.class) methods, we direct the compressed file into Image view

My question is can't we directly show the bitmap in Image preview area instead of encoding into a file and then show the file in Image preview area?

It is not recommended to use this method. It will be inefficient, and the CPU and memory will shake severely, which will also cause the preview to get stuck

asadasivam commented 1 year ago

It is not recommended to use this method. It will be inefficient, and the CPU and memory will shake severely, which will also cause the preview to get stuck

1729051657 commented 5 months ago

It is not recommended to use this method. It will be inefficient, and the CPU and memory will shake severely, which will also cause the preview to get stuck不建议使用此方法。效率会很低,CPU和内存会剧烈抖动,也会导致预览卡住

  • From the IFrameCallback.java, we understood another possible. Does its a recommended method?从 IFrameCallback.java 中,我们理解了另一种可能性。这是推荐的方法吗? "If you want to get same result as on screen, please try to “如果您想获得与屏幕上相同的结果,请尝试
    • consider to get images via texture(SurfaceTexture) and read pixel buffer from it using OpenGL|ES2/3考虑通过 texture(SurfaceTexture) 获取图像并使用 OpenGL|ES2/3 [美]
    • instead of using IFrameCallback(this way is much efficient in most case than using IFrameCallback)"而不是使用 IFrameCallback(这种方式在大多数情况下比使用 IFrameCallback 要有效得多)”

如何实现呢?