Pi4 Microscope Kit
Pi4 Microscope Kit is for Raspberry Pi 4th generation. It uses the original 12-megapixel camera module of Raspberry Pi with a 6mm fixed-focus wide-angle lens, and a 4.3-inch 800x480 pixel DSI touch screen as the display screen. It is easy to assemble and more convenient to preview the camera screen.
4.3inch DSI LCD Parameters
- 800×480 pixel, IPS screen, with tempered glass panel, support 5-point touch, viewing angle up to 160°.
- Support DSI display interface, high frame rate, and good compatibility with Raspberry Pi system.
- For more details, please refer to 4.3inch DSI LCD (B).
Raspberry Pi original High-quality Camera Parameters
- 12 million pixels 4056 (H) × 3040 (V), support RAW12 / 10 / 8, COMP8 format output.
- 7.9mm CMOS diagonal length.
- C-mount/CS-mount lens standard with integrated IR filter.
- For more details, please refer to Raspberry Pi High-Quality Camera.
Wide Angle Lens Parameters
- 6mm fixed focus, support 63-degree field of view, wider viewing angle.
- F1.2 aperture, more light intake, support manual adjustment.
- For more details, please refer to Wide Angle Lens.
Working with Raspberry Pi
4.13 inch DSI LCD
- Using the FFC cable, connect the 4.3-inch DSI LCD to the DSI port of the Raspberry Pi.
- For convenience, the Raspberry Pi can be screwed to the back of the 4.3-inch DSI LCD and assembled with copper posts.
1. Please download the newest image from Raspberry Pi official website, download the compressed file to the PC, and extract the .img file.
2. Connect the TF card to PC, and use SDFormatter to format the TF card.
3. Open Win32DiskImager, select the system image prepared in step 1, and click "write" to burn the system image.
4. After the programming is completed, save and safely eject the TF card, and insert the TF card into the Raspberry Pi.
5. Power on the Raspberry Pi, it will display normally after a few seconds. It can be touched normally after the system starts.
Note: On December 2, 2021, the Raspberry Pi OS for Raspberry Pi split into two branches, the Buster branch, and the Bullseye branch.
The Buster branch is a continuation of the old system and is more stable. The Bullseye branch adds some new features and uses open-source libraries and new interfaces. The current Bullseye branch has just been released and is not very stable.
If you are an industrial user, the Buster branch is highly recommended.
If you use the Buster branch system, the image can be used normally without any modification. If you are using a system from the Bullseye branch, you also need to make the following modifications.
Comment the following statement in the config.txt file (the config file is located in the root directory of the TF card, namely /boot).
Add the following statement below [all]:
After saving, restart the Raspberry Pi
If you need to use the CSI camera under the Bullseye branch system. Since this branch uses the libcamera camera library by default, this library does not support FKMS drivers.
So in addition to the above modifications, you also need to install the Raspicam camera library.
The installation method is as follows:
Run the following command in the terminal:
cd ~ sudo apt install cmake git clone https://github.com/raspberrypi/userland cd userland ./buildme sudo cp build/bin/* /bin/
Then execute the following command to shut down:
Connect the Raspberry Pi camera to the CSI interface of the Raspberry Pi, power on the Raspberry Pi again, and after the system starts, execute the following commands:
raspistill -o image.jpg
raspivid -o video.h264 -t 10000
Enter the following command in the terminal to control the backlight brightness:
echo X > /sys/class/backlight/rpi_backlight/brightness
Where X represents any number from 0 to 255. 0 means the backlight is the darkest, and 255 means the backlight is the brightest. E.g:
echo 100 > /sys/class/backlight/rpi_backlight/brightness echo 0 > /sys/class/backlight/rpi_backlight/brightness echo 255 > /sys/class/backlight/rpi_backlight/brightness
In addition, Waveshare provides a corresponding application (this program is only for Raspberry Pi OS system), which users can download, install and use in the following ways:
wget https://www.waveshare.net/w/upload/3/39/Brightness.tar.gz tar -xzf Brightness.tar.gz cd brightness ./install.sh
After the installation is complete, you can open the program in the Start menu - "Accessories - "Brightness, as shown below:
Note: If it is 2021-10-30-raspios-bullseye-armhf and later systems, you need to add dtoverlay=rpi-backlight to config.txt
At the end of the config.txt file, add the following commands corresponding to disabling touch (the config file is located in the root directory of the TF card, and can also be accessed through the command: sudo nano /boot/config.txt):
To test the Raspberry Pi camera, you need to connect an HDMI screen or a DSI screen to the Raspberry Pi.
The packages of the CSI (camera) and DSI (display) interfaces on the Raspberry Pi motherboard are similar, so be careful not to connect them wrongly when wiring. (The CSI interface is between the audio interface and the HDMI interface).
Direct the metal side of the cable to the HDMI port and connect it to the camera port.
About the Model
|Photosensitive Chip Model||Raspberry Pi Motherboard||Driver Types|
|OV5647||All||libcamera / Raspicam|
|IMX219 (Raspberry Pi official）||All||libcamera / Raspicam|
|IMX219 (the third party)||Raspberry Pi Compute Module||libcamera|
|IMX477 (Raspberry Pi official)||All||libcamera / Raspicam|
|IMX477 (the third party)||Raspberry Pi Compute Module||libcamera|
Enable Camera Interface
If you are using the latest bullseye image, the camera interface has been enabled by default, and you can skip the modification steps.
- Open the Raspberry Pi terminal and use the command to enter the setting interface.
- Set up the camera.
Select Interface Options -> Camera -> Yes -> Finish -> Yes
- Reboot the Raspberry Pi.
Camera Testing (Bullseyes System)
If you use OV9281, IMX290, IMX378, or non-Raspberry Pi official IMX219 and IMX477 cameras, you need to configure the config.txt file separately.
sudo nano /boot/config.txt
Find the camera-auto-detect=1 statement and modify it to camera_auto_detect=0
At the end of the file, add the following setting statements according to the camera model.
Enable the Raspberry Pi terminal and the camera preview:
sudo libcamera-hello -t 0
If you want to close the preview window, you can directly combine the keys Alt-F4, or click x to close. You can also go back to the terminal interface and terminate the program with ctrl-c.
Camera Testing(Buster System)
Open the Raspberry Pi terminal and enable the camera preview:
sudo raspistill -t 0
If you want to close the preview window, you can terminate the program with ctrl-c.
After the Bullseye version of the Raspberry Pi image was released, the underlying Raspberry Pi driver was switched from Raspicam to libcamera. libcamera is an open-source software stack (or "driver"), which is convenient for the third-party porting and development of their own camera drivers. As of 2021-12-20, there are still many bugs in libcamra, and the current libcamera does not support python, so the Raspberry Pi official still provides a method for installing and downloading Raspicam. For users who are difficult to switch to libcamera but need to use the latest system, please move directly to the Raspicam instructions.
How to Call the Camera
The libcamera software stack provides six instructions for users to preview and test the camera interface.
This is a simple "hello word" program that previews the camera and displays the camera image on the screen.
This command will preview the camera on the screen for about 5 seconds. The user can use the -t <duration> parameter to set the preview time, where the unit of <duration> is milliseconds. If it is set to 0, it will keep previewing all the time. for example:
libcamerahello -t 0
The libcamera driver of the Raspberry Pi will call a tuning file for different camera modules. The tuning file provides various parameters. When calling the camera, the libcamera calls the parameters in the tuning file, and processes the image with the algorithm, and the final output is Preview screen.
Since the libcamera driver only can automatically receive the signal of the chip, the final display effect of the camera will also be affected by the entire module. The use of the tuning file is to flexibly handle the cameras in different modules and adjust to improve the image quality.
If the output image of the camera is not ideal when using the default tuning file, the user can adjust the image by calling the custom tuning file. For example, if you are using the official NOIR version of the camera, the NOIR camera may require different white balance parameters than the regular Raspberry Pi Camera V2. In this case, you can switch by calling the tuning file.
libcamera-hello --tuning-file /usr/share/libcamera/ipa/raspberrypi/imx219_noir.json
Users can copy the default tuning files and modify them according to their needs.
Note: The use of tuning files is applicable to other libcamera commands, and will not be introduced in subsequent commands.
Most libcamera commands will display a preview window on the screen. Users can customize the title information of the preview window through the --info-text parameter, and can also call some camera parameters through %directives and display them on the window.
For example, if you use HQ Camera: You can display the focal length of the camera on the window through --info-txe "%focus"
libcamera-hello --info-text "focus %focus"
Note: For more information on parameter settings, please refer to the following chapters on command parameter setting
libcamera-jpeg is a program for still shooting. Different from the complex functions of libcamera-still, libcamera-jpeg code is more concise and has more functions to complete shooting.
Take a full pixel JPEG image
libcamera-jpeg -o test.jpg
This shooting command will display a preview serial port for about 5 seconds, and then shoot a full-pixel JPEG image and save it as test.jpg
Users can set the preview time through the -t parameter, and can set the resolution of the captured image through --width and --height. E.g:
libcamera-jpeg -o test.jpg -t 2000 --width 640 --height 480
All libcamera commands allow the user to set the shutter time and gain themselves, such as:
libcamera-jpeg -o test.jpg -t 2000 --shutter 20000 --gain 1.5
This command will capture an image with 20ms exposure and camera gain set to 1.5x. The gain parameter set will first set the analog gain parameter inside the photosensitive chip. If the set gain exceeds the maximum built-in analog gain value of the driver, the maximum analog gain of the chip will be set first, and then the remaining gain multiples will be used as numbers. gain to take effect.
Remarks: The digital gain is realized by ISP (image signal processing), not directly adjusting the built-in register of the chip. Under normal circumstances, the default digital gain is close to 1.0, unless there are the following three situations.
1. The overall gain parameter requirements, that is, when the analog gain cannot meet the set gain parameter requirements, the digital gain will be required for compensation
2. One of the color gains is less than 1 (the color gain is achieved by digital gain), in this case, the final gain is stabilized at 1/min(red_gain, blue_gain), that is, a unified digital gain is actually applied, and is the gain value of one of the color channels (not the green channel).
3. AEC/AGC was modified. If there is a change in AEC/AGC, the numerical gain will also change to a certain extent, where does it come from to eliminate any fluctuations, but this change will be quickly restored to the "normal" value
The Raspberry Pi's AEC/AGX algorithm allows the program to specify exposure compensation, which is to adjust the brightness of the image by setting the aperture value. for example:
libcamera-jpeg --ev -0.5 -o darker.jpg libcamera-jpeg --ev 0 -o normal.jpg libcamera-jpeg --ev 0.5 -o brighter.jpg
libcamera-still and libcamera-jpeg are very similar, but the difference is that libcamera has more functions of raspistill. As before, the user can take a picture with the following command.
libcamera-still -o test.jpg
libcamea-still supports image files in different formats. It can support png and bmp, and it also supports saving binary dumps of RGB or YUV pixels as files without encoding or in any image format. If you save RGB or YUV data directly, the program must learn the pixel arrangement of the file when reading such files.
libcamera-still -e png -o test.png libcamera-still -e bmp -o test.bmp libcamera-still -e rgb -o test.data libcamera-still -e yuv420 -o test.data
Note: The format of image saving is controlled by the -e parameter. If the -e parameter is not called, it will be saved in the format of the output file name by default.
Raw Image Capture
The raw image is the output by the direct image sensor without any ISP or CPU processing. Generally, for color camera sensors, the output format of the raw image is Bayer. Note that the raw image is different from the bit-encoded RGB and YUV images we said earlier, and RGB and YUV are also ISP-processed images.
Instructions to take a raw image:
libcamera-still -r -o test.jpg
The original image is generally saved in DNG (Adobe digital Negative) format, which is compatible with most standard programs, such as dcraw or RawTherapee. The original image will be saved as a file with the same name with the .dng suffix, for example, if you run the above command , to be saved as test.dng, and generate a jpeg file at the same time. The DNG file contains metadata related to image acquisition, such as white balance data, ISP color matrix, etc. The following is the metadata encoding information displayed by the exiftool tool:
File Name : test.dng Directory : . File Size : 24 MB File Modification Date/Time : 2021:08:17 16:36:18+01:00 File Access Date/Time : 2021:08:17 16:36:18+01:00 File Inode Change Date/Time : 2021:08:17 16:36:18+01:00 File Permissions : rw-r--r-- File Type : DNG File Type Extension : dng MIME Type : image/x-adobe-dng Exif Byte Order : Little-endian (Intel, II) Make : Raspberry Pi Camera Model Name : /base/soc/i2c0mux/i2c@1/imx477@1a Orientation : Horizontal (normal) Software : libcamera-still Subfile Type : Full-resolution Image Image Width : 4056 Image Height : 3040 Bits Per Sample : 16 Compression : Uncompressed Photometric Interpretation : Color Filter Array Samples Per Pixel : 1 Planar Configuration : Chunky CFA Repeat Pattern Dim : 2 2 CFA Pattern 2 : 2 1 1 0 Black Level Repeat Dim : 2 2 Black Level : 256 256 256 256 White Level : 4095 DNG Version : 188.8.131.52 DNG Backward Version : 184.108.40.206 Unique Camera Model : /base/soc/i2c0mux/i2c@1/imx477@1a Color Matrix 1 : 0.8545269369 -0.2382823821 -0.09044229197 -0.1890484985 1.063961506 0.1062747385 -0.01334283455 0.1440163847 0.2593136724 As Shot Neutral : 0.4754476844 1 0.413686484 Calibration Illuminant 1 : D65 Strip Offsets : 0 Strip Byte Counts : 0 Exposure Time : 1/20 ISO : 400 CFA Pattern : [Blue,Green][Green,Red] Image Size : 4056x3040 Megapixels : 12.3 Shutter Speed : 1/20
Super Long Exposure
If we want to take a super long exposure picture, we need to disable AEC/AGC and white balance, otherwise, these algorithms will cause the picture to wait for a lot of frame data when it converges. Disabling these algorithms requires another explicit value to be set. Additionally, the user can skip the preview process with the --immediate setting.
Here is the instruction to take an image with a 100-second exposure:
libcamera-still -o long_exposure.jpg --shutter 100000000 --gain 1 --awbgains 1,1 --immediate
Remarks: Reference table for the longest exposure time of several official cameras.
|Module||Maximum Exposure Time (s)|
libcamera-vid is a demo for video recording that uses the Raspberry Pi hardware H.264 encoder by default. After the demo runs, a preview window will be displayed on the screen, and the bitstream encoding will be output to the specified file. For example, record a 10s video.
libcamera-vid -t 10000 -o test.h264
If you want to view the video, you can use vlc to play it.
Note: The recorded video stream is unpackaged. Users can use --save-pts to set the output timestamp to facilitate the subsequent conversion of the bit stream to other video formats.
libcamera-vid -o test.h264 --save-pts timestamps.txt
If you want to output the mkv file, you can use the following command:
mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264
Raspberry Pi supports JPEG format and YUV420 without compression and format:
libcamera-vid -t 10000 --codec mjpeg -o test.mjpeg libcamera-vid -t 10000 --codec yuv420 -o test.data
The --codec option sets the output format, not the output file extension.
Use the --segment parameter to split the output file into segments (unit is ms), which is suitable for JPEG files that need to split the JPEG video stream into separate JPEG files within a relatively short time (about 1 ms).
libcamera-vid -t 10000 --codec mjpeg --segment 1 -o test%05d.jpeg
libcamera-raw is similar to a video recording program. In different places, libcamera-raw records the Bayer format data output by the direct sensor, that is, the original image data. libcamera-raw doesn't show a preview window. For example, record a 2-second clip of raw data.
libcamera-raw -t 2000 -o test.raw
The program will directly dump the original frame without format information, the program will directly print the pixel format and image size on the terminal, and the user can view the pixel data according to the output data.
By default, the program will save the original frame as a file, the file is usually large, and the user can split the file by the --segement parameter.
libcamera-raw -t 2000 --segment 1 -o test%05d.raw
If the memory condition is better (such as using SSD), libcamera-raw can write the official HQ Camera data (about 18MB per frame) to the hard disk at a speed of about 10 frames per second. In order to achieve this speed, the program writes The ones are unformatted raw frames, there is no way to save as DNG files like libcamera-still does. If you want to ensure that there are no dropped frames, you can use --framerate to reduce the frame rate.
libcamera-raw -t 5000 --width 4056 --height 3040 -o test.raw --framerate 8
Common Command for Setting Options
Common command setting options can apply to all libcamera commands.
Print program helping information, you can print the available setting options for each program command, then exit.
Print the software version, print the software version of libcamera and libcamera-app, then exit.
The -t option sets the running time of the libcamera program. If the video recording command is run, the timeout option sets the recording time. If the image capture command is run, the timeout sets the preview time before the image is captured and output.
If the timeout is not set when running the libcamera program, the default timeout value is 5000 (5 seconds). If the timeout is set to 0, the program will continue to run.
Example: libcamera-hello -t 0
-p sets the size and position of the preview window (the qualified settings are valid in both X and DRM version windows), and the format is --preview <x. y, w, h> where x y set the coordinates of the preview window on the display, w, and h set the width and length of the preview window
The settings of the preview serial port will not affect the resolution and aspect ratio of the camera image preview. The program will scale the preview image to display in the preview window and adapt it according to the original image aspect ratio.
Example: libcamera-hello -p 100,100,500,500
The -f option sets the preview window full screen, the preview window, and the border in full-screen mode. Like -p, it does not affect the resolution and aspect ratio, and will automatically adapt.
Example: libcamera-still -f -o test.jpg
Using the preview window based on the QT framework, this setting is not recommended under normal circumstances, because the preview program will not use zero-copy buffer sharing and GPU acceleration, which will lead to high resource consumption. The QT preview window supports X forwarding (the default previewer does not).
The Qt preview serial port does not support the --fullscreen setting option. If the user wants to use the Qt preview, it is recommended to keep a small preview window to avoid excessive resource usage and affecting the normal operation of the system.
Example: libcamera-hello --qt-preview
Images are not previewed. This setting turns off the image preview feature.
Example: libcamera-hello -n
Set the title and information display of the preview window (only available in the X graphics window) using the format --info-text <string>. When calling this option, there are multiple parameters that can be set, and the parameters are usually called in the % command format. The program will call the corresponding value in the graphics metadata according to the instruction.
If no window info is specified, the default --info-text is set to "#%frame (%fps fps) exp %exp ag %ag dg %dg"
Example: libcamera-hello --info-test "Focus measure: %focus Available parameters:
|%frame||Frame Sequence Number|
|%fps||Frames Per Second|
|%exp||Shutter speed when capturing images unit: ms|
|%ag||Image analog gain controlled by the sensor chip|
|%dg||Image numerical gain controlled by ISP|
|%rg||Gain of red component per pixel|
|%bg||Gain of blue component per pixel|
|%focus||The corner point measurement of the image, the larger the value, the clearer the image|
These two parameters set the width and height of the image respectively. For libcamera-still, libcamera-jpeg and libcamera-vid commands, these two parameters can set the resolution of the output image/video.
If the libcamera-raw command is used, these two parameters affect the size of the obtained metadata frame. The camera has a 2x2 block reading mode. If the set resolution is smaller than the split mode, the camera will obtain the metadata frame according to the 2x2 block size.
libcamera-hello cannot specify resolution Example:
libcamera-vid -o test.h264 --width 1920 --height 1080 Record 1080p video
libcamera-still -r -o test.jpg --width 2028 --height 1520 Take a JPEG image with a resolution of 2028x1520.
This setting option is also used to set the resolution of the image, the difference is only the image size of the preview. It does not affect the final output image or video resolution. The size of the preview image will not affect the size of the preview window and will be adapted according to the window.
Example: libcamera-hello --viewfinder-width 640 --viewfinder-height 480
This setting forces the sensor to use the --width and --height settings to output still images and video in full-resolution read mode. This setting libcamera-hello has no effect.
With this setting, the framerate is sacrificed. In full-resolution mode, the speed for the reading frame will be slower.
Example: libcamera-raw -t 2000 --segment 1 --rawfull -o test%03d.raw
This command captures multiple frames of metadata in full-resolution mode. If you are using an HQ camera. The size of each frame is 18MB, and if --rawfull is not set, the HQ camera defaults to 2x2 mode, and the data size of each frame is only 4.5MB.
These two options set low-resolution images. The low-resolution data stream compresses the image, causing the aspect ratio of the image to change. When using libcamera-vid to record video, if a low resolution is set, functions such as color denoising will be disabled.
Example: libcamera-hello --lores-width 224 --lores-height 224 Note that low-resolution settings are usually used in conjunction with image postprocessing, otherwise they are not very useful.
--hflip #Flip the image horizontally --vflip #Flip the image vertically --rotation #Flip the image horizontally or vertically according to the given angle <angle>
These three options are used to flip the image. The --rotation parameter currently only supports 0 and 180, which is actually equivalent to --hflip and --vflip.
Example: libcamera-hello --vflip --hflip
--roi #crop image <x, y, w, h>
--roi allows the user to crop the image they want according to the coordinates from the complete image provided by the sensor, that is, digital scaling, paying attention to the coordinate value if it is in the valid range. For example --roi 0, 0, 1, 1 is an invalid instruction.
Example: libcamera-hello --roi 0.25,0.25,0.5,0.5 The example command will crop 1/4 of the image from the center of the image
--sharpness #Set the sharpness of the image <number>
Adjust the sharpness of the image by the value of <number>. If set to 0, no sharpening is applied. If you set a value above 1.0, an extra sharpening amount will be used.
Example: libcamera-still -o test.jpg --sharpness 2.0
--contrast #Set image contrast <number>
Example: libcamera-still -o test.jpg --contrast 1.5
--brightness #Set image brightness <number>
The setting range is -1.0 ~ 1.0
Example: libcamera-still -o test.jpg --brightness 0.2
--saturation #Set image color saturation <number>
Example: libcamera-still -o test.jpg --saturation 0.8
--ev #Set EV compensation <number>
Set the EV compensation of the image in aperture units, the setting range is -10 ~ 10, the default value is 0. The program works by improving the target method of the AEC/AGC algorithm.
Example: libcamera-still -o test.jpg --ev 0.3
--shutter #Set the exposure time, the unit is ms <number>
Note: If the frame rate of the camera is too fast, it may cause it to fail to work according to the set shutter time. If this happens, you can try to use --framerate to reduce the frame rate.
Example: libcamera-hello --shutter 30000
--gain #Set gain value (combination of numerical gain and analog gain) <number> --analoggain #--gain synonym
--analoggain is the same as --gain, the use of analoggain is only for compatibility with raspicam programs.
--metering #Set metering mode <string>
Set the metering mode of the AEC/AGC algorithm. The available parameters are:
- centre - Center metering (default)
- spot - spot metering
- averag - average or full frame metering
- custom - custom metering mode, can be set via tuning file
Example: libcamera-still -o test.jpg --metering spot
--exposure #set exposure profile <string>
The exposure mode can be set to normal or sport. The report profile for these two modes does not affect the overall exposure of the image, but in the case of sport mode, the program will shorten the exposure time and increase the justice to achieve the same exposure effect.
Example: libcamera-still -o test.jpg --exposure sport
--awb #Set white balance mode <string>
Available White Balance Modes:
|auto||2500K ~ 8000K|
|incadescent||2500K ~ 3000K|
|fluorescent||4000K ~ 4700K|
|indoor||3000K ~ 5000K|
|daylight||5500K ~ 6500 K|
|cloudy||7000K ~ 8500K|
|custom||Custom range, set via tuning file|
Example: libamera-still -o test.jpg --awb tungsten
--awbgains #Set a fixed color gain <number,number>
Set red and blue gain.
Example: libcamera-still -o test.jpg --awbgains 1.5, 2.0
--denoise #Set denoising mode <string>
Supported denoising modes:
- auto - default mode, use standard spatial denoising, if it is video, it will use fast color noise reduction and use high-quality color noise reduction when taking still pictures. The preview image will not use any color denoising.
- off - turns off spatial denoising and color denoising
- cdn_off - turn off color denoising
- cdn_fast - Use fast color denoising
- cdn_hq - Use high-quality color denoising, not suitable for video recording.
Example: libcamera-vid -o test.h264 --denoise cdn_off
--tuning-file #Specify camera tuning file <string>
For more tuning files, please refer to Official tutorial.
Example:libcamera-hello --tuning-file ~/my~camera-tuning.json
--output, -o #output filename <string>
Set the filename of the output image or video. In addition to setting the file name, you can also specify the output udp or tcp server address to output the image to the server. If you are interested, you can check the relevant setting instructions of the subsequent tcp and udp.
Example: libcamera-vid -t 100000 -o test.h264
--wrap #Wrap the output file counter <number>
Example: libcamera-vid -t 0 --codec mjpeg --segment 1 --wrap 100 -o image%d.jpg
-flush # Flush the output file immediately
--flush will immediately update each frame of the image to the hard disk at the same time as it is written, reducing latency.
Example: libcamera-vid -t 10000 --flush -o test.h264
Still picture shooting settings parameters
--quality, -q #Set JPEG image quality <0 ~ 100> --exif, -x #Add extra EXIF flags --timelapse #Time interval of time-lapse photography, the unit is ms --framestart #start value of frame count --datetime #name output file with date format --timestamp #name the output file with the system timestamp -- restart #Set the JPEG restart interval --keypress, -k # Set the enter button photo mode --signal, -s #Set the signal to trigger the photo --thumb #Set thumbnail parameters <w:h:q> --ebcoding, -e #Set the image encoding type. jpg/png/bmp/rgb/yuv420 --raw, -r #Save raw image --latest #Associate symbols to the latest saved file
Video recording image setting parameters
--quality, -q # Set JPEG commands <0 - 100> --bitrate, -b # Set H.264 bitrate --intra, -g #Set the internal frame period (only supports H.264) --profile #Set H.264 configuration --level #Set H.264 level --codec #Set encoding type h264 / mjpeg / yuv420 --keypress, -k #Set carriage return to pause and record --signal, -s #Set signal pause and record --initial #Start the program in the recording or paused state --split #Split video and save to another file --segment #Split video into multiple video segments --circular #Write video to circular buffer --inline #Write header in each I frame (H.264 only) --listen #Wait for a TCP connection
For more camera setting, please refer to Official camera documentation
- 4.3inch DSI LCD 3D Drawing
- RPi Camera Manual
- RPi Camera User Guides
- RPi HD Camera Instructions
- RPi HD Camera Dimensions
- C-Mount Camera Manual
- CS-Mount Camera User Guides
- FCC Authentication
- CE Authentication
The following opencv adjustment code is for reference only. (The code is shared by RPi Camera (G) users)
import picamera import picamera.array import cv2 from time import sleep import numpy as np def test_gcamera(): cv2.namedWindow("img",0) with picamera.PiCamera() as camera: camera.resolution = (1920, 1080) camera.awb_mode = 'off' rg, bg = (1.8, 1.4) camera.awb_gains = (rg, bg) with picamera.array.PiRGBArray(camera) as output: for foo in camera.capture_continuous(output, 'rgb', use_video_port=True): img = cv2.cvtColor(output.array, cv2.COLOR_RGB2BGR) cv2.imshow("img", img) cv2.waitKey(1) cv2.imwrite("test.jpg",img) r, g, b = (np.mean(output.array[..., i]) for i in range(3)) if abs(r - g) > 2: if r > g: rg -= 0.1 else: rg += 0.1 if abs(b - g) > 1: if b > g: bg -= 0.1 else: bg += 0.1 camera.awb_gains = (rg, bg) output.seek(0) output.truncate(0) if __name__=="__main__": test_gcamera()
Use 5V power supply Raspberry Pi 4B+4.3inch DSI LCD maximum brightness, normal working current is 700mA~750mA
Use 5V power supply Raspberry Pi 4B+4.3inch DSI LCD minimum brightness Normal working current is 550mA~580mA
As shown in the figure below, first remove the original soldered resistor, and then connect the pad (left pad) of the resistor to the P1 pin of the Raspberry Pi, and you can use GPIO to control the backlight.
- gpio -g pwm 18 0
- gpio -g mode 18 pwm (the occupied pins are PWM pins)
- gpio pwmc 1000
- Control brightness:
- gpio -g pwm 18 X (X is between 0 and 1024, 0 is the darkest, and 1024 is the brightest)
PS: In order to ensure a good customer experience, the default factory minimum brightness is the visible state. If you need to completely turn off the backlight to achieve a black screen effect, please manually change the 100K resistor as shown below to a 68K resistor: