32#ifndef __SPRESENSE_CAMERA_CLASS_H__
33#define __SPRESENSE_CAMERA_CLASS_H__
36#error "Camera library is NOT supported by SubCore."
52#include <nuttx/video/video.h>
121#define CAM_IMGSIZE_QQVGA_H (160)
122#define CAM_IMGSIZE_QQVGA_V (120)
123#define CAM_IMGSIZE_QVGA_H (320)
124#define CAM_IMGSIZE_QVGA_V (240)
125#define CAM_IMGSIZE_VGA_H (640)
126#define CAM_IMGSIZE_VGA_V (480)
127#define CAM_IMGSIZE_HD_H (1280)
128#define CAM_IMGSIZE_HD_V (720)
129#define CAM_IMGSIZE_QUADVGA_H (1280)
130#define CAM_IMGSIZE_QUADVGA_V (960)
131#define CAM_IMGSIZE_FULLHD_H (1920)
132#define CAM_IMGSIZE_FULLHD_V (1080)
133#define CAM_IMGSIZE_3M_H (2048)
134#define CAM_IMGSIZE_3M_V (1536)
135#define CAM_IMGSIZE_5M_H (2560)
136#define CAM_IMGSIZE_5M_V (1920)
193#define CAM_ISO_SENSITIVITY_25 (25000)
194#define CAM_ISO_SENSITIVITY_32 (32000)
195#define CAM_ISO_SENSITIVITY_40 (40000)
196#define CAM_ISO_SENSITIVITY_50 (50000)
197#define CAM_ISO_SENSITIVITY_64 (64000)
198#define CAM_ISO_SENSITIVITY_80 (80000)
199#define CAM_ISO_SENSITIVITY_100 (100000)
200#define CAM_ISO_SENSITIVITY_125 (125000)
201#define CAM_ISO_SENSITIVITY_160 (160000)
202#define CAM_ISO_SENSITIVITY_200 (200000)
203#define CAM_ISO_SENSITIVITY_250 (250000)
204#define CAM_ISO_SENSITIVITY_320 (320000)
205#define CAM_ISO_SENSITIVITY_400 (400000)
206#define CAM_ISO_SENSITIVITY_500 (500000)
207#define CAM_ISO_SENSITIVITY_640 (640000)
208#define CAM_ISO_SENSITIVITY_800 (800000)
209#define CAM_ISO_SENSITIVITY_1000 (1000000)
210#define CAM_ISO_SENSITIVITY_1250 (1250000)
211#define CAM_ISO_SENSITIVITY_1600 (1600000)
252 static const int SPRESENSE_CAMIMAGE_MEM_ALIGN = 32;
260 enum v4l2_buf_type buf_type;
275 bool is_valid(){
return (buff != NULL); };
277 void lock() {
if(buff!=NULL) sem_wait(&my_sem); };
278 void unlock(){
if(buff!=NULL) sem_post(&my_sem); };
280 void queued(
bool q){ lock(); is_queue = q; unlock(); };
281 bool is_queued(
void){
bool ret; lock(); ret = is_queue; unlock();
return ret; };
286 bool generate_imgmem(
size_t s);
287 size_t calc_img_size(
int w,
int h,
CAM_IMAGE_PIX_FMT fmt,
int jpgbufsize_divisor);
288 void update_actual_size(
size_t sz);
290 static void delete_inst(
ImgBuff *buf);
308 void setActualSize(
size_t sz) { img_buff->update_actual_size(sz); };
309 void setPixFormat(
CAM_IMAGE_PIX_FMT pix_fmt) {
if(img_buff != NULL) img_buff->pix_fmt = pix_fmt; }
310 void setIdx(
int i){
if(img_buff != NULL) img_buff->idx = i; }
311 bool isIdx(
int i){
return (img_buff != NULL) ? (img_buff->idx == i) :
false; }
312 int getIdx(){
return (img_buff != NULL) ? img_buff->idx : -1; }
313 int getType(){
return (img_buff != NULL) ? img_buff->buf_type : -1; }
314 bool is_valid(){
return (img_buff != NULL); };
316 bool check_hw_resize_param(
int iw,
int ih,
int ow,
int oh);
317 bool check_resize_magnification(
int in,
int out);
328 int getWidth(){
return (img_buff != NULL) ? img_buff->width : 0; }
337 int getHeight(){
return (img_buff != NULL) ? img_buff->height : 0; }
346 uint8_t *
getImgBuff() {
return (img_buff != NULL) ? img_buff->buff : NULL; }
355 size_t getImgSize() {
return (img_buff != NULL) ? img_buff->actual_size : 0; }
528 volatile bool loop_dqbuf_en;
530 sem_t video_cb_access_sem;
535 CamErr convert_errno2camerr(
int err);
536 CamErr set_frame_parameters(
enum v4l2_buf_type type,
int video_width,
int video_height,
int buf_num,
CAM_IMAGE_PIX_FMT video_fmt );
538 void delete_videobuff();
539 CamErr enqueue_video_buffs();
541 bool is_device_ready();
543 CamErr set_ext_ctrls(uint16_t ctl_cls, uint16_t cid, int32_t value);
544 int32_t get_ext_ctrls(uint16_t ctl_cls, uint16_t cid);
546 CamErr create_dq_thread();
547 void delete_dq_thread();
549 void lock_video_cb() { sem_wait(&video_cb_access_sem); };
550 void unlock_video_cb(){ sem_post(&video_cb_access_sem); };
553 static void frame_handle_thread(
void *);
554 static const int CAM_FRAME_THREAD_STACK_SIZE = 2048;
555 static const int CAM_FRAME_THREAD_STACK_PRIO = 101;
557 mqd_t frame_exchange_mq;
558 static const int CAM_FRAME_MQ_SIZE = 1;
561 static void dqbuf_thread(
void *);
562 static const int CAM_DQ_THREAD_STACK_SIZE = 1024;
563 static const int CAM_DQ_THREAD_STACK_PRIO = 102;
565 int ioctl_dequeue_stream_buf(
struct v4l2_buffer *buf, uint16_t type);
567 void release_buf(
ImgBuff *buf);
618 int jpgbufsize_divisor = 7
809 int jpgbufsize_divisor = 7
[en] The class which is to control Image from Camera. [ja] Cameraから得られる画像データを利用するためのクラス。
Definition: Camera.h:302
[en] The class to control Spresense Camera. [ja] SpresenseのCamera機能を制御するためのクラス。
Definition: Camera.h:516
[en] Camera Image memory management class. This is internal class. [ja] Cameraのイメージメモリ管理用クラス。内部利用Cl...
Definition: Camera.h:251
#define CAM_IMGSIZE_QVGA_H
Definition: Camera.h:123
#define CAM_IMGSIZE_QVGA_V
Definition: Camera.h:124
CAM_HDR_MODE getHDR(void)
Get HDR mode.
CamErr setAbsoluteExposure(int32_t exposure_time)
Set exposure Time.
CAM_COLOR_FX
[en] Camera Color effect setting parameters. [ja] Cameraの画像エフェクトの設定値
Definition: Camera.h:167
CAM_HDR_MODE
[en] Camera HDR mode definitions. [ja] CameraのHDRモードの設定値
Definition: Camera.h:220
size_t getImgSize()
Get Image Size.
Definition: Camera.h:355
CamImage(const CamImage &obj)
Copy Constuctor of CamImage class.
int getFrameInterval(void)
Get frame interval.
CamErr setAutoWhiteBalanceMode(CAM_WHITE_BALANCE wb)
Set Auto White Balance mode.
CamErr setAutoISOSensitivity(bool enable)
Control Auto ISO Sensitivity.
CamErr clipAndResizeImageByHW(CamImage &img, int lefttop_x, int lefttop_y, int rightbottom_x, int rightbottom_y, int width, int height)
Clip and resize Image with HW 2D accelerator.
CAM_VIDEO_FPS
[en] Camera Video Framerate setting parameters. [ja] Cameraのフレームレート設定値
Definition: Camera.h:231
CamImage()
Constuctor of CamImage class.
Definition: Camera.h:382
CamErr
[en] Camera Error Codes. [ja] Cameraのエラーコード
Definition: Camera.h:76
int32_t getAbsoluteExposure(void)
Get exposure Time.
uint8_t * getImgBuff()
Get Image memory address.
Definition: Camera.h:346
CAM_WHITE_BALANCE
[en] Camera White Balance setting parameters [ja] Cameraホワイトバランス設定値
Definition: Camera.h:106
CamErr startStreaming(bool enable, camera_cb_t cb=NULL)
Start / Stop Video Stream.
CamErr begin(int buff_num=1, CAM_VIDEO_FPS fps=CAM_VIDEO_FPS_30, int video_width=CAM_IMGSIZE_QVGA_H, int video_height=CAM_IMGSIZE_QVGA_V, CAM_IMAGE_PIX_FMT video_fmt=CAM_IMAGE_PIX_FMT_YUV422, int jpgbufsize_divisor=7)
Initialize CameraClass instance.
CAM_DEVICE_TYPE
[en] Camera device type which is being used [ja] 使用されているカメラデバイスの種類
Definition: Camera.h:95
~CameraClass()
Destruct CameraClass instance.
int getWidth()
Get Image Width.
Definition: Camera.h:328
bool isAvailable(void)
Check valid image data.
CamErr setAutoExposure(bool enable)
Control Auto Exposure.
CamErr setColorEffect(CAM_COLOR_FX effect)
Set Color Effect.
int getFd()
Get the file descriptor of camera device.
Definition: Camera.h:599
void end()
De-initialize Spresense Camera.
CAM_DEVICE_TYPE getDeviceType()
Get camera device type.
CamImage & operator=(const CamImage &obj)
Assignment operator.
CamErr setHDR(CAM_HDR_MODE mode)
Set HDR mode.
void(* camera_cb_t)(CamImage img)
[en] Camera Callback type definition. [jp] Cameraからのコールバック関数の型定義
Definition: Camera.h:243
CamErr setISOSensitivity(int iso_sense)
Set ISO Sensivity value.
~CamImage()
Destructor of CamImage.
static CameraClass getInstance()
Get the Camera instance.
CamErr convertPixFormat(CAM_IMAGE_PIX_FMT to_fmt)
Convert Pixcelformat of the image.
CamErr setJPEGQuality(int quality)
Set JPEG quality.
int getJPEGQuality(void)
Get JPEG quality.
size_t getImgBuffSize()
Get image buffer size.
Definition: Camera.h:364
CamErr setStillPictureImageFormat(int img_width, int img_height, CAM_IMAGE_PIX_FMT img_fmt=CAM_IMAGE_PIX_FMT_JPG, int jpgbufsize_divisor=7)
Set Still Picture Image format parameters.
CAM_IMAGE_PIX_FMT getPixFormat()
Get Image Pixcel format.
Definition: Camera.h:373
int getHeight()
Get Image Height.
Definition: Camera.h:337
CAM_IMAGE_PIX_FMT
[en] Camera Image Pixcel format [ja] Camera画像のピクセルフォーマット
Definition: Camera.h:62
CamErr resizeImageByHW(CamImage &img, int width, int height)
Resize Image with HW 2D accelerator.
CamErr setAutoWhiteBalance(bool enable)
Control Auto White Balance.
int getISOSensitivity(void)
Get ISO Sensivity value.
CAM_SCENE_MODE
[en] Camera Scene Mode setting parameters. [ja] Cameraのシーンモード設定値
Definition: Camera.h:145
CamErr setAutoISOSensitive(bool enable)
Control Auto ISO Sensitivity (WIll obsolete after v1.2.0)
CamImage takePicture()
Take picture.
@ CAM_COLOR_FX_VIVID
Definition: Camera.h:177
@ CAM_COLOR_FX_SET_CBCR
Definition: Camera.h:183
@ CAM_COLOR_FX_SKIN_WHITEN
Definition: Camera.h:176
@ CAM_COLOR_FX_ANTIQUE
Definition: Camera.h:182
@ CAM_COLOR_FX_PASTEL
Definition: Camera.h:184
@ CAM_COLOR_FX_ART_FREEZE
Definition: Camera.h:179
@ CAM_COLOR_FX_SEPIA
Definition: Camera.h:170
@ CAM_COLOR_FX_GRASS_GREEN
Definition: Camera.h:175
@ CAM_COLOR_FX_EMBOSS
Definition: Camera.h:172
@ CAM_COLOR_FX_SILHOUETTE
Definition: Camera.h:180
@ CAM_COLOR_FX_NEGATIVE
Definition: Camera.h:171
@ CAM_COLOR_FX_NONE
Definition: Camera.h:168
@ CAM_COLOR_FX_SKETCH
Definition: Camera.h:173
@ CAM_COLOR_FX_BW
Definition: Camera.h:169
@ CAM_COLOR_FX_SKY_BLUE
Definition: Camera.h:174
@ CAM_COLOR_FX_SOLARIZATION
Definition: Camera.h:181
@ CAM_COLOR_FX_AQUA
Definition: Camera.h:178
@ CAM_HDR_MODE_AUTO
Definition: Camera.h:222
@ CAM_HDR_MODE_ON
Definition: Camera.h:223
@ CAM_HDR_MODE_OFF
Definition: Camera.h:221
@ CAM_VIDEO_FPS_60
Definition: Camera.h:238
@ CAM_VIDEO_FPS_120
Definition: Camera.h:239
@ CAM_VIDEO_FPS_NONE
Definition: Camera.h:232
@ CAM_VIDEO_FPS_15
Definition: Camera.h:236
@ CAM_VIDEO_FPS_5
Definition: Camera.h:233
@ CAM_VIDEO_FPS_30
Definition: Camera.h:237
@ CAM_VIDEO_FPS_6
Definition: Camera.h:234
@ CAM_VIDEO_FPS_7_5
Definition: Camera.h:235
@ CAM_ERR_NOT_INITIALIZED
Definition: Camera.h:81
@ CAM_ERR_ILLEGAL_DEVERR
Definition: Camera.h:79
@ CAM_ERR_USR_INUSED
Definition: Camera.h:86
@ CAM_ERR_ALREADY_INITIALIZED
Definition: Camera.h:80
@ CAM_ERR_NOT_PERMITTED
Definition: Camera.h:87
@ CAM_ERR_NO_MEMORY
Definition: Camera.h:85
@ CAM_ERR_INVALID_PARAM
Definition: Camera.h:84
@ CAM_ERR_NOT_STILL_INITIALIZED
Definition: Camera.h:82
@ CAM_ERR_CANT_CREATE_THREAD
Definition: Camera.h:83
@ CAM_ERR_SUCCESS
Definition: Camera.h:77
@ CAM_ERR_NO_DEVICE
Definition: Camera.h:78
@ CAM_WHITE_BALANCE_AUTO
Definition: Camera.h:107
@ CAM_WHITE_BALANCE_INCANDESCENT
Definition: Camera.h:108
@ CAM_WHITE_BALANCE_FLASH
Definition: Camera.h:111
@ CAM_WHITE_BALANCE_SHADE
Definition: Camera.h:113
@ CAM_WHITE_BALANCE_CLOUDY
Definition: Camera.h:112
@ CAM_WHITE_BALANCE_FLUORESCENT
Definition: Camera.h:109
@ CAM_WHITE_BALANCE_DAYLIGHT
Definition: Camera.h:110
@ CAM_DEVICE_TYPE_UNKNOWN
Definition: Camera.h:96
@ CAM_DEVICE_TYPE_ISX012
Definition: Camera.h:97
@ CAM_DEVICE_TYPE_ISX019
Definition: Camera.h:98
@ CAM_IMAGE_PIX_FMT_GRAY
Definition: Camera.h:66
@ CAM_IMAGE_PIX_FMT_YUV422
Definition: Camera.h:64
@ CAM_IMAGE_PIX_FMT_JPG
Definition: Camera.h:65
@ CAM_IMAGE_PIX_FMT_NONE
Definition: Camera.h:67
@ CAM_IMAGE_PIX_FMT_RGB565
Definition: Camera.h:63
@ CAM_SCENE_MODE_SUNSET
Definition: Camera.h:158
@ CAM_SCENE_MODE_FIREWORKS
Definition: Camera.h:152
@ CAM_SCENE_MODE_CANDLE_LIGHT
Definition: Camera.h:149
@ CAM_SCENE_MODE_NONE
Definition: Camera.h:146
@ CAM_SCENE_MODE_LANDSCAPE
Definition: Camera.h:153
@ CAM_SCENE_MODE_PORTRAIT
Definition: Camera.h:156
@ CAM_SCENE_MODE_NIGHT
Definition: Camera.h:154
@ CAM_SCENE_MODE_FALL_COLORS
Definition: Camera.h:151
@ CAM_SCENE_MODE_PARTY_INDOOR
Definition: Camera.h:155
@ CAM_SCENE_MODE_SPORTS
Definition: Camera.h:157
@ CAM_SCENE_MODE_BACKLIGHT
Definition: Camera.h:147
@ CAM_SCENE_MODE_BEACH_SNOW
Definition: Camera.h:148
@ CAM_SCENE_MODE_DAWN_DUSK
Definition: Camera.h:150