Cameras for Raspberry Pi

  1. Home
  2. Docs
  3. Cameras for Raspberry Pi
  4. IMX519 Autofocus Camera and Raspberry Pi libcamera Guide
  5. Solution Of Using Autofocus Camera On OctoPrint

Solution Of Using Autofocus Camera On OctoPrint

In the past, OctoPrint official only supported the native camera and native driver of Raspberry Pi. But with our efforts, other sensors including IMX519 and IMX298 can also use libcamera and OctoPi. This article will show you how to use OctoPi on our autofocus camera.

1. SD Card image:

2. System information:

[email protected]:~ $ uname -a
Linux octopi 5.10.92-v7l+ #1514 SMP Mon Jan 17 17:38:03 GMT 2022 armv7l GNU/Linux

[email protected]:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

3. Install dependencies

3.1. Install the Driver(Example using imx519)

How to install and build Raspberry Pi Kernel Driver for IMX519 Camera 
How to install libcamera?
For the official Raspberry Pi camera modules (V1/V2/HQ), it’s already built-in. If you are using the Arducam Autofocus Camera for the first time, please follow these steps:
Step 1. Download the bash scripts Step 2. Install libcamra-dev Step 3. Install libcamera-apps ….

# Agree to restart after installation

wget -O
chmod +x
./ -p imx519_kernel_driver

3.2. libcamera-dev and libcamera-apps Installation

How to access and program the Pivariety Camera using Command Line, Python,… 4
Contents1. libcamera-dev and libcamera-apps Installation1.1. Use pre-compiled binaries1.1.1 Install libcamera1.1.2 Install libcamera-apps1.2. Build from the source code1.2.1 Install dependency1.2.2 Download and compile libcamera1.2.3 Download and…

./ -p libcamera_dev
./ -p libcamera_apps

3.3. Test

Check video device:

libcamera-still -t 5000 -o test.jpg -n

4. Download libcamera plugin source code

Clone mjpg-streamer source code and execute the following commands, compile and install the libcamera plugin.

git clone mjpg-streamer-libcamera
cd mjpg-streamer-libcamera/mjpg-streamer-experimental
sudo install -m 755 _build/mjpg_streamer /opt/mjpg-streamer
sudo find _build -name "*.so" -type f -exec install -m 644 {} /opt/mjpg-streamer \;
sudo cp -a -r ./www /opt/mjpg-streamer
sudo chmod 755 /opt/mjpg-streamer/www
sudo chmod -R 644 /opt/mjpg-streamer/www

5. Modify the octopi.txt file

Edit /boot/octopi.txt, and make the following changes

5.1. Configure which camera to use

image 15

like this:

5.2. Set parameters for libcamera plugin.


Parameter details can be viewed using the following command.

./mjpg_streamer -i " -h"

5.3. Configuration of camera HTTP output


You can also use the command to view the camera_http_options parameter.

./mjpg_streamer -o " -h"

6. Replace webcamd file

webcamd is in the /root/bin directory.

You can change the name of the original file to achieve the purpose of backup. Then copy our modified webcamd to the /root/bin directory.

In the example, we downloaded the new file to the /home/pi directory.

cd ~
sudo mv /root/bin/webcamd /root/bin/webcamd.bak
sudo wget -O webcamd
sudo mv webcamd /root/bin/
sudo chmod 755 /root/bin/webcamd

7. Reboot your Pi

sudo reboot

8. View in browser

8.1. Display

Enter the device’s IP address(ipv4 address) in the browser address bar.

Click on the label pointed by the red arrow in the image below to view the image captured by the camera.

8.2. Control

Install control plugin

Click the button pointed by the arrow in the image below.

Follow the instructions to complete the plugin download.

Copy the link to the location outlined in the diagram.

Finally, follow the prompts on the page to restart the service.

sudo reboot

You can use this plugin to achieve manual focus.

Was this article helpful to you? Yes 2 No 5