Skip to content
Unofficial Java API library for the Raspberry Pi camera.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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.


16th March, 2019 - new release 1.0.0 available at Maven Cental


Add the following Maven dependency to your project:


Basic Usage

Using the library 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("picam.jpg")));

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 images looks a bit "off", try setting a delay value on the CameraConfiguration - 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.

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 should be considered alpha, it is stable but nevertheless is still subject to change.

Thousands upon thousands of images have been captured with no problems.

Feedback is welcome at the github project.

Not all camera features or effects are implemented, the aim is to add more support over time:

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

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:


You can’t perform that action at this time.