Difference between revisions of "MV Camera Application Development Guide on Rochchip"

From wiki_veye
Jump to navigation Jump to search
Line 128: Line 128:
 
<code>export FPS=30</code>
 
<code>export FPS=30</code>
  
=== Configuring Formats with media-ctl ===
+
===Configuring Formats with media-ctl===
  
==== Viewing the Topology with <code>media-ctl</code> ====
+
====Viewing the Topology with <code>media-ctl</code>====
 
By using the "media-ctl" command, the current topology structure can be clearly displayed.
 
By using the "media-ctl" command, the current topology structure can be clearly displayed.
  
 
<code>media-ctl -p -d /dev/media0</code>
 
<code>media-ctl -p -d /dev/media0</code>
  
===== Link relationship =====
+
=====Link relationship=====
gx camera->rockchip-csi2-dphy0->rockchip-mipi-csi2->stream_cif_mipi_id0 - - ->DDR(/dev/video0)
+
mv camera->rockchip-csi2-dphy0->rockchip-mipi-csi2->stream_cif_mipi_id0 - - ->DDR(/dev/video0)
  
 +
===== mv camera entity information =====
 +
Take GX-MIPI-IMX662 as an example:
  
 +
<code>- entity 63: m00_b_mvcam 7-003b (1 pad, 1 link)</code>
  
 +
<code>             type V4L2 subdev subtype Sensor flags 0</code>
 +
 +
<code>             device node name /dev/v4l-subdev2</code>
 +
 +
<code>        pad0: Source</code>
 +
 +
<code>                [fmt:Y8_1X8/1920x1200@100/6000 field:none</code>
 +
 +
<code>                 crop.bounds:(0,0)/1920x1200</code>
 +
 +
<code>                 crop:(0,0)/1920x1200]</code>
 +
 +
<code>                -> "rockchip-csi2-dphy0":0 [ENABLED]</code>
 +
 +
It can be seen that:
 +
 +
* The complete name of this Entity is: m00_b_mvcam 7-003b. (On the ROC-RK3566-PC, the name of this Entity is m00_b_mvcam 4-003b).
 +
* It is a V4L2 subdev (Sub-Device) sensor.
 +
* The corresponding node is /dev/v4l-subdev2. The application (such as v4l2-ctl) can open it and make configurations.
 +
* Its output format is [<code>fmt:Y8_1X8/1920x1200@100/6000 field:none</code>], where <code>Y8_1X8</code> is a shortened form of an mbus-code. The supported mbus-codes will be listed in the next section.
 +
* The current resolution is <code>1920x1200</code>.
 +
* The current frame interval is <code>10000/600000</code>, which means the frame rate is 60.
 +
 +
The data format output by the camera can be modified through the "media-ctl" command.
 +
 +
==== Camera-supported MBUS code ====
 +
The MV/RAW series cameras utilize the data format capability. For details, please refer to the data manuals of each model of the cameras.
 +
{| class="wikitable"
 +
|+Format correspondence relationship
 +
!Format on datasheet
 +
!mbus-code for media-ctl
 +
!FourCC pixelformat for v4l2-ctl
 +
|-
 +
|RAW8
 +
|Y8_1X8
 +
|GREY
 +
|-
 +
|RAW10
 +
|Y10_1X10
 +
|'Y10 '
 +
|-
 +
|RAW12
 +
|Y12_1X12
 +
|'Y12 '
 +
|-
 +
|UYVY
 +
|UYVY8_2X8
 +
|UYVY
 +
|}
 
<br />
 
<br />

Revision as of 11:12, 26 December 2025

查看中文

Application Layer Usage and Development Guide for MV/RAW Series Camera Modules on the Rockchip Platform

1 Overview

This document applies to scenarios where the camera hardware is correctly connected, the driver is properly installed, and the MV/RAW series camera has been successfully recognized.

The main objectives of this guide are to:

  • Query the device information of the connected MV/RAW series camera
  • Configure and prepare the camera operating modes
  • Introduce several methods for previewing and capturing images
  • Explain camera parameter configuration
  • Provide guidance for customer-specific development

On the Rockchip platform, regardless of the method used to access the camera, it is necessary to complete device detection and media-ctl configuration before performing any further operations. Therefore, the following sections first cover device detection and media-ctl setup.

2 Device Detection and Environment Configuration

Here, we provide two scripts that can automatically retrieve key information about the connected camera.

2.1 probe_camera_info-rk.sh

This script is used to probe connected and successfully registered camera devices, retrieving underlying information such as the corresponding media device node, video device node, sub-device node, I²C bus, and device name.

