Correct way to send android camera to PC?

Hello, does anyone have any example on how to send the image from the camera of an android phone to a PC with processing?

I donā€™t know how ā€œcorrectā€ it is, but it worked for me. I was able to see the android camera output on the desktop in processing.

But this is an apk. I need capture and share android camera fron android processing apk. My project are a robot controlled from any windows pc with processing. The robot hardware are a android phone and arduino uno connected to phone by usb otg. I need swnd camera and receive commands to meve robot.

A picture taken and saved in the library?

1 Like

Hi, thanks for the help butā€¦ really i have send a image over network from Android phone yo Windows PC.

What program are you planning to use on the PC to receive the file?
And where is the file located on the phone? Or are you drawing in a sketch, and you want to send it from within?

Hi and good morning!
Data itĀ“s not a file, itĀ“s a image captured from camera, in byte array for example pixels[].

The idea is simple, capture de camera in real time and send it to pc, same al live webcam.

That I understood. But you need some program to receive the ā€˜image fileā€™.

Yes, this project is closes by two parts, one for android with camera sender and another processing program on pc to decode and draw images.

I think Iā€™m going to capture the array of pixels and send it directly.

so, wich is the best way to do this?
capture the sketch canvas to an image and send over http?
may be send a text file with the pixel array?
If the pc sketch acts like an http server maybe?

the most efficient way i think is if the phone acts like an http server and you simply point to that address?
the other way take a Pimage in android from an http: can be done and i have tested it.
You just have to give cleartext permission for http in manifest xml.

<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="" android:usesCleartextTraffic="true">

and corresponding sketch permissions INTERNET and wifi state

PImage scimg = loadImage("http://"+clientIP+":8000/screenshot.jpg");

so is there a way to make the processing sketch in angroid act as a simple http server and host images for example in /data folder?

Hello, it can be done like this, but I think it will not be necessary in my case. For me the best solution is to simply send the pixels of the image from android to PC over the network. For udp it would be ideal but for TCP it can also be useful if you are careful to wait for the acknowledgment before sending a new frame;)

how do you achieve that?

Hi, I donā€™t use OSC because in android it has several serious bugs when the server is the part that runs in android. For this reason I created my own network library very similar to OSC but really a standard library for processing / java.
I have not yet written the part of the program that sends the image but it is very simple with the library that I have for processing 3, and it works perfectly on all platforms, it is based on webSockets to also be compatible with html5. As soon as I have the written program I will share it with you;)