最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Access android device camera into a service - Stack Overflow

programmeradmin3浏览0评论

I am stuck into a problem programming an android application, using Java. I am implementing a Service, since my application should run in background, without affecting the other functionalities of the device.

I should access to camera device, I just need to grub the current camera frame within a given framerate. I am a bit confused, since it seems that I cannot access to camera without a view panel (and, since I am programming a service, I don't have a view panel).

I have tried different solutions found online, but no one of them works. I am using Andoird 6.0 (sdk 23). Do you have any hints?

------------ EDIT ------------------

Why should a service access to the camera?

I am working on a robotic system that is interfaced via a set of android API (the robot is composed of 2-layers. One is a standard computer that is not accessible, the other is the android layer with its API). Along with the APIs, the tablet has also different sensors, like a standard tablet camera.

I am developing an interface to get its sensors and make available the APIs via network, enabling the robot to be controlled without writing proper android applications on the robot. I have quite finished, and everything runs in a service, so the user will not lose the control of the robot tablet. However, I am not able to stream the camera data.

Regards,

I am stuck into a problem programming an android application, using Java. I am implementing a Service, since my application should run in background, without affecting the other functionalities of the device.

I should access to camera device, I just need to grub the current camera frame within a given framerate. I am a bit confused, since it seems that I cannot access to camera without a view panel (and, since I am programming a service, I don't have a view panel).

I have tried different solutions found online, but no one of them works. I am using Andoird 6.0 (sdk 23). Do you have any hints?

------------ EDIT ------------------

Why should a service access to the camera?

I am working on a robotic system that is interfaced via a set of android API (the robot is composed of 2-layers. One is a standard computer that is not accessible, the other is the android layer with its API). Along with the APIs, the tablet has also different sensors, like a standard tablet camera.

I am developing an interface to get its sensors and make available the APIs via network, enabling the robot to be controlled without writing proper android applications on the robot. I have quite finished, and everything runs in a service, so the user will not lose the control of the robot tablet. However, I am not able to stream the camera data.

Regards,

Share Improve this question edited Mar 15 at 7:35 Jonathan asked Mar 14 at 17:41 JonathanJonathan 213 bronze badges 3
  • Why a service should access the camera? Please describe your use case from end user point of view. – Livio Commented Mar 14 at 20:21
  • Thanks, I added further info to my problem. – Jonathan Commented Mar 15 at 7:35
  • I suggest to use only ImageCapture and start the camera using following statement: Camera camera = cameraProvider.bindToLifecycle(this, cameraSelector, imageCapture); – Livio Commented Mar 15 at 18:32
Add a comment  | 

1 Answer 1

Reset to default 0

Your approach seems to be technically infeasable. Unfortunately (because of security concerns) Android does not allow you to send a camera feed without a foreground application (You would be able to spy on people).

To make things easier, you could have a workaround that would make your setup significantly easier. Because you are using a Tablet you could start your App in a Splitscreen with the Robot App. People couldbe able to view your App (and you could display Robot Data) and you would be able to capture and send Camera Data. You could look here for a way of implementing the splitscreen!

发布评论

评论列表(0)

  1. 暂无评论