Robo4J RaspberryPi Camera client example
The example is capable to take or post images to specific network destination. The example is designed for standard raspberryPi camera modules (v1.3, v2).
- you need to have your camera connected/configure to your RapsberryPi device
- go to project folder release
- upload following files
$scp ./robo4j.xml pi@<YOUR_IP>:/home/pi
$scp ./robo4j-rpi-camera-client.jar pi@<YOUR_IP>:/home/pi
- login to your RaspberryPi device
$ssh pi@<YOUR_IP>
- IMPORTANT: configure your robo4j.xml configuration file by defining IP address where Robo4J Camera center is running
$vi robo4j.xml
edit :
1. <roboUnit id="httpClient">
<class>com.robo4j.socket.http.units.HttpClientUnit</class>
<config name="com.robo4j.root">
<value name="address" type="String">...CHANGE_your-ip...192.0.0.42</value>
2. <roboUnit id="imageController">
<class>com.robo4j.units.rpi.camera.RaspistillUnit</class>
<config name="com.robo4j.root">
<value name="targetOut" type="String">httpClient</value>
<value name="storeTarget" type="String">imageProvider</value>
<value name="client" type="String">...CHANGE_your-ip...192.0.0.42</value>
- after having cofiguration done, you can run following command
$ java -jar ./robo4j-rpi-camera-client.jar ./robo4j.xml
- camera-client should star sending images on your Robo4J Camera-Center server, and you should see images there
The robo4j.xml system configuration descriptor allows to the user to specif camera properties.
- width
- height
- timeout
- quality
- sharpness
- brightness
- contrast
- saturation
- timelapse
- exposure
<roboUnit id="imageController">
<class>com.robo4j.units.rpi.camera.RaspistillUnit</class>
<config name="com.robo4j.root">
<value name="targetOut" type="String">httpClient</value>
<value name="storeTarget" type="String">imageProvider</value>
<value name="client" type="String">127.0.0.1</value>
<value name="clientPort" type="String">8027</value>
<value name="clientUri" type="String">/imageController</value>
<value name="width" type="String">640</value>
<value name="height" type="String">480</value>
<value name="exposure" type="String">nightpreview</value>
<value name="brightness" type="String">60</value>
<value name="contrast" type="String">30</value>
<value name="timeout" type="String">1</value>
<value name="timelapse" type="String">100</value>
</config>
</roboUnit>
NOTE: options client, clientPort are not used in standalone example execution. Both define the Robo4J unit where the taken image should be send. Don't change them, you may want to change only camera realted properties.
properties values are according to the 'raspstill' util documentation
- clone and install robo4j project from Robo4J Github organisation
- Robo4J will be installed into the local maven repository
- command inside the project root folder:
$ gradle clean build install
- clone Robo4J-rpi-camera-client example from Github
- go the the directory and create FatJar file
- command:
$ gralde clean fatJar
- upload jar file to raspberryPi
- you can use scp command:
$ scp ./robo4j-rpi-camera-client-alpha-0.3.jar pi@x.x.x.x:/home/pi
- run example on raspberryPi client
$ java -jar robo4j-rpi-camera-client-alpha-0.3.jar
- image is available over http get request
- open your favorite browser
- type link: http://:8025/imageProvider?image.jpg
- imageProvider is the unit reponsible for providing taken image
- URI option: image.jpg is the access to the taken image
Notes: RaspberryPi must have successfully installed camera module otherwise default image will be displayed
Example of Running example on raspberryPi:
INFO: cameraCommand:raspistill -br 60 -ex nightpreview -co 30 -w 640 -t 1 -tl 100 -h 480 -n -e jpg --nopreview -o -
State before start:
RoboSystem state Uninitialized
================================================
httpClient Initialized
httpServer Initialized
imageController Initialized
imageProvider Initialized
scheduleController Initialized
State after start:
RoboSystem state Started
================================================
httpClient Started
httpServer Started
imageController Started
imageProvider Started
scheduleController Started
Press enter to quit!
The Robo4j framework uses Gradle to build. It's required to create fatJar file and run.
- Java JDK 8
- Robo4j.io :: version: alpha-0.3
Follow @robo4j or authors: @miragemiko , @hirt on Twitter. In-depth articles can be found at Robo4j.io or miragemiko blog
The Robo4j.io Framework is released under version 3.0 of the General Public License.