maix::camera

maix.camera module, access camera device and get image from it

This is maix::camera module of MaixCDK.
All of these elements are in namespace maix::camera.

For MaixCDK developer: DO NOT edit this doc file manually, this doc is auto generated!

Module

No module

Enum

Variable

Function

list_devices

List all supported camera devices.

item description
return Returns the path to the camera device.

C++ defination code:

std::vector<std::string> list_devices()

set_regs_enable

Enable set camera registers, default is false, if set to true, will not set camera registers, you can manually set registers by write_reg API.

item description
param enable: enable/disable set camera registers

C++ defination code:

void set_regs_enable(bool enable = true)

get_device_name

Get device name. Most of the time, the returned name is the name of the sensor.

C++ defination code:

std::string get_device_name()

Class

Camera

Camera class

C++ defination code:

class Camera

Camera

Construct a new Camera object.\nMaximum resolution support 2560x1440.

item description
type func
param width: camera width, default is -1, means auto, mostly means max width of camera support
height: camera height, default is -1, means auto, mostly means max height of camera support
format: camera output format, default is image.Format.FMT_RGB888
device: camera device path, you can get devices by list_devices method, by default(value is NULL(None in MaixPy)) means the first device
fps: camera fps, default is -1, means auto, mostly means max fps of camera support
buff_num: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
open: If true, camera will automatically call open() after creation. default is true.
raw: If true, you can use read_raw() to capture the raw image output from the sensor.
static False

C++ defination code:

Camera(int width = -1, int height = -1, image::Format format = image::FMT_RGB888, const char *device = nullptr, double fps = -1, int buff_num = 3, bool open = true, bool raw = false)

get_ch_nums

Get the number of channels supported by the camera.

item description
type func
return Returns the maximum number of channels.
static False

C++ defination code:

int get_ch_nums()

open

Open camera and run

item description
type func
param width: camera width, default is -1, means auto, mostly means max width of camera support
height: camera height, default is -1, means auto, mostly means max height of camera support
format: camera output format, default same as the constructor's format argument
fps: camera fps, default is -1, means auto, mostly means max fps of camera support
buff_num: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err open(int width = -1, int height = -1, image::Format format = image::FMT_INVALID, double fps = -1, int buff_num = -1)

read

Get one frame image from camera buffer, must call open method before read.\nIf open method not called, will call it automatically, if open failed, will throw exception!\nSo call open method before read is recommended.

item description
type func
param buff: buffer to store image data, if buff is nullptr, will alloc memory automatically.
In MaixPy, default to None, you can create a image.Image object, then pass img.data() to buff.
block: block read, default is true, means block util read image successfully,
if set to false, will return nullptr if no image in buffer
block_ms: block read timeout
return image::Image object, if failed, return nullptr, you should delete if manually in C++
static False

C++ defination code:

image::Image *read(void *buff = nullptr, size_t buff_size = 0, bool block = true, int block_ms = -1)

read_raw

Read the raw image and obtain the width, height, and format of the raw image through the returned Image object.

item description
type func
note The raw image is in a Bayer format, and its width and height are affected by the driver. Modifying the size and format is generally not allowed.
return image::Image object, if failed, return nullptr, you should delete if manually in C++
static False

C++ defination code:

image::Image *read_raw()

clear_buff

Clear buff to ensure the next read image is the latest image

item description
type func
static False

C++ defination code:

void clear_buff()

skip_frames

Read some frames and drop, this is usually used avoid read not stable image when camera just opened.

item description
type func
param num: number of frames to read and drop
static False

C++ defination code:

void skip_frames(int num)

close

Close camera

item description
type func
static False

C++ defination code:

void close()

add_channel

Add a new channel and return a new Camera object, you can use close() to close this channel.

item description
type func
param width: camera width, default is -1, means auto, mostly means max width of camera support
height: camera height, default is -1, means auto, mostly means max height of camera support
format: camera output format, default is RGB888
fps: camera fps, default is -1, means auto, mostly means max fps of camera support
buff_num: camera buffer number, default is 3, means 3 buffer, one used by user, one used for cache the next frame,
more than one buffer will accelerate image read speed, but will cost more memory.
open: If true, camera will automatically call open() after creation. default is true.
return new Camera object
static False

C++ defination code:

camera::Camera *add_channel(int width = -1, int height = -1, image::Format format = image::FMT_RGB888, double fps = -1, int buff_num = 3, bool open = true)

is_opened

