Unofficial Java API library for the Raspberry Pi camera.
Alternatives To Picam
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
13 days ago56June 06, 2020888gpl-3.0Python
A web frontend for the motion daemon.
2 years ago42bsd-2-clausePython
OpenCV Python Neural Network Autonomous RC Car
2 years ago25mitPython
python app to turn a photograph into a cartoon
10 months ago1November 01, 202019gpl-3.0Python
Deep learning gateway on Raspberry Pi and other edge devices
a month ago15mitJavaScript
Open-Source AI Camera. Empower any camera/CCTV with state-of-the-art AI, including facial recognition, person recognition(RE-ID) car detection, fall detection and more
10 months ago269bsd-3-clausePython
A pure Python interface to the Raspberry Pi camera module
Pi Webcam1,328
3 months ago10mit
Automation to configure a Raspberry Pi as a USB OTG webcam
5 months ago62gpl-3.0Shell
Raspberry Pi + High Quality Camera = High-quality USB Webcam!
Gentoo On Rpi 64bit914
3 years ago47gpl-3.0Shell
Bootable 64-bit Gentoo image for the Raspberry Pi4B, 3B & 3B+, with Linux 5.4, OpenRC, Xfce4, VC4/V3D, camera and h/w codec support, weekly-autobuild binhost
5 months ago4February 16, 202227apache-2.0Go
Open-Source HomeKit Surveillance Camera
Alternatives To Picam
Select To Compare

Alternative Project Comparisons

You are currently looking at the development branch for picam-2.0.0, if you are looking for the previous version of picam you should switch to the picam-1.x branch.

At the moment this master branch for 2.0.0 is somewhat experimental in that it uses JNI rather than JNA to access the camera and there is a little bit more involved in getting up and running.

If you want to play it safe, use the picam-1.x branch instead, if you want to experiment, test, or help improve the JNI solution then by all means this master branch is for you!


An easy-to-use Open Source Java library to access the Raspberry Pi camera module.

This library provides a direct Java API to the camera - behind the scenes the native MMAL library is used.

This library does not require any external native processes nor does it wrap any native executable program.

The implementation is based loosely on that used by the native RaspiStill utility.

This project is unofficial and is not affiliated in any way with the Raspberry Pi Foundation.


Picam 2.0.0 brings a pure JNI implementation rather than using JNA, this should give a modest but notable performance boost compared to the JNA implementation in picam-1.x.

Version 2.0.0+ of picam brings some small API changes, you may have to make some minor adjustments to your code if you decide to move to the new version.

Release are available at Maven Cental.


Add the following Maven dependency to your project:


No other dependencies are necessary.

Since version 2+ of picam, JNI is used directly via the picam native library project.

You can build this library yourself, or use the pre-built shared library that is bundled in the picam jar file.

Testing the Installation

A very basic capture application is provided with the picam jar file. You can test that everything works like this:

java -jar picam-2.0.0.jar 1280 800 test.jpg

The command-line parameters are width, height and filename respectively.

Basic Usage

The first thing to do is to install the picam JNI native library, you can set this up manually if you want, but the simplest way is to have picam do it for you:

import static uk.co.caprica.picam.PicamNativeLibrary.installTempLibrary;

public class PicamTest {

    public static void main(String[] args) {
        // Extract the bundled picam native library to a temporary file and load it
        // ... your application code ...


Using the library itself is simple, first you create a CameraConfiguration using a convenient "builder" approach:

CameraConfiguration config = cameraConfiguration()

You can supply as much or as little configuration as you want, sensible defaults will be provided where needed.

Next, create a Camera with that configuration:

try (Camera camera = new Camera(config)) {
    camera.takePicture(new FilePictureCaptureHandler(new File("picam1.jpg")));
    camera.takePicture(new FilePictureCaptureHandler(new File("picam2.jpg")));
catch (CameraException e) {

Captured images can be directly saved to disk, or returned and processed as a byte[].

The above example used a FilePictureCaptureHandler that saves the captured picture directly to disk. You are free to provide your own implementations of a PictureCaptureHandler to suit your own needs.

That example also created a camera, took only a single picture and automatically cleaned up the camera since Camera implements AutoCloseable. There is no reason why you couldn't keep a camera component and take multiple pictures before finally closing the camera yourself. It is important that whichever approach you use you close the camera when you are finished using it to free up the camera and associated resources.

If the colouration of your captured pictures looks a bit "off", try setting a delay value when you take the picture. The delay value is used to give the camera sensor time to "settle" before capturing the image. Even a delay as small as 5ms can make a significant difference. A longer delay for the first capture is sometimes needed.

You can specify the delay like this:

try (Camera camera = new Camera(config)) {
    camera.takePicture(new FilePictureCaptureHandler(new File("picam-1.jpg")), 3000);
    camera.takePicture(new FilePictureCaptureHandler(new File("picam-2.jpg")));
catch (CameraException e) {

This example code fragment shows waiting 3 seconds (3,000 milliseconds) for the first picture, then no delay for the second picture.

The Camera instance is obviously not thread-safe. You must not attempt to use the camera from multiple threads at the same time.



Some new tutorials are available here.


The current API is stable but nevertheless is still subject to change.

Hundres of thousands of images have been captured, but you might like to have a look at this issue.

Feedback is welcome at the github project.

Most major/useful camera features or effects are implemented:

  • [x] image width/height
  • [x] image encoding
  • [x] encoding quality (for JPEG encoding)
  • [x] stereo mode
  • [x] brightness
  • [x] contrast
  • [x] saturation
  • [x] sharpness
  • [x] video stabilisation
  • [x] shutter speed
  • [x] ISO
  • [x] exposure mode
  • [x] exposure metering mode
  • [x] exposure compensation
  • [x] dynamic range compression strength
  • [x] automatic white balance modes
  • [x] automatic white balance red/blue gain
  • [x] image effects
  • [x] colour effects
  • [x] flip horizontally/vertically
  • [x] rotation (90 degree steps)
  • [x] crop (region of interest)
  • [x] initial capture delay (time for the sensor to 'settle')

Trademark Acknowledgement

Raspberry Pi is a trademark of the Raspberry Pi Foundation.

Demo Application

This screenshot shows a Java web application running on the Pi:


Popular Camera Projects
Popular Raspberry Pi Projects
Popular Hardware Categories

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Raspberry Pi