0

For a project, I set up a small android application which communicates via TCP with a server, which is my PC. My goal is to basically stream camera input to the server, evaluate them through means of CV, and send a a simple response back. Being a total novice in all things Android, there also lies my problem.

I was not able to find a generally considered best practice for this. There seem to be a lot of possible ways to approach camera capture and I tried some of them, but nothing really works as I wished. Common denominator was always sending Bytearrays over the network. Currently I use a TextureView in a CameraX environment, simply call getBitmap() to get the current screen and send the converted data. This takes way too much time to be efficient (getBitmap() seems to be bad for this).

Anyway, basically I am currently really lost what would be the correct approach for my problem, maybe there is a best practice. After reading more on the topic, I believe I should use OpenGL, but would really appreciate any recommendation to guide me.

Regards

Leanhope
  • 1
  • 4
  • I am not quite certain how you are achieving screen capture using CameraX. The official screen capture solution on Android 5.0 is to use the media projection APIs. [These sample projects](https://github.com/commonsguy/cw-omnibus/tree/v9.0/MediaProjection), profiled in [this book](https://commonsware.com/Android), perform individual screen captures (`andshooter`) and screencasts (`andcorder`). – CommonsWare Jul 25 '19 at 13:45
  • Hm, maybe screen capture is the wrong term. Let me clarify: Every n-th frame captured with CameraX in the textureView is converted to a bitmap, from there to a Bytearray. I do not intend to actually record a video, sorry for the wrong term. – Leanhope Jul 25 '19 at 13:57
  • "Screen capture" usually refers to recording the contents of the device screen (screenshots, screencasts, etc.). CameraX is for recording what is seen via a camera (photos, videos, etc.). – CommonsWare Jul 25 '19 at 14:02

1 Answers1

0

If you want to achieve some processing on every frame from camera. I would recommend having a look at image analysis in CameraX. It provided every preview frame image in yuv format to app. https://developer.android.com/training/camerax/analyze

Wasim Ansari
  • 305
  • 1
  • 9