1.Introduction
This Arducam Camarray HAT (supports four inputs) is an upgraded version of the Arducam synchronous stereo camera HAT (supports two inputs). This quad-camera bundle kit aggregates four OV9782 color cameras into one video stream, compared to its counterpart OV9282 monochrome quad-camera bundle kit. So that it is completely synchronized, the output is a standard MIPI CSI-2 interface, which can be connected to Raspberry Pi, Jetson Nano, Jetsno NX, and other platforms.
This document is compatible with Jetson Nano and Xavier NX platforms(Collectively referred to as Jetson in the document), the operation is similar, only the driver package is different.

2.Hardware
Connect the hardware according to the figure below (refer to the four-camera OV9281 in the picture below, only the camera is different).

The HAT can be plugged into the Jetson and powered by a 2×3 row of female sockets through its 2×20 GPIO pin header.
3.Software
3.1 Driver installation
3.1.1 Understanding Different Camera Drivers
There are potentially three camera drivers you may come across on the Jetson boards, the official IMX219 driver, the Arducam IMX477 driver, and the Arducam V4L2 Jetvariety driver.
These three drivers conflict with each other, only one of the three can be enabled at a time according to the corresponding camera used.
- No matter what kind of driver is installed earlier, when installing the Arducam IMX477 driver or Arducam V4L2 Jetvariety driver, the other two drivers will be automatically overwritten (no need to uninstall first).
- If you want to use the official driver (for IMX219), you need to uninstall the Arducam IMX477 driver or Arducam V4L2 Jetvariety driver first. The uninstallation commands for these two drivers are the same (sudo dpkg -r arducam-nvidia-l4t-kernel).
- The process of installing the Arducam IMX477 driver and Arducam V4L2 Jetvariety driver is the same, but the driver package (.deb) is different.
Note
For this product we should use Arducam V4L2 Jetvariety camera driver.
3.1.2.Identify the Camera Driver Installed
So how to determine which driver is currently installed?
Execute the following command to see if there is a response. No response, indicating that the corresponding driver is not installed.
dmesg | grep imx219 dmesg | grep imx477 dmesg | grep arducam
imx219 represents the official driver (IMX219);
imx477 stands for Arducam IMX477 driver
Arducam stands for Arducam V4L2 Jetvariety driver.
3.1.3 Install Arducam V4L2 Jetvariety driver
No matter which driver is installed earlier, the other two drivers will be automatically overwritten after the Arducam V4L2 Jetvariety driver is installed.
Refer to this link to install.

- install driver
cd ~ wget https://github.com/ArduCAM/MIPI_Camera/releases/download/v0.0.3/install_full.sh
chmod +x install_full.sh ./install_full.sh -m arducam
Enter y to reboot.

- Install V4L-utils package
sudo apt-get install v4l-utils

3.2.Display image via Python
3.2.1.Install V4L2 python module
for Python3.x:
wget https://bootstrap.pypa.io/get-pip.py

sudo python3 get-pip.py
It’s a long time here, it takes a few minutes.


sudo pip3 install v4l2-fix
The V4L2 of Python3.x has a known bug that requires a manual fix, and the following error occurs when you import the v4l2 module into Python3.x:
You can refer to this link to fix this bug.
3.2.2. Download the demo code
git clone https://github.com/ArduCAM/MIPI_Camera.git


3.2.3.Check whether the camera is detected
ls /dev/video0

3.2.4.Check the video format supported
v4l2-ctl --list-formats-ext

3.2.5.Real-time display of images
If you are accessing Jetson through remote software (such as MobaXterm),

You need to execute the following command (executed only once) to display the image on Jetson.
export DISPLAY=:0.0

Enter the program directory
cd MIPI_Camera/Jetson/Jetvariety/example/

The image display commands currently supported by the four-camera OV9782 are as follows:
#RAW8
python3 arducam_displayer.py -f RGGB --width 5120 --height 800 -d 0 --fps
#RAW10
python3 arducam_displayer.py -f Y16 --width 5120 --height 800 -d 0 --fps
RGGB means RAW8, Y16 means RAW10;
-width and -height respectively represent the width and height of the input image;
–fps means to display the current frame number. When you don’t want to display the number of frames, you can remove the command parameter.
Take RAW8 5120×800 as an example, execute the command:
python3 arducam_displayer.py -f RGGB --width 5120 --height 800 -d 0 --fps


Enter Ctrl+C to exit the image display.
Python display resolution settings may affect the number of display frames.
Select Arducam/arducam_displayer.py, right-click and select open with Text Editor,
The value in the figure below represents the number of frames of the display resolution. If the display is dropped, try changing the value to a smaller value.
3.2.6.Only receive data without display
Even if the display resolution is changed to a smaller size, the display may still drop frames due to the performance of the platform.
You can test the actual number of input image frames by only receiving data without displaying images.
The commands that only receive data but do not display are as follows:
#RAW8
v4l2-ctl --set-fmt-video=width=2560,height=800,pixelformat='RGGB' --stream-mmap --stream-count=-1 -d /dev/video0
#RAW10
v4l2-ctl --set-fmt-video=width=2560,height=800,pixelformat='Y16 ' --stream-mmap --stream-count=-1 -d /dev/video0

3.2.7.Adjust exposure
Operation method:
Open two command windows at the same time, the first window executes the image display command, and the second window executes the adjust exposure command.
The commands for adjusting the exposure are:
v4l2-ctl -c exposure=1000
The command to view the exposure parameters (minimum, maximum, default) is:
v4l2-ctl -l

For example, execute the command in the second window:
v4l2-ctl -c exposure=2000
Increase the exposure time, and the result will be brighter and the frame rate will drop.



3.2.8.Adjust the gain
Operation method:
Open two command windows at the same time, the first window executes the image display command, and the second window executes the adjustment gain command.
The command to adjust the gain is:
v4l2-ctl -c gain=12
The command to view gain parameters (minimum, maximum, default) is:
v4l2-ctl -l

For example, execute the command in the second window:
v4l2-ctl -c gain=12
Increase the gain, and the resultant picture will become brighter, and the frame rate will not change.



3.2.9.Adjust the frame rate
Operation method:
Open two command windows at the same time, the first window executes the image display command, and the second window executes the frame rate adjustment command.
The command to adjust the frame rate is:
v4l2-ctl -c frame_rate=10
frame_rate=X, X is the set number of frames.
For example, execute the command in the first window:
python3 arducam_displayer.py -f RGGB --width 5120 --height 800 -d 0 --fps

The last line displays the current frame rate in real time.
Then execute the command in the second window:
v4l2-ctl -c frame_rate=10
The last line displays the current frame rate in real time.
Then execute the command in the second window:
v4l2-ctl -c frame_rate=10


Then the frame rate display of the first window will change to 30fps.
In the second window, execute the following command to view the frame rate range of the current display mode:
v4l2-ctl -l

If the set frame rate exceeds the maximum value, it will work according to the maximum value. The same goes for the minimum value.