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_1 (1000)
194#define CAM_ISO_SENSITIVITY_1_2 (1200)
195#define CAM_ISO_SENSITIVITY_1_6 (1600)
196#define CAM_ISO_SENSITIVITY_2 (2000)
197#define CAM_ISO_SENSITIVITY_2_5 (2500)
198#define CAM_ISO_SENSITIVITY_3_2 (3200)
199#define CAM_ISO_SENSITIVITY_4 (4000)
200#define CAM_ISO_SENSITIVITY_5 (5000)
201#define CAM_ISO_SENSITIVITY_6 (6000)
202#define CAM_ISO_SENSITIVITY_8 (8000)
203#define CAM_ISO_SENSITIVITY_10 (10000)
204#define CAM_ISO_SENSITIVITY_12 (12000)
205#define CAM_ISO_SENSITIVITY_16 (16000)
206#define CAM_ISO_SENSITIVITY_20 (20000)
207#define CAM_ISO_SENSITIVITY_25 (25000)
208#define CAM_ISO_SENSITIVITY_32 (32000)
209#define CAM_ISO_SENSITIVITY_40 (40000)
210#define CAM_ISO_SENSITIVITY_50 (50000)
211#define CAM_ISO_SENSITIVITY_64 (64000)
212#define CAM_ISO_SENSITIVITY_80 (80000)
213#define CAM_ISO_SENSITIVITY_100 (100000)
214#define CAM_ISO_SENSITIVITY_125 (125000)
215#define CAM_ISO_SENSITIVITY_160 (160000)
216#define CAM_ISO_SENSITIVITY_200 (200000)
217#define CAM_ISO_SENSITIVITY_250 (250000)
218#define CAM_ISO_SENSITIVITY_320 (320000)
219#define CAM_ISO_SENSITIVITY_400 (400000)
220#define CAM_ISO_SENSITIVITY_500 (500000)
221#define CAM_ISO_SENSITIVITY_640 (640000)
222#define CAM_ISO_SENSITIVITY_800 (800000)
223#define CAM_ISO_SENSITIVITY_1000 (1000000)
224#define CAM_ISO_SENSITIVITY_1250 (1250000)
225#define CAM_ISO_SENSITIVITY_1600 (1600000)
226#define CAM_ISO_SENSITIVITY_2000 (2000000)
227#define CAM_ISO_SENSITIVITY_2500 (2500000)
228#define CAM_ISO_SENSITIVITY_3200 (3200000)
229#define CAM_ISO_SENSITIVITY_4000 (4000000)
230#define CAM_ISO_SENSITIVITY_5000 (5000000)
271 static const int SPRESENSE_CAMIMAGE_MEM_ALIGN = 32;
279 enum v4l2_buf_type buf_type;
294 bool is_valid(){
return (buff != NULL); };
296 void lock() {
if(buff!=NULL) sem_wait(&my_sem); };
297 void unlock(){
if(buff!=NULL) sem_post(&my_sem); };
299 void queued(
bool q){ lock(); is_queue = q; unlock(); };
300 bool is_queued(
void){
bool ret; lock(); ret = is_queue; unlock();
return ret; };
305 bool generate_imgmem(
size_t s);
306 size_t calc_img_size(
int w,
int h,
CAM_IMAGE_PIX_FMT fmt,
int jpgbufsize_divisor);
307 void update_actual_size(
size_t sz);
309 static void delete_inst(
ImgBuff *buf);
327 void setActualSize(
size_t sz) { img_buff->update_actual_size(sz); };
328 void setPixFormat(
CAM_IMAGE_PIX_FMT pix_fmt) {
if(img_buff != NULL) img_buff->pix_fmt = pix_fmt; }
329 void setIdx(
int i){
if(img_buff != NULL) img_buff->idx = i; }
330 bool isIdx(
int i){
return (img_buff != NULL) ? (img_buff->idx == i) :
false; }
331 int getIdx(){
return (img_buff != NULL) ? img_buff->idx : -1; }
332 int getType(){
return (img_buff != NULL) ? img_buff->buf_type : -1; }
333 bool is_valid(){
return (img_buff != NULL); };
335 bool check_hw_resize_param(
int iw,
int ih,
int ow,
int oh);
336 bool check_resize_magnification(
int in,
int out);
347 int getWidth(){
return (img_buff != NULL) ? img_buff->width : 0; }
356 int getHeight(){
return (img_buff != NULL) ? img_buff->height : 0; }
365 uint8_t *
getImgBuff() {
return (img_buff != NULL) ? img_buff->buff : NULL; }
374 size_t getImgSize() {
return (img_buff != NULL) ? img_buff->actual_size : 0; }
547 volatile bool loop_dqbuf_en;
549 sem_t video_cb_access_sem;
554 CamErr convert_errno2camerr(
int err);
555 CamErr set_frame_parameters(
enum v4l2_buf_type type,
int video_width,
int video_height,
int buf_num,
CAM_IMAGE_PIX_FMT video_fmt );
557 void delete_videobuff();
558 CamErr enqueue_video_buffs();
560 bool is_device_ready();
562 CamErr set_ext_ctrls(uint16_t ctl_cls, uint16_t cid, int32_t value);
563 int32_t get_ext_ctrls(uint16_t ctl_cls, uint16_t cid);
565 CamErr create_dq_thread();
566 void delete_dq_thread();
568 void lock_video_cb() { sem_wait(&video_cb_access_sem); };
569 void unlock_video_cb(){ sem_post(&video_cb_access_sem); };
572 static void frame_handle_thread(
void *);
573 static const int CAM_FRAME_THREAD_STACK_SIZE = 2048;
574 static const int CAM_FRAME_THREAD_STACK_PRIO = 101;
576 mqd_t frame_exchange_mq;
577 static const int CAM_FRAME_MQ_SIZE = 1;
580 static void dqbuf_thread(
void *);
581 static const int CAM_DQ_THREAD_STACK_SIZE = 1024;
582 static const int CAM_DQ_THREAD_STACK_PRIO = 102;
584 int ioctl_dequeue_stream_buf(
struct v4l2_buffer *buf, uint16_t type);
586 void release_buf(
ImgBuff *buf);
637 int jpgbufsize_divisor = 7
828 int jpgbufsize_divisor = 7
[en] The class which is to control Image from Camera. [ja] Cameraから得られる画像データを利用するためのクラス。
Definition: Camera.h:321
[en] The class to control Spresense Camera. [ja] SpresenseのCamera機能を制御するためのクラス。
Definition: Camera.h:535
[en] Camera Image memory management class. This is internal class. [ja] Cameraのイメージメモリ管理用クラス。内部利用Cl...
Definition: Camera.h:270
#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:239
size_t getImgSize()
Get Image Size.
Definition: Camera.h:374
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:250
CamImage()
Constuctor of CamImage class.
Definition: Camera.h:401
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:365
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:347
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:618
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:262
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:383
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:392
int getHeight()
Get Image Height.
Definition: Camera.h:356
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:241
@ CAM_HDR_MODE_ON
Definition: Camera.h:242
@ CAM_HDR_MODE_OFF
Definition: Camera.h:240
@ CAM_VIDEO_FPS_60
Definition: Camera.h:257
@ CAM_VIDEO_FPS_120
Definition: Camera.h:258
@ CAM_VIDEO_FPS_NONE
Definition: Camera.h:251
@ CAM_VIDEO_FPS_15
Definition: Camera.h:255
@ CAM_VIDEO_FPS_5
Definition: Camera.h:252
@ CAM_VIDEO_FPS_30
Definition: Camera.h:256
@ CAM_VIDEO_FPS_6
Definition: Camera.h:253
@ CAM_VIDEO_FPS_7_5
Definition: Camera.h:254
@ 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