Check if camera is opened

item description
type func
return true if camera is opened, false if not
static False

C++ defination code:

bool is_opened()

is_closed

check camera device is closed or not

item description
type func
return closed or not, bool type
static False

C++ defination code:

bool is_closed()

width

Get camera width

item description
type func
return camera width
static False

C++ defination code:

int width()

height

Get camera height

item description
type func
return camera height
static False

C++ defination code:

int height()

fps

Get camera fps

item description
type func
return camera fps
static False

C++ defination code:

double fps()

format

Get camera output format

item description
type func
return camera output format, image::Format object
static False

C++ defination code:

image::Format format()

buff_num

Get camera buffer number

item description
type func
return camera buffer number
static False

C++ defination code:

int buff_num()

hmirror

Set/Get camera horizontal mirror

item description
type func
return camera horizontal mirror
static False

C++ defination code:

int hmirror(int value = -1)

vflip

Set/Get camera vertical flip

item description
type func
return camera vertical flip
static False

C++ defination code:

int vflip(int value = -1)

device

Get camera device path

item description
type func
return camera device path
static False

C++ defination code:

std::string device()

write_reg

Write camera register

item description
type func
param addr: register address
data: register data
bit_width: register data bit width, default is 8
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err write_reg(int addr, int data, int bit_width = 8)

read_reg

Read camera register

item description
type func
param addr: register address
bit_width: register data bit width, default is 8
return register data, -1 means failed
static False

C++ defination code:

int read_reg(int addr, int bit_width = 8)

show_colorbar

Camera output color bar image for test

item description
type func
param enable: enable/disable color bar
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err show_colorbar(bool enable)

get_channel

Get channel of camera

item description
type func
return channel number
static False

C++ defination code:

int get_channel()

set_resolution

Set camera resolution

item description
type func
param width: new width
height: new height
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err set_resolution(int width, int height)

set_fps

Set camera fps

item description
type func
param fps: new fps
return error code, err::ERR_NONE means success, others means failed
static False

C++ defination code:

err::Err set_fps(double fps)

exposure

Set/Get camera exposure

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: exposure time. unit: us
If value == -1, return exposure time.
If value != 0, set and return exposure time.
return camera exposure time
static False

C++ defination code:

int exposure(int value = -1)

gain

Set/Get camera gain

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: camera gain.
If value == -1, returns camera gain.
If value != 0, set and return camera gain.
return camera gain
static False

C++ defination code:

int gain(int value = -1)

luma

Set/Get camera luma

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: luma value, range is [0, 100]
If value == -1, returns luma value.
If value != 0, set and return luma value.
return returns luma value
static False

C++ defination code:

int luma(int value = -1)

constrast

Set/Get camera constrast

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: constrast value, range is [0, 100]
If value == -1, returns constrast value.
If value != 0, set and return constrast value.
return returns constrast value
static False

C++ defination code:

int constrast(int value = -1)

saturation

Set/Get camera saturation

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: saturation value, range is [0, 100]
If value == -1, returns saturation value.
If value != 0, set and return saturation value.
return returns saturation value
static False

C++ defination code:

int saturation(int value = -1)

awb_mode

Set/Get white balance mode (deprecated interface)

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
This interface may be deprecated in the future, and there may be incompatibilities in the definition of the parameters of the new interface
param value: value = 0, means set white balance to auto mode, value = 1, means set white balance to manual mode, default is auto mode.
return returns awb mode
static False

C++ defination code:

int awb_mode(int value = -1)

set_awb

Set/Get white balance mode

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
param value: value = 0, means set white balance to manual mode, value = 1, means set white balance to auto mode, default is auto mode.
return returns awb mode
static False

C++ defination code:

int set_awb(int mode = -1)

exp_mode

Set/Get exposure mode (deprecated interface)

item description
type func
attention This method will affect the isp and thus the image, so please be careful with it.
This interface may be deprecated in the future, and there may be incompatibilities in the definition of the parameters of the new interface
param value: value = 0, means set exposure to auto mode, value = 1, means set exposure to manual mode, default is auto mode.
return returns exposure mode
static False

C++ defination code:

int exp_mode(int value = -1)

set_windowing

Set window size of camera

item description
type func
param roi: Support two input formats, [x,y,w,h] set the coordinates and size of the window;
[w,h] set the size of the window, when the window is centred.
return error code
static False

C++ defination code:

err::Err set_windowing(std::vector<int> roi)