Skip to content

Commit

Permalink
Camera: Add getFrameInterval() API
Browse files Browse the repository at this point in the history
Add getFrameInterval() API to get frame interval.
  • Loading branch information
SPRESENSE committed Mar 18, 2022
1 parent 78159bf commit 0ed9f9e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,31 @@ int CameraClass::getJPEGQuality(void)
V4L2_CID_JPEG_COMPRESSION_QUALITY);
}

// Public : frame interval
int CameraClass::getFrameInterval(void)
{
struct v4l2_streamparm param = {0};
struct v4l2_fract *interval = &param.parm.capture.timeperframe;

if (is_device_ready())
{
param.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

if (ioctl(video_fd, VIDIOC_G_PARM, (unsigned long)&param) < 0)
{
return convert_errno2camerr(errno);
}

/* Convert fraction to value with 100usec unit. */

return interval->numerator * 10000 / interval->denominator;
}
else
{
return CAM_ERR_NOT_INITIALIZED;
}
}

// Public : Still Picture Format.
CamErr CameraClass::setStillPictureImageFormat(int img_width, int img_height, CAM_IMAGE_PIX_FMT img_fmt,
int jpgbufsize_divisor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,16 @@ class CameraClass {
*/
int getJPEGQuality(void);

/**
* @brief Get frame interval
* @details [en] Get frame interval in 100usec units. <BR>
* [ja] フレーム間隔(100usec単位)を取得する。
*
* @return [en] Frame interval in 100usec units or error code defined as #CamErr. <BR>
* [ja] フレーム間隔(100usec単位) もしくは、#CamErrで定義されているエラーコード。
*/
int getFrameInterval(void);

/**
* @brief Set Still Picture Image format parameters.
* @details [en] Set Still Picture Image format. <BR>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ getAbsoluteExposure KEYWORD2
getHDR KEYWORD2
getISOSensitivity KEYWORD2
getJPEGQuality KEYWORD2
getFrameInterval KEYWORD2
setStillPictureImageFormat KEYWORD2
takePicture KEYWORD2
getDeviceType KEYWORD2
Expand Down

0 comments on commit 0ed9f9e

Please sign in to comment.