After execution, an auto_camera_index.json file will be generated in the current directory, containing the retrieved information.

Example usage:

$ ./probe_camera_info-rk.sh

cat auto_camera_index.json

[

  {

    "media_node": "/dev/media0",

    "video_node": "/dev/video0",

    "video_subnode": "/dev/v4l-subdev2",

    "media_entity_name": "m00_b_mvcam 7-003b",

    "i2c_bus": "7"

  }

]

Each {} block represents a single camera. If the board supports multiple camera modules, multiple {} blocks will be present in the file.

Explanation of Camera Information:

Camera Information
Field Name Purpose Usage
media_node Media device node Used to access the device within the media-controller framework Used when configuring resolution and format via the media-ctl command
video_node Video capture device node Standard V4L2 video device Used with v4l2-ctl or customer applications to capture images
video_subnode V4L2 sub-device node Used for configuring certain camera parameters Accessed via v4l2-ctl commands
media_entity_name Media entity name Describes the device, e.g., "m00_b_mvcam 7-003b" Used when setting resolution and format with media-ctl
i2c_bus I²C bus Indicates the I²C bus to which the device is connected Used as the underlying communication channel for camera parameter configuration, e.g., by the mv_mipi_i2c.sh script

The media device node, video device node, sub-device node, I²C bus, and device name used in the following sections can all be replaced with the corresponding information obtained from the JSON file generated by this probe script.

2.2 mv_probe.sh

The mv_probe.sh script can configure environment variables with key information for a specific camera, including the I²C bus number, camera model, resolution (width and height), and frame rate. This simplifies subsequent use of media-ctl for format configuration.

The usage method is:

$ source ./mv_probe.sh <i2c_bus>

Example:

$ source ./mv_probe.sh 7

Found veye_mvcam camera on i2c-7.

Setenv I2C_BUS = 7

Setenv CAMERAMODEL = MV-MIPI-AR0234M

Setenv FPS = 60

Setenv WIDTH = 1920

Setenv HEIGHT = 1200

You can verify the environment variable output using:

echo $CAMERAMODEL

Note that these environment variables are only valid for the current session.

Important Notes:

  • This script requires the mvcam driver version 1.1.06 or later.
  • If your driver version is earlier than 1.1.06 or you need to use different width, height, or frame rate values, refer to the camera module manual and manually configure the following environment variables. Otherwise, subsequent programs may not function correctly.

Example:

export WIDTH=1920

export HEIGHT=1200

export FPS=30

3 Configuring Formats with media-ctl

3.1 Viewing the Topology with media-ctl

By using the "media-ctl" command, the current topology structure can be clearly displayed.

media-ctl -p -d /dev/media0

3.1.1 Link relationship

mv camera->rockchip-csi2-dphy0->rockchip-mipi-csi2->stream_cif_mipi_id0 - - ->DDR(/dev/video0)

3.1.2 mv camera entity information

Take GX-MIPI-IMX662 as an example:

- entity 63: m00_b_mvcam 7-003b (1 pad, 1 link)

             type V4L2 subdev subtype Sensor flags 0

             device node name /dev/v4l-subdev2

        pad0: Source

                [fmt:Y8_1X8/1920x1200@100/6000 field:none

                 crop.bounds:(0,0)/1920x1200

                 crop:(0,0)/1920x1200]

                -> "rockchip-csi2-dphy0":0 [ENABLED]

It can be seen that:

  • The complete name of this Entity is: m00_b_mvcam 7-003b. (On the ROC-RK3566-PC, the name of this Entity is m00_b_mvcam 4-003b).
  • It is a V4L2 subdev (Sub-Device) sensor.
  • The corresponding node is /dev/v4l-subdev2. The application (such as v4l2-ctl) can open it and make configurations.
  • Its output format is [fmt:Y8_1X8/1920x1200@100/6000 field:none], where Y8_1X8 is a shortened form of an mbus-code. The supported mbus-codes will be listed in the next section.
  • The current resolution is 1920x1200.
  • The current frame interval is 10000/600000, which means the frame rate is 60.

The data format output by the camera can be modified through the "media-ctl" command.

3.2 Camera-supported MBUS code

The MV/RAW series cameras utilize the data format capability. For details, please refer to the data manuals of each model of the cameras.

Format correspondence relationship
Format on datasheet mbus-code for media-ctl FourCC pixelformat for v4l2-ctl
RAW8 Y8_1X8 GREY
RAW10 Y10_1X10 'Y10 '
RAW12 Y12_1X12 'Y12 '
UYVY UYVY8_2X8 UYVY