| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- /******************************************************************************
- * CAMERA设备操作抽象层
- * @author Dozingfiretruck
- * @since 0.0.1
- *****************************************************************************/
- #ifndef Luat_CAMERA_H
- #define Luat_CAMERA_H
- #include "luat_base.h"
- #ifdef __LUATOS__
- #include "luat_lcd.h"
- #endif
- /**
- * @defgroup CAMERA CAMERA设备(CAMERA)
- * @{
- */
- enum
- {
- LUAT_CAMERA_FRAME_START = 0,
- LUAT_CAMERA_FRAME_END,
- LUAT_CAMERA_FRAME_RX_DONE,
- LUAT_CAMERA_FRAME_ERROR,
- LUAT_CAMERA_MODE_AUTO = 0,
- LUAT_CAMERA_MODE_SCAN,
- LUAT_CAMERA_TYPE_USB = 0x20,
- LUAT_CAMERA_TYPE_DVP = 0,
- LUAT_CAMERA_PREVIEW_ROTATE_0 = 0,
- LUAT_CAMERA_PREVIEW_ROTATE_90,
- LUAT_CAMERA_PREVIEW_ROTATE_180,
- LUAT_CAMERA_PREVIEW_ROTATE_270,
- // H264配置项
- LUAT_CAMERA_CONF_H264_BASE = 0x200,
- LUAT_CAMERA_CONF_H264_QP_INIT,
- LUAT_CAMERA_CONF_H264_QP_I_MAX,
- LUAT_CAMERA_CONF_H264_QP_P_MAX,
- LUAT_CAMERA_CONF_H264_IMB_BITS,
- LUAT_CAMERA_CONF_H264_PMB_BITS,
- LUAT_CAMERA_CONF_H264_PFRAME_NUMS,
- LUAT_CAMERA_CONF_PREVIEW_BASE = 0x210,
- LUAT_CAMERA_CONF_PREVIEW_ENABLE,
- LUAT_CAMERA_CONF_PREVIEW_ROTATE,
- LUAT_CAMERA_CONF_UVC_FPS = 0x220,
- LUAT_CAMERA_CONF_LOG_LEVEL = 0x230,
- };
- typedef struct luat_camera_conf
- {
- uint8_t id;
- uint8_t zbar_scan;
- uint8_t draw_lcd;
- uint8_t i2c_id;
- uint8_t i2c_addr;
- uint8_t pwm_id;
- size_t pwm_period;
- uint8_t pwm_pulse;
- uint16_t sensor_width;
- uint16_t sensor_height;
- uint16_t pid;
- uint16_t vid;
- uint8_t color_bit;
- uint8_t id_reg;
- uint8_t id_value;
- uint8_t usb_port;
- uint8_t stream;
- uint8_t async;
- size_t init_cmd_size;
- uint8_t *init_cmd;
- #ifdef __LUATOS__
- luat_lcd_conf_t* lcd_conf;
- #else
- void *lcd_conf;
- #endif
- } luat_camera_conf_t;
- typedef struct
- {
- size_t camera_speed; //提供给camera时钟频率
- uint16_t sensor_width; //camera的最大宽度
- uint16_t sensor_height; //camera的最大高度
- uint8_t only_y;
- uint8_t rowScaleRatio;
- uint8_t colScaleRatio;
- uint8_t scaleBytes;
- uint8_t spi_mode;
- uint8_t is_msb; //0 or 1;
- uint8_t is_two_line_rx; //0 or 1;
- uint8_t seq_type; //0 or 1
- uint8_t plat_param[4];//0 ddr 1
- #ifdef __LUATOS__
- luat_lcd_conf_t* lcd_conf;
- #else
- void *lcd_conf;
- #endif
- } luat_spi_camera_t;
- #ifdef __LUATOS__
- int l_camera_handler(lua_State *L, void* ptr);
- #endif
- /**
- * @brief 配置spi camera并且初始化camera
- * @param id camera接收数据总线ID,见选型手册,例如AIR780EXXX是0
- * @param conf camera相关配置
- * @param callback camera接收中断回调,注意这是在中断里的回调
- * @param param 中断回调时用户的参数
- * @return >=0成功,其他失败
- */
- int luat_camera_setup(int id, luat_spi_camera_t *conf, void* callback, void *param);
- /**
- * @brief 配置图像大小
- * @param id camera接收数据总线ID
- * @param w 图像宽
- * @param h 图像高
- * @return >=0成功,其他失败
- */
- int luat_camera_set_image_w_h(int id, uint16_t w, uint16_t h);
- /**
- * @brief 配置camera并且初始化camera,spi camera不要使用这个
- * @param conf camera相关配置
- * @return 0成功,其他失败
- */
- int luat_camera_init(luat_camera_conf_t *conf);
- /**
- * @brief 关闭camera并且释放资源
- * @param id camera接收数据总线ID
- * @return 0成功,其他失败
- */
- int luat_camera_close(int id);
- /**
- * @brief 摄像头启动开始接收数据,csdk专用
- * @param id camera接收数据总线ID
- * @param buf 用户区地址,如果为NULL,则表示不存放到用户区
- * @return 0成功,其他失败
- */
- int luat_camera_start_with_buffer(int id, void *buf);
- /**
- * @brief 摄像头切换接收数据缓冲区,csdk专用
- * @param id camera接收数据总线ID
- * @param buf 用户区地址,如果为NULL,则表示不存放到用户区
- * @return 0成功,其他失败
- */
- void luat_camera_continue_with_buffer(int id, void *buf);
- /**
- * @brief 暂停接收camera数据
- * @param id camera接收数据总线ID
- * @param is_pause 非0暂停,0恢复
- * @return 0成功,其他失败
- */
- int luat_camera_pause(int id, uint8_t is_pause);
- /*
- * @brief 扫码库初始化
- * @param type 扫码库型号,目前只支持0
- * @param stack 扫码库任务的堆栈地址
- * @param stack_length 扫码库任务的堆栈深度,type=0时需要至少220KB
- * @param priority 扫码库任务优先级
- * @return 0成功,其他失败
- */
- int luat_camera_image_decode_init(uint8_t type, void *stack, uint32_t stack_length, uint32_t priority);
- /*
- * @brief 扫码库进行一次解码
- * @param data 缓冲区
- * @param image_w 图像宽
- * @param image_h 图像高
- * @param timeout 超时
- * @param callback 回调函数
- * @param param 回调参数
- * @return 0成功,其他失败
- */
- int luat_camera_image_decode_once(uint8_t *data, uint16_t image_w, uint16_t image_h, uint32_t timeout, void *callback, void *param);
- /*
- * @brief 扫码库反初始化
- */
- void luat_camera_image_decode_deinit(void);
- /*
- * @brief 获取解码结果
- * @param buf 缓冲区
- * @return 1成功,其他失败
- */
- int luat_camera_image_decode_get_result(uint8_t *buf);
- /**********以下是luatos使用,csdk不要使用***********/
- /**
- * @brief 开始接收camera数据
- * @param id camera接收数据总线ID
- * @return 0成功,其他失败
- */
- int luat_camera_start(int id);
- /**
- * @brief 停止接收camera数据
- * @param id camera接收数据总线ID
- * @return 0成功,其他失败
- */
- int luat_camera_stop(int id);
- int luat_camera_preview(int id, uint8_t on_off);
- int luat_camera_work_mode(int id, int mode);
- int luat_camera_capture_config(int id, uint16_t start_x, uint16_t start_y, uint16_t new_w, uint16_t new_h);
- int luat_camera_capture(int id, uint8_t quality, const char *path);
- int luat_camera_capture_in_ram(int id, uint8_t quality, void *buffer);
- int luat_camera_config(int id, int key, int value);
- void luat_camera_reset_pin(int id, uint8_t level);
- void luat_camera_pwdn_pin(int id, uint8_t level);
- extern int32_t g_camera_log_level;
- /** @}*/
- #endif
|