Skip to content

Commit

Permalink
Camera: Add getDeviceType() API
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRESENSE authored Dec 3, 2021
2 parents 29feef1 + 133a941 commit 26b5e92
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,32 @@ CamImage CameraClass::takePicture( )
return CamImage(); // Return empty CamImage because of any error occured.
}

// Public : Get camera device type.
CAM_DEVICE_TYPE CameraClass::getDeviceType()
{
CAM_DEVICE_TYPE ret;
struct v4l2_capability param = {0};

ret = CAM_DEVICE_TYPE_UNKNOWN;

if (is_device_ready())
{
if (ioctl(video_fd, VIDIOC_QUERYCAP, (unsigned long)&param) == 0)
{
if (strncmp((char *)param.driver, "ISX012", sizeof(param.driver)) == 0)
{
ret = CAM_DEVICE_TYPE_ISX012;
}
else if (strncmp((char *)param.driver, "ISX019", sizeof(param.driver)) == 0)
{
ret = CAM_DEVICE_TYPE_ISX019;
}
}
}

return ret;
}

// Public : Finish to use the Camera.
void CameraClass::end()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ enum CamErr {
CAM_ERR_NOT_PERMITTED = -10, /**< [en] Operation is not permitted. <BR> [jp] 許容されていない操作です */
};

/**
* @enum CAM_DEVICE_TYPE
* @brief [en] Camera device type which is being used <BR>
* [ja] 使用されているカメラデバイスの種類
*/
enum CAM_DEVICE_TYPE {
CAM_DEVICE_TYPE_UNKNOWN, /**< [en] Unknown <BR> [ja] 不明 */
CAM_DEVICE_TYPE_ISX012, /**< [en] ISX012 <BR> [ja] ISX012 */
CAM_DEVICE_TYPE_ISX019, /**< [en] ISX019 <BR> [ja] ISX019 */
};

/**
* @enum CAM_WHITE_BALANCE
Expand Down Expand Up @@ -716,6 +726,16 @@ class CameraClass {
*/
CamImage takePicture();

/**
* @brief Get camera device type.
* @details [en] Get camera device type which is being used. <BR>
* [ja] 使用されているカメラデバイスの種類を取得する。
* @return [en] Camera device type which is being used. <BR>
* [ja] 使用されているカメラデバイスの種類。
*/

CAM_DEVICE_TYPE getDeviceType();

/**
* @brief De-initialize Spresense Camera
* @details [en] De-initialize Spresense Camera. This method cancel everything of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ setSceneMode KEYWORD2
setColorEffect KEYWORD2
setStillPictureImageFormat KEYWORD2
takePicture KEYWORD2
getDeviceType KEYWORD2
end KEYWORD2

# Constants
Expand All @@ -39,7 +40,11 @@ CAM_ERR_CANT_CREATE_THREAD LITERAL1
CAM_ERR_INVALID_PARAM LITERAL1
CAM_ERR_NO_MEMORY LITERAL1
CAM_ERR_USR_INUSED LITERAL1


CAM_DEVICE_TYPE_UNKNOWN LITERAL1
CAM_DEVICE_TYPE_ISX012 LITERAL1
CAM_DEVICE_TYPE_ISX019 LITERAL1

CAM_WHITE_BALANCE_INCANDESCENT LITERAL1
CAM_WHITE_BALANCE_FLUORESCENT LITERAL1
CAM_WHITE_BALANCE_DAYLIGHT LITERAL1
Expand Down

0 comments on commit 26b5e92

Please sign in to comment.