maix.camera
maix.camera module, access camera device and get image from it
You can use
maix.camerato access this module with MaixPy
This module is generated from MaixCDK
Module
No module
Enum
Variable
Function
list_devices
| item | doc |
|---|---|
| brief | List all supported camera devices. |
| return | Returns the path to the camera device. |
C++ defination code:
std::vector<std::string> list_devices()
set_regs_enable
| item | doc |
|---|---|
| brief | 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. |
| param | enable: enable/disable set camera registers |
C++ defination code:
void set_regs_enable(bool enable = true)
Class
Camera
| item | doc |
|---|---|
| brief | Camera class |
C++ defination code:
class Camera
__init__
def __init__(self, width: int = -1, height: int = -1, format: maix.image.Format = ..., device: str = None, fps: int = -1, buff_num: int = 3, open: bool = True) -> None
| item | doc |
|---|---|
| type | func |
| brief | Construct a new Camera object |
| 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. |
| static | False |
C++ defination code:
Camera(int width = -1, int height = -1, image::Format format = image::FMT_RGB888, const char *device = nullptr, int fps = -1, int buff_num = 3, bool open = true)
get_ch_nums
def get_ch_nums(self) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get the number of channels supported by the camera. |
| return | Returns the maximum number of channels. |
| static | False |
C++ defination code:
int get_ch_nums()
open
def open(self, width: int = -1, height: int = -1, format: maix.image.Format = ..., fps: int = -1, buff_num: int = -1) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Open camera and run |
| 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, int fps = -1, int buff_num = -1)
read
def read(self, buff: capsule = None, buff_size: int = 0, block: bool = True) -> maix.image.Image
| item | doc |
|---|---|
| type | func |
| brief | 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. |
| 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 |
| 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)
clear_buff
def clear_buff(self) -> None
| item | doc |
|---|---|
| type | func |
| brief | Clear buff to ensure the next read image is the latest image |
| static | False |
C++ defination code:
void clear_buff()
skip_frames
def skip_frames(self, num: int) -> None
| item | doc |
|---|---|
| type | func |
| brief | Read some frames and drop, this is usually used avoid read not stable image when camera just opened. |
| param | num: number of frames to read and drop |
| static | False |
C++ defination code:
void skip_frames(int num)
close
def close(self) -> None
| item | doc |
|---|---|
| type | func |
| brief | Close camera |
| static | False |
C++ defination code:
void close()
add_channel
def add_channel(self, width: int = -1, height: int = -1, format: maix.image.Format = ..., fps: int = -1, buff_num: int = 3, open: bool = True) -> Camera
| item | doc |
|---|---|
| type | func |
| brief | Add a new channel and return a new Camera object, you can use close() to close this channel. |
| 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, int fps = -1, int buff_num = 3, bool open = true)
is_opened
def is_opened(self) -> bool
| item | doc |
|---|---|
| type | func |
| brief | Check if camera is opened |
| return | true if camera is opened, false if not |
| static | False |
C++ defination code:
bool is_opened()
is_closed
def is_closed(self) -> bool
| item | doc |
|---|---|
| type | func |
| brief | check camera device is closed or not |
| return | closed or not, bool type |
| static | False |
C++ defination code:
bool is_closed()
width
def width(self) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera width |
| return | camera width |
| static | False |
C++ defination code:
int width()
height
def height(self) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera height |
| return | camera height |
| static | False |
C++ defination code:
int height()
fps
def fps(self) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera fps |
| return | camera fps |
| static | False |
C++ defination code:
int fps()
format
def format(self) -> maix.image.Format
| item | doc |
|---|---|
| type | func |
| brief | Get camera output format |
| return | camera output format, image::Format object |
| static | False |
C++ defination code:
image::Format format()
buff_num
def buff_num(self) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera buffer number |
| return | camera buffer number |
| static | False |
C++ defination code:
int buff_num()
hmirror
def hmirror(self, value: int = -1) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera horizontal mirror |
| return | camera horizontal mirror |
| static | False |
C++ defination code:
int hmirror(int value = -1)
vflip
def vflip(self, value: int = -1) -> int
| item | doc |
|---|---|
| type | func |
| brief | Get camera vertical flip |
| return | camera vertical flip |
| static | False |
C++ defination code:
int vflip(int value = -1)
exposure
def exposure(self, value: int = -1) -> float
| item | doc |
|---|---|
| type | func |
| brief | Get camera exposure |
| return | camera exposure |
| static | False |
C++ defination code:
float exposure(int value = -1)
gain
def gain(self, value: int = -1) -> float
| item | doc |
|---|---|
| type | func |
| brief | Get camera gain |
| return | camera gain |
| static | False |
C++ defination code:
float gain(int value = -1)
device
def device(self) -> str
| item | doc |
|---|---|
| type | func |
| brief | Get camera device path |
| return | camera device path |
| static | False |
C++ defination code:
std::string device()
write_reg
def write_reg(self, addr: int, data: int, bit_width: int = 8) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Write camera register |
| 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
def read_reg(self, addr: int, bit_width: int = 8) -> int
| item | doc |
|---|---|
| type | func |
| brief | Read camera register |
| 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
def show_colorbar(self, enable: bool) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Camera output color bar image for test |
| 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
| item | doc |
|---|---|
| type | func |
| brief | Get channel of camera |
| return | channel number |
| static | False |
C++ defination code:
int get_channel()
set_resolution
def set_resolution(self, width: int, height: int) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera resolution |
| param | width: new width height: new height |
| static | False |
C++ defination code:
err::Err set_resolution(int width, int height)
set_hmirror
def set_hmirror(self, en: bool) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera mirror |
| param | en: enable/disable mirror |
| static | False |
C++ defination code:
err::Err set_hmirror(bool en)
set_vflip
def set_vflip(self, en: bool) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera flip |
| param | en: enable/disable flip |
| static | False |
C++ defination code:
err::Err set_vflip(bool en)
set_luma
def set_luma(self, value: int) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera constrast |
| param | int: constrast value |
| static | False |
C++ defination code:
err::Err set_luma(int value)
set_constrast
def set_constrast(self, value: int) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera constrast |
| param | int: constrast value |
| static | False |
C++ defination code:
err::Err set_constrast(int value)
set_saturation
def set_saturation(self, value: int) -> maix.err.Err
| item | doc |
|---|---|
| type | func |
| brief | Set camera saturation |
| param | int: saturation value |
| static | False |
C++ defination code:
err::Err set_saturation(int value)