Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the Camera via Bluetooth?

This is what I'd like to achieve. I have 2 android devices, I would like to access the camera of the second via bluetooth and display the preview on the first one.

Any hints how to do this?

Basically I would like to get a camera instance of another android device via bluetooth.

like image 607
Manza Avatar asked Mar 12 '14 18:03

Manza


1 Answers

Short Answer:

You can't get a direct instance this way. That is - you're not going to get a Camera Object which you'll be able to use normally. Instead you're going to have to fake it a fair amount.

Long Answer:

You're going to have to set up a bluetooth client/host relationship between the two devices. After you've done that you're going to set one up as the "control" aspect of this relationship, and the other as the camera. We'll call these 1 and 2.

1 will have a UI (take picture button etc). When a button is pressed, a command will travel down the line to 2.

2 will then do as the command requests and pass some data back to 1.

In the case of taking a picture:

User presses take picture button in 1. 1 Sends command "take a pic" to 2. 2 then uses this command to take a photo as per your instruction. 2 then sends the file result of this picture back over the bluetooth.

For doing image preview - that is seeing what the image is before you actually click "capture" - I don't think you're going to have much luck. You could do this following the above pattern, but I'm doubtful that it would be a smooth experience.

EDIT:

After some discussion with Alex in comments, and some thinking on this I have a few ideas for preview.

Concerns:

If you can get around 10-15 fps from 2 to 1 you can have a reasonable preview. Depending on your needs/use case even less might be possible.

You need to implement

Camera.PreviewCallback:

onPreviewFrame(byte[] data, Camera camera); :

http://developer.android.com/reference/android/hardware/Camera.PreviewCallback.html#onPreviewFrame(byte[], android.hardware.Camera), and register your callback with

Camera

setPreviewCallback(Camera.PreviewCallback cb)

You need to downsample (likely, I'm not sure on the sizes of what's provided in onPreviewFrame) to keep content size low.

4) Send.

I'm not entirely sure this would work as I haven't tested it, but thats the most straightforward route that I see.

Another Option:

Go into the JNI and handle the entire thing there. You could almost certainly make this work at that level in terms of speed. I have vague ideas on how to do this but it would be a fairly substantial undertaking.

like image 86
Nathaniel D. Waggoner Avatar answered Nov 12 '22 18:11

Nathaniel D. Waggoner