Welcome to RDK X5 Robot repository
1. Camera driver
Camera driver
Camera driver1.1 Introduction1.2 Core content analysis1.3 Mipi_Camera API interface1.3 Operation steps
1.1 Introduction
This course mainly uses the IMX219 camera to obtain the camera image and display it on the jupyterlab control.
To use the IMX219 camera, you need to import the Mipi_Camera library. This file has been integrated into the SunriseRobotLib library. As long as the SunriseRobotLib library is installed, you can import Mipi_Camera to drive the camera.
1.2 Core content analysis
Import the Mipi_Camera library from SunriseRobotLib, and then print the relevant API functions.
xxxxxxxxxxfrom SunriseRobotLib import Mipi_Camerahelp(Mipi_Camera)
Create a Mipi_Camera object and set the camera resolution to 320*240. The g_camera.isOpened function returns the camera status, True if it is successfully opened, and False if it fails to open.
xxxxxxxxxxwidth=320height=240g_camera = Mipi_Camera(width, height, debug=True)if g_camera.isOpened():print("Open Camera OK")else:print("Fail To Open Camera")
Read a frame of the camera, ret=True if the read is successful, ret=False if the read fails, frame represents the current read image.
xxxxxxxxxxret, frame = g_camera.read()
If it is not needed, please release the camera to avoid errors caused by other routines accessing the camera at the same time.
xxxxxxxxxxg_camera.release()
1.3 Mipi_Camera API interface
xxxxxxxxxxclass Mipi_Camera(builtins.object)| Mipi_Camera(width=320, height=240, debug=False)|| # V2.0.1|| Methods defined here:|| __del__(self)|| __init__(self, width=320, height=240, debug=False)| Initialize self. See help(type(self)) for accurate signature.|| get_frame(self)| # Gets a frame of the camera|| get_frame_jpg(self, text='', color=(0, 255, 0))| # Gets the JPG image of the camera|| isOpened(self)| # Check whether the camera is enabled successfully|| read(self)| # Gets a frame of the camera|| release(self)| # Release the camera device bus| # Release the camera
1.3 Operation steps
Open the jupyterLab client (the system automatically starts jupyter lab, you only need to access the car IP: 8888 in the browser to access it), find the code path:
xxxxxxxxxx/home/sunrise/sunriseRobot/Samples/2_AI/01_camera/camera.ipynb
Click to run all cells, then pull to the bottom to see the generated controls.


The program will continue to capture the camera's image and update it to the image control.
When you need to end the camera, click the stop button to stop and release the camera.
