Tutorial
Tutorial
Tutorial
com Welcome 1
Welcome
Thank you for choosing Freenove products!
Get Started
Get Support
When there are packaging damage, quality problems, questions encountering in use, etc., just send us an
email. We will reply to you within one working day and provide a solution.
About
Freenove is committed to helping customers learn programming and electronic knowledge, quickly
implement product prototypes, realize their creativity and launch innovative products. Our services include:
To learn more about us or get our latest information, please visit our website:
http://www.freenove.com
Copyright
All the files provided in the ZIP file are released under Creative Commons Attribution-NonCommercial-
ShareAlike 3.0 Unported License. You can find a copy of the license in the ZIP file.
It means you can use these files on your own derived works, in part or completely. But not for commercial
use.
Freenove® brand and logo are trademarks of Freenove Creative Technology Co., Ltd. Must not be used
without permission.
TM
Get Started
Note (Important)
Please note that our FNK0056 prodcut, which comes with the camera model OV5647, is only compatible with
Raspberry Pi; while the product FNK0056B, with camera model IMX219, can work with both Raspberry Pi and
Jetson Nano.
Note: If you want to use a Raspberry Pi Zero, you need a Camera Module ribbon cable that fits the Raspberry
3. Insert the Camera Module ribbon cable; make sure the connectors at the bottom of the ribbon cable are
facing the contacts in the port.
M2*10
Screw
M2 Nut
Camera
M3*30
Standoff
M3*6
Screw
Step 3 How to control the Camera Module via the command line
The Python Picamera2 module currently uses the latest version of the Raspberry PI operating system
(called Bullseye) by default.
Picamera2 is designed for systems running either Raspberry Pi OS version or Raspberry Pi OS Lite, using a
Bullseye or later image. It is pre-installed in current images downloaded from the Raspberry Pi website, or
can be installed using the Raspberry Pi Imager tool. Users with older images should consider updating them
or proceed to the installation instructions.
Picamera2 can operate in a headless manner, not requiring an attached screen or keyboard. When first setting
up such a system we would recommend attaching a keyboard and screen if possible, as it can make trouble-
shooting easier. Raspberry Pi OS Bullseye and later images by default run the libcamera camera stack, which
is required for Picamera2.
Open a terminal window by clicking the black monitor icon in the taskbar:
If you are using the FNK0056B 8MP camera, to have the camera be detected successfully, you need to modify
the configuration file to add the designated camera driver.
If you are using the FNK0056 5MP camera, you can skip this configuration.
Before testing the camera, run the following command to see if the camera can be detected.
libcamera-hello --list-cameras
Or this command:
ls /dev/video*
/dev/video0 indicates the camera is connected. If you do not find this device, please check the camera wiring.
You may reconnect it and try again.
Please note that when operating the camera wiring, you need to shut down the raspberry pi first; otherwise,
it may burn the camera.
You can check that libcamera is working by opening a command window and typing:
libcamera-hello
You should see a camera preview window for about five seconds. If you do not, please refer to the Raspberry
Pi camera documentation.
You can also enter the following command to capture an image with a resolution of 800 by 600. The image
is saved in the current directory path by default.
libcamera-jpeg –o test.jpg –t 2000 –width 800 –height 600
If you aer using Raspberry Pi 5, the camera may not work with the latest system. In this case, please update
the kernel of the Raspberry Pi OS and test again.
After the update, reboot your Raspberry Pi and run the image capture command again to see if it works.
libcamera-jpeg –o test.jpg –t 2000 –width 800 –height 600
Press Ctrl+O, Enter, Ctrl x to save the change and exit it.
Reboot your Raspberry Pi and run the image capture command again to see if it works.
libcamera-jpeg –o test.jpg –t 2000 –width 800 –height 600
The Python picamera library allows you to control your Camera Module and create amazing projects.
Open a Python 3 editor, such as Thonny Python IDE:
In this example we use the H.264 encoder. For the output object we can just use a string for convenience; this
will be interpreted as a simple output file. For configuring the camera, the create_video_configuration is a
good starting point, as it will use a larger buffer_count to reduce the risk of dropping frames.
We also used the convenient start_recording and stop_recording functions, which start and stop both the
encoder and the camera together. Sometimes it can be useful to separate these two operations, for example
you might want to start and stop a recording multiple times while leaving the camera running throughout.
For this reason, start_recording could have been replaced by:
1 encoder.output = 'test.h264'
2 picam2.start_encoder(encoder)
3 picam2.start()
and stop_recording by:
1 picam2.stop()
2 picam2.stop_encoder()
All the video encoders can be constructed with parameters that determine the quality (amount of compression)
of the output, such as the bitrate for the H.264 encoder. For those not so familiar with the details of these
encoders, these parameters can also be omitted in favour of supplying a quality to the start_encoder or
start_recording functions.
Thepermitted quality parameters are:
•Quality.VERY_LOW
•Quality.LOW
•Quality.MEDIUM - this is the default for both functions if the parameter is not specified
•Quality.HIGH
•Quality.VERY_HIGH
This quality parameter only has any effect if the encoder was not passed explicit codec-specific parameters.
It could be used like this:
Open Terminal,
1. Enter Raspberry_Pi folder with cd command.
cd ~/Freenove_Camera_Module_for_Raspberry_Pi/Raspberry_Pi
2. Run the code
python camera_quality.py
Enter the following code:
1 import time
2 from picamera2.encoders import H264Encoder, Quality
3 from picamera2 import Picamera2
4 picam2 = Picamera2()
5 video_config = picam2.create_video_configuration()
6 picam2.configure(video_config)
7 encoder = H264Encoder()
8
9 picam2.start_recording(encoder, 'low.h264', quality=Quality.VERY_LOW)
10 print(encoder._bitrate)
11 time.sleep(5)
12 picam2.stop_recording()
13
14 picam2.start_recording(encoder, 'medium.h264', quality=Quality.MEDIUM)
15 print(encoder._bitrate)
16 time.sleep(5)
17 picam2.stop_recording()
18
19 picam2.start_recording(encoder, 'high.h264', quality=Quality.VERY_HIGH)
20 print(encoder._bitrate)
21 time.sleep(5)
22 picam2.stop_recording()
You can also check out the official documentation to learn more about picamera2:
https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf
There are so many interesting examples for you to learn in picamera2.
The official library link is as follows:
https://github.com/raspberrypi/picamera2