Android Camera with Processing

Hello !
I was recently introduced to Processing . I’m working on a big school project that involves object tracking and I think Processing is perfect for that . I saw that there is a cool library for connecting your phone over wi-fi for the video stream . I don’t want to buy web cameras , because they are kinda pricey . The library is called “AndroidCapture for Processing” . But there is a gigantic delay … almost unusable for my needs . Is there a way to connect my phone over to my PC with a USB cable ?

You should be able to stream real time video. Not sure if any of the free available code will be able to do the job. If I were you, I will start with the ketai library which is meant to be used in Processing Android. Make sure you use the P3D if you want to render real time on the phone (if it has OpenGL support). Also, for a better real time experience, choose a lower frame size streaming, like 320x240 instead of 640x480 or higher. Notice you will still need to implement the wifi data transfer. Maybe check for a connection using sockets.

Not sure about streaming data code. A quick search return something like this: https://android.stackexchange.com/questions/7686/is-there-a-way-to-see-the-devices-screen-live-on-pc-through-adb You should focus in a search along the lines “mirroring my screen device to pc” and you will get some hits. If it is pure Android Java, there is a possibility that can be ported to Android Processing.

Kf

1 Like

Thank you for the informative reply ! But I have 1 more question .
I saw a library for a PS3 Camera using Libusb … can i use libusb for my needs ? Can i combine Ketai with Libusb to stream my android camera to processing ?

good idea not to waste money
and also to reuse old things,
but as you talk about using a ?big? PC together with a ?good? mobile
to save some money for a camera??

how about a total different setup: https://www.raspberrypi.org/products/

  • raspberry pi 3B+ 38$
  • 8Mpix camera 25$
  • Raspbian Linux OS and Processing 3.4 FREE
    ( ok, plus uSD card and power supply )

just a idea…

It doesn’t need to be that small or portable . My project : every year in my school we have a day where kids can walk around the halls and check out projects that students have made the past year . My friend made a robotic arm . I want to use 2 phones to scan a table … where this arm is sitting and using the Firmata processing library to send it missions that it can do based on markers of some sort . I want to recreate maybe a factory type setting where 1 arm can make the whole thing and it doesn’t need to have a line with 10 arms for example !

1 Like

Not familiar with the library. Share a link to your resources and I might be able to help (as time permits). Also check online sample code. I bet there are people that have put some effort to do what you want to do and they have made it available out there. Maybe you might not find the source right here in the community but it does not mean you can integrate it yourself. If stuck, just ask a question here…

Kf

The PS3 controller library is this one https://github.com/diwi/PS3Eye . I don’t know anything about libusb … i just have a driver for it . I will try to scrap code from some parts of the internet and hopefully i can even make a library myself ! I’m using a piece of software that can decompile java and I’m decompiling those 3 here … so I can try to see how they work, but I’m not on my PC atm , so I can’t tell you what I use .
Links I find useful i for now : https://github.com/libusb/libusb/tree/master/android
https://github.com/onlylemi/processing-android-capture

EDIT: This is what libusb is libusb : Libusb is a C library that provides generic access to USB devices. It is intended to be used by developers to facilitate the production of applications that communicate with USB hardware.

It is portable : Using a single cross-platform API, it provides access to USB devices on Linux, OS X, Windows, Android, OpenBSD, etc.

It is user-mode : No special privilege or elevation is required for the application to communicate with a device.

It is version-agnostic : All versions of the USB protocol, from 1.0 to 3.1 (latest), are supported.

Hi.

Ketai can use any camera attached to android, either phone camera or usb camera. You can see a video demo shot with a usb camera attached to android tvbox here:

Regards.

@JoseMY
@ZaharyMomchilov

You can use any cam with android but i am not sure that ketai can list usb devices as it wraps camera.Info class for that and camera.info recognizes only front && face cam. Anyway the main problem is to send live video streaming; i have got a look to the Capture lib src: it opens a socket and send each image, which is not at all live video streaming and has to be very very slow or laggy. Of course yu have to open a socket but before sending you have to “packetise” your images which is not at all easy to code. As for me i have done that two ways: first one simply using wowza streaming engine which has an android app doing that then sending to the server (not free!); second one is to use ffmpeg streamer and server (or VLC), this is feasable but supposes to use ndk because ffmpeg is a C++ lib…

1 Like