Skip to content

Commit

Permalink
Camera: Enable to use frame sizes that SDK supports
Browse files Browse the repository at this point in the history
Delete frame size check to use frame sizes that SDK supports.
  • Loading branch information
SPRESENSE committed Mar 18, 2022
1 parent 32e4012 commit 5a35560
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,21 +548,6 @@ CamErr CameraClass::convert_errno2camerr(int err)
}
}

// Private : Validate video frame parameters.
bool CameraClass::check_video_fmtparam(int w, int h, CAM_VIDEO_FPS fps, CAM_IMAGE_PIX_FMT fmt)
{
if( ((CAM_IMGSIZE_QVGA_H == w) && (CAM_IMGSIZE_QVGA_V == h)) ||
((CAM_IMGSIZE_VGA_H == w) && (CAM_IMGSIZE_VGA_V == h)) ||
((CAM_IMGSIZE_QUADVGA_H == w) && (CAM_IMGSIZE_QUADVGA_V == h)) ||
((CAM_IMGSIZE_HD_H == w) && (CAM_IMGSIZE_HD_V == h)) ||
((CAM_IMGSIZE_FULLHD_H == w) && (CAM_IMGSIZE_FULLHD_V == h)) ||
((CAM_IMGSIZE_5M_H == w) && (CAM_IMGSIZE_5M_V == h)) ||
((CAM_IMGSIZE_3M_H == w) && (CAM_IMGSIZE_3M_V == h)) ){
return true;
}
return false;
}

