luat_soc_sdk_2024 V1.0
luat_camera.h
浏览该文件的文档.
1/******************************************************************************
2 * CAMERA设备操作抽象层
3 * @author Dozingfiretruck
4 * @since 0.0.1
5 *****************************************************************************/
6#ifndef Luat_CAMERA_H
7#define Luat_CAMERA_H
8
9#include "luat_base.h"
10#ifdef __LUATOS__
11#include "luat_lcd.h"
12#endif
17enum
18{
23
26};
27
28typedef struct luat_camera_conf
29{
30 uint8_t id;
31 uint8_t zbar_scan;
32 uint8_t draw_lcd;
33 uint8_t i2c_id;
34 uint8_t i2c_addr;
35 uint8_t pwm_id;
36 size_t pwm_period;
37 uint8_t pwm_pulse;
38 uint16_t sensor_width;
39 uint16_t sensor_height;
40 uint8_t color_bit;
41 uint8_t id_reg;
42 uint8_t id_value;
44 uint8_t *init_cmd;
45#ifdef __LUATOS__
46 luat_lcd_conf_t* lcd_conf;
47#else
48 void *lcd_conf;
49#endif
51
52typedef struct
53{
54 size_t camera_speed; //提供给camera时钟频率
55 uint16_t sensor_width; //camera的最大宽度
56 uint16_t sensor_height; //camera的最大高度
57 uint8_t only_y;
60 uint8_t scaleBytes;
61 uint8_t spi_mode;
62 uint8_t is_msb; //0 or 1;
63 uint8_t is_two_line_rx; //0 or 1;
64 uint8_t seq_type; //0 or 1
65 uint8_t plat_param[4];
66#ifdef __LUATOS__
67 luat_lcd_conf_t* lcd_conf;
68#else
69 void *lcd_conf;
70#endif
72#ifdef __LUATOS__
73int l_camera_handler(lua_State *L, void* ptr);
74#endif
83int luat_camera_setup(int id, luat_spi_camera_t *conf, void* callback, void *param);
84
92int luat_camera_set_image_w_h(int id, uint16_t w, uint16_t h);
93
100
107
114int luat_camera_start_with_buffer(int id, void *buf);
121void luat_camera_continue_with_buffer(int id, void *buf);
128int luat_camera_pause(int id, uint8_t is_pause);
129/*
130 * @brief 扫码库初始化
131 * @param type 扫码库型号,目前只支持0
132 * @param stack 扫码库任务的堆栈地址
133 * @param stack_length 扫码库任务的堆栈深度,type=0时需要至少220KB
134 * @param priority 扫码库任务优先级
135 * @return 0成功,其他失败
136 */
137int luat_camera_image_decode_init(uint8_t type, void *stack, uint32_t stack_length, uint32_t priority);
138/*
139 * @brief 扫码库进行一次解码
140 * @param data 缓冲区
141 * @param image_w 图像宽
142 * @param image_h 图像高
143 * @param timeout 超时
144 * @param callback 回调函数
145 * @param param 回调参数
146 * @return 0成功,其他失败
147 */
148int luat_camera_image_decode_once(uint8_t *data, uint16_t image_w, uint16_t image_h, uint32_t timeout, void *callback, void *param);
149
150/*
151 * @brief 扫码库反初始化
152 */
154/*
155 * @brief 获取解码结果
156 * @param buf 缓冲区
157 * @return 1成功,其他失败
158 */
160
161/**********以下是luatos使用,csdk不要使用***********/
174
175int luat_camera_preview(int id, uint8_t on_off);
176
177int luat_camera_work_mode(int id, int mode);
178
179int luat_camera_capture(int id, uint8_t quality, const char *path);
180
181int luat_camera_capture_in_ram(int id, uint8_t quality, void *buffer);
183#endif
int luat_camera_work_mode(int id, int mode)
void luat_camera_image_decode_deinit(void)
int luat_camera_preview(int id, uint8_t on_off)
int luat_camera_setup(int id, luat_spi_camera_t *conf, void *callback, void *param)
配置spi camera并且初始化camera
int luat_camera_init(luat_camera_conf_t *conf)
配置camera并且初始化camera,spi camera不要使用这个
int luat_camera_stop(int id)
停止接收camera数据
struct luat_camera_conf luat_camera_conf_t
void luat_camera_continue_with_buffer(int id, void *buf)
摄像头切换接收数据缓冲区,csdk专用
int luat_camera_image_decode_get_result(uint8_t *buf)
int luat_camera_capture_in_ram(int id, uint8_t quality, void *buffer)
int luat_camera_capture(int id, uint8_t quality, const char *path)
int luat_camera_close(int id)
关闭camera并且释放资源
int luat_camera_image_decode_init(uint8_t type, void *stack, uint32_t stack_length, uint32_t priority)
int luat_camera_start_with_buffer(int id, void *buf)
摄像头启动开始接收数据,csdk专用
int luat_camera_image_decode_once(uint8_t *data, uint16_t image_w, uint16_t image_h, uint32_t timeout, void *callback, void *param)
int luat_camera_pause(int id, uint8_t is_pause)
暂停接收camera数据
int luat_camera_set_image_w_h(int id, uint16_t w, uint16_t h)
配置图像大小
int luat_camera_start(int id)
开始接收camera数据
@ LUAT_CAMERA_FRAME_END
@ LUAT_CAMERA_MODE_SCAN
@ LUAT_CAMERA_FRAME_RX_DONE
@ LUAT_CAMERA_FRAME_START
@ LUAT_CAMERA_FRAME_ERROR
@ LUAT_CAMERA_MODE_AUTO