// Private : Set V4S frame paramters.
CamErr CameraClass::set_frame_parameters( enum v4l2_buf_type type, int video_width, int video_height, int buf_num, CAM_IMAGE_PIX_FMT video_fmt )
{
Expand Down Expand Up @@ -884,11 +869,6 @@ CamErr CameraClass::begin(int buff_num, CAM_VIDEO_FPS fps, int video_width, int
{
CamErr ret = CAM_ERR_SUCCESS;

if (!check_video_fmtparam(video_width, video_height, fps, video_fmt))
{
return CAM_ERR_INVALID_PARAM;
}

if (buff_num < 0)
{
return CAM_ERR_INVALID_PARAM;
Expand Down Expand Up @@ -922,13 +902,6 @@ CamErr CameraClass::begin(int buff_num, CAM_VIDEO_FPS fps, int video_width, int
return CAM_ERR_SUCCESS;
}

// Start Dequeue Buff thread.
ret = create_dq_thread();
if (ret != CAM_ERR_SUCCESS)
{
goto label_err_no_memaligned;
}

// Set Video Frame parameters.
ret = set_frame_parameters(V4L2_BUF_TYPE_VIDEO_CAPTURE,
video_width,
Expand All @@ -947,6 +920,13 @@ CamErr CameraClass::begin(int buff_num, CAM_VIDEO_FPS fps, int video_width, int
goto label_err_no_memaligned;
}

// Start Dequeue Buff thread.
ret = create_dq_thread();
if (ret != CAM_ERR_SUCCESS)
{
goto label_err_no_memaligned;
}

// Create Buffer
ret = create_videobuff(video_width, video_height, buff_num, video_fmt,
jpgbufsize_divisor);
Expand Down Expand Up @@ -1223,30 +1203,16 @@ CamErr CameraClass::setStillPictureImageFormat(int img_width, int img_height, CA

if (is_device_ready())
{
if (check_video_fmtparam(img_width,
img_height,
CAM_VIDEO_FPS_NONE,
img_fmt))
err = set_frame_parameters(V4L2_BUF_TYPE_STILL_CAPTURE,
img_width, img_height, 1, img_fmt);
if (err == CAM_ERR_SUCCESS)
{
err = create_stillbuff(img_width, img_height, img_fmt, jpgbufsize_divisor);
if (err == CAM_ERR_SUCCESS)
{
err = set_frame_parameters(V4L2_BUF_TYPE_STILL_CAPTURE,
img_width, img_height, 1, img_fmt);
if (err == CAM_ERR_SUCCESS)
{
enqueue_video_buff(still_img);
}
else
{
DELETE_CAMIMAGE(still_img);
}
enqueue_video_buff(still_img);
}
}
else
{
err = CAM_ERR_INVALID_PARAM;
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@ enum CAM_WHITE_BALANCE {
* @brief Camera Image size definition.
* @{
*/
#define CAM_IMGSIZE_QVGA_H VIDEO_HSIZE_QVGA /**< QVGA horizontal size */
#define CAM_IMGSIZE_QVGA_V VIDEO_VSIZE_QVGA /**< QVGA vertical size */
#define CAM_IMGSIZE_VGA_H VIDEO_HSIZE_VGA /**< VGA horizontal size */
#define CAM_IMGSIZE_VGA_V VIDEO_VSIZE_VGA /**< VGA vertical size */
#define CAM_IMGSIZE_HD_H VIDEO_HSIZE_HD /**< HD horizontal size */
#define CAM_IMGSIZE_HD_V VIDEO_VSIZE_HD /**< HD vertical size */
#define CAM_IMGSIZE_QUADVGA_H VIDEO_HSIZE_QUADVGA /**< QUADVGA horizontal size */
#define CAM_IMGSIZE_QUADVGA_V VIDEO_VSIZE_QUADVGA /**< QUADVGA vertical size */
#define CAM_IMGSIZE_FULLHD_H VIDEO_HSIZE_FULLHD /**< FULLHD horizontal size */
#define CAM_IMGSIZE_FULLHD_V VIDEO_VSIZE_FULLHD /**< FULLHD vertical size */
#define CAM_IMGSIZE_5M_H VIDEO_HSIZE_5M /**< 5M horizontal size */
#define CAM_IMGSIZE_5M_V VIDEO_VSIZE_5M /**< 5M vertical size */
#define CAM_IMGSIZE_3M_H VIDEO_HSIZE_3M /**< 3M horizontal size */
#define CAM_IMGSIZE_3M_V VIDEO_VSIZE_3M /**< 3M vertical size */
#define CAM_IMGSIZE_QQVGA_H (160) /**< QQVGA horizontal size */
#define CAM_IMGSIZE_QQVGA_V (120) /**< QQVGA vertical size */
#define CAM_IMGSIZE_QVGA_H (320) /**< QVGA horizontal size */
#define CAM_IMGSIZE_QVGA_V (240) /**< QVGA vertical size */
#define CAM_IMGSIZE_VGA_H (640) /**< VGA horizontal size */
#define CAM_IMGSIZE_VGA_V (480) /**< VGA vertical size */
#define CAM_IMGSIZE_HD_H (1280) /**< HD horizontal size */
#define CAM_IMGSIZE_HD_V (720) /**< HD vertical size */
#define CAM_IMGSIZE_QUADVGA_H (1280) /**< QUADVGA horizontal size */
#define CAM_IMGSIZE_QUADVGA_V (960) /**< QUADVGA vertical size */
#define CAM_IMGSIZE_FULLHD_H (1920) /**< FULLHD horizontal size */
#define CAM_IMGSIZE_FULLHD_V (1080) /**< FULLHD vertical size */
#define CAM_IMGSIZE_3M_H (2048) /**< 3M horizontal size */
#define CAM_IMGSIZE_3M_V (1536) /**< 3M vertical size */
#define CAM_IMGSIZE_5M_H (2560) /**< 5M horizontal size */
#define CAM_IMGSIZE_5M_V (1920) /**< 5M vertical size */
/** @} */


Expand Down Expand Up @@ -531,7 +533,6 @@ class CameraClass {
CameraClass(const char *path);

CamErr convert_errno2camerr(int err);
bool check_video_fmtparam(int w, int h, CAM_VIDEO_FPS fps, CAM_IMAGE_PIX_FMT fmt);
CamErr set_frame_parameters( enum v4l2_buf_type type, int video_width, int video_height, int buf_num, CAM_IMAGE_PIX_FMT video_fmt );
CamErr create_videobuff(int w, int h, int buff_num, CAM_IMAGE_PIX_FMT fmt, int jpgbufsize_divisor);
void delete_videobuff();
Expand Down

0 comments on commit 5a35560

Please sign in to comment.