C API Reference

Author

Arducam

Date

2023/3/6

Version

V2.0.1

Copyright

Arducam

Typedefs

typedef uint8_t (*BUFFER_CALLBACK)(uint8_t *buffer, uint8_t lenght)

Callback function prototype

typedef void (*STOP_HANDLE)(void)

Callback function prototype

Enums

enum CamStatus

Camera status.

Values:

enumerator CAM_ERR_SUCCESS

Operation succeeded

enumerator CAM_ERR_NO_CALLBACK

No callback function is registered

enum CAM_IMAGE_MODE

Configure camera resolution.

Values:

enumerator CAM_IMAGE_MODE_QQVGA

160x120

enumerator CAM_IMAGE_MODE_QVGA

320x240

enumerator CAM_IMAGE_MODE_VGA

640x480

enumerator CAM_IMAGE_MODE_SVGA

800x600

enumerator CAM_IMAGE_MODE_HD

1280x720

enumerator CAM_IMAGE_MODE_SXGAM

1280x960

enumerator CAM_IMAGE_MODE_UXGA

1600x1200

enumerator CAM_IMAGE_MODE_FHD

1920x1080

enumerator CAM_IMAGE_MODE_QXGA

2048x1536

enumerator CAM_IMAGE_MODE_WQXGA2

2592x1944

enumerator CAM_IMAGE_MODE_96X96

96x96

enumerator CAM_IMAGE_MODE_128X128

128x128

enumerator CAM_IMAGE_MODE_320X320

320x320

enum CAM_CONTRAST_LEVEL

Configure camera contrast level.

Values:

enumerator CAM_CONTRAST_LEVEL_MINUS_3

Level -3

enumerator CAM_CONTRAST_LEVEL_MINUS_2

Level -2

enumerator CAM_CONTRAST_LEVEL_MINUS_1

Level -1

enumerator CAM_CONTRAST_LEVEL_DEFAULT

Level Default

enumerator CAM_CONTRAST_LEVEL_1

Level +1

enumerator CAM_CONTRAST_LEVEL_2

Level +2

enumerator CAM_CONTRAST_LEVEL_3

Level +3

enum CAM_EV_LEVEL

Configure camera EV level.

Values:

enumerator CAM_EV_LEVEL_MINUS_3

Level -3

enumerator CAM_EV_LEVEL_MINUS_2

Level -2

enumerator CAM_EV_LEVEL_MINUS_1

Level -1

enumerator CAM_EV_LEVEL_DEFAULT

Level Default

enumerator CAM_EV_LEVEL_1

Level +1

enumerator CAM_EV_LEVEL_2

Level +2

enumerator CAM_EV_LEVEL_3

Level +3

enum CAM_STAURATION_LEVEL

Configure camera stauration level.

Values:

enumerator CAM_STAURATION_LEVEL_MINUS_3

Level -3

enumerator CAM_STAURATION_LEVEL_MINUS_2

Level -2

enumerator CAM_STAURATION_LEVEL_MINUS_1

Level -1

enumerator CAM_STAURATION_LEVEL_DEFAULT

Level Default

enumerator CAM_STAURATION_LEVEL_1

Level +1

enumerator CAM_STAURATION_LEVEL_2

Level +2

enumerator CAM_STAURATION_LEVEL_3

Level +3

enum CAM_BRIGHTNESS_LEVEL

Configure camera brightness level.

Values:

enumerator CAM_BRIGHTNESS_LEVEL_MINUS_4

Level -4

enumerator CAM_BRIGHTNESS_LEVEL_MINUS_3

Level -3

enumerator CAM_BRIGHTNESS_LEVEL_MINUS_2

Level -2

enumerator CAM_BRIGHTNESS_LEVEL_MINUS_1

Level -1

enumerator CAM_BRIGHTNESS_LEVEL_DEFAULT

Level Default

enumerator CAM_BRIGHTNESS_LEVEL_1

Level +1

enumerator CAM_BRIGHTNESS_LEVEL_2

Level +2

enumerator CAM_BRIGHTNESS_LEVEL_3

Level +3

enumerator CAM_BRIGHTNESS_LEVEL_4

Level +4

enum CAM_SHARPNESS_LEVEL

Configure camera Sharpness level.

Values:

enumerator CAM_SHARPNESS_LEVEL_AUTO

Sharpness Auto

enumerator CAM_SHARPNESS_LEVEL_1

Sharpness Level 1

enumerator CAM_SHARPNESS_LEVEL_2

Sharpness Level 2

enumerator CAM_SHARPNESS_LEVEL_3

Sharpness Level 3

enumerator CAM_SHARPNESS_LEVEL_4

Sharpness Level 4

enumerator CAM_SHARPNESS_LEVEL_5

Sharpness Level 5

enumerator CAM_SHARPNESS_LEVEL_6

Sharpness Level 6

enumerator CAM_SHARPNESS_LEVEL_7

Sharpness Level 7

enumerator CAM_SHARPNESS_LEVEL_8

Sharpness Level 8

enum CAM_VIDEO_MODE

Configure resolution in video streaming mode.

Values:

enumerator CAM_VIDEO_MODE_0

320x240

enumerator CAM_VIDEO_MODE_1

640x480

enum CAM_IMAGE_PIX_FMT

Configure image pixel format.

Values:

enumerator CAM_IMAGE_PIX_FMT_RGB565

RGB565 format

enumerator CAM_IMAGE_PIX_FMT_JPG

JPEG format

enumerator CAM_IMAGE_PIX_FMT_YUV

YUV format

enumerator CAM_IMAGE_PIX_FMT_NONE

No defined format

enum CAM_WHITE_BALANCE

Configure white balance mode.

Values:

enumerator CAM_WHITE_BALANCE_MODE_DEFAULT

Auto

enumerator CAM_WHITE_BALANCE_MODE_SUNNY

Sunny

enumerator CAM_WHITE_BALANCE_MODE_OFFICE

Office

enumerator CAM_WHITE_BALANCE_MODE_CLOUDY

Cloudy

enumerator CAM_WHITE_BALANCE_MODE_HOME

Home

enum CAM_COLOR_FX

Configure special effects.

Values:

enumerator CAM_COLOR_FX_NONE

no effect

enumerator CAM_COLOR_FX_BLUEISH

cool light

enumerator CAM_COLOR_FX_REDISH

warm

enumerator CAM_COLOR_FX_BW

Black/white

enumerator CAM_COLOR_FX_SEPIA

Sepia

enumerator CAM_COLOR_FX_NEGATIVE

positive/negative inversion

enumerator CAM_COLOR_FX_GRASS_GREEN

Grass green

enumerator CAM_COLOR_FX_OVER_EXPOSURE

Over exposure

enumerator CAM_COLOR_FX_SOLARIZE

Solarize

enum IMAGE_QUALITY

Values:

enumerator HIGH_QUALITY
enumerator DEFAULT_QUALITY
enumerator LOW_QUALITY
enum [anonymous]

Values:

enumerator SENSOR_5MP_1
enumerator SENSOR_3MP_1
enumerator SENSOR_5MP_2
enumerator SENSOR_3MP_2
enum CameraStatus

Values:

enumerator Camera_uninit
enumerator Camera_init
enumerator Camera_open
enumerator Camera_close

Functions

ArducamCamera createArducamCamera(int cs)

Create a camera instance.

Parameters:

cs – Chip select signal for SPI communication

Returns:

Return a ArducamCamera instance

CamStatus reset(ArducamCamera *camera)

reset cpld and camera

Parameters:

cameraArducamCamera instance

Returns:

Return operation status

CamStatus begin(ArducamCamera *camera)

Initialize the configuration of the camera module.

Parameters:

cameraArducamCamera instance

Returns:

Return operation status

CamStatus takePicture(ArducamCamera *camera, CAM_IMAGE_MODE mode, CAM_IMAGE_PIX_FMT pixel_format)

Start a snapshot with specified resolution and pixel format.

Note

The mode parameter must be the resolution wh

Parameters:
  • cameraArducamCamera instance

  • mode – Resolution of the camera module

  • pixel_format – Output image pixel format,which supports JPEG, RGB, YUV

Returns:

Return operation status

CamStatus takeMultiPictures(ArducamCamera *camera, CAM_IMAGE_MODE mode, CAM_IMAGE_PIX_FMT pixel_format, uint8_t number)

Start multi capture with specified number of image.

Note

The mode parameter must be the resolution which the current camera supported

Parameters:
  • cameraArducamCamera instance

  • mode – Resolution of the camera module

  • pixel_format – Output image pixel format,which supports JPEG, RGB, YUV

  • number – Number of pictures taken

Returns:

Return operation status

CamStatus startPreview(ArducamCamera *camera, CAM_VIDEO_MODE mode)

Start preview with specified resolution mode.

Note

Before calling this function, you need to register the callback function.The default image pixel format is JPEG

Parameters:
  • cameraArducamCamera instance

  • mode – Resolution of the camera module

Returns:

Return operation status

void captureThread(ArducamCamera *camera)
CamStatus stopPreview(ArducamCamera *camera)

Stop preview.

Parameters:

cameraArducamCamera instance

Returns:

Return operation status

CamStatus setAutoExposure(ArducamCamera *camera, uint8_t val)

Set the exposure mode.

Parameters:
  • cameraArducamCamera instance

  • val1 Turn on automatic exposure 0 Turn off automatic exposure

Returns:

Return operation status

CamStatus setAbsoluteExposure(ArducamCamera *camera, uint32_t val)

Set the exposure time Manually.

Note

Before calling this function, you need to use the setAutoExposure() function to turn off the auto exposure function

Parameters:
  • cameraArducamCamera instance

  • val – Value of exposure line

Returns:

Return operation status

CamStatus setAutoISOSensitive(ArducamCamera *camera, uint8_t val)

Set the gain mode.

Parameters:
  • cameraArducamCamera instance

  • val1 turn on automatic gain 0 turn off automatic gain

Returns:

Return operation status

CamStatus setISOSensitivity(ArducamCamera *camera, int iso_sense)

Set the exposure time Manually.

Note

Before calling this function, you need to use the setAutoISOSensitive() function to turn off the auto gain function

Parameters:
Returns:

Return operation status

CamStatus setAutoWhiteBalance(ArducamCamera *camera, uint8_t val)

Set white balance mode.

Parameters:
  • cameraArducamCamera instance

  • val1 turn on automatic white balance 0 turn off automatic white balance

Returns:

Return operation status

CamStatus setAutoWhiteBalanceMode(ArducamCamera *camera, CAM_WHITE_BALANCE mode)

Set the white balance mode Manually.

Parameters:
Returns:

Return operation status

CamStatus setColorEffect(ArducamCamera *camera, CAM_COLOR_FX effect)

Set special effects.

Parameters:
  • cameraArducamCamera instance

  • effect – Special effects mode

Returns:

Return operation status

CamStatus setAutoFocus(ArducamCamera *camera, uint8_t val)

Set auto focus mode.

Note

Only 5MP cameras support auto focus control

Parameters:
Returns:

Return operation status

CamStatus setSaturation(ArducamCamera *camera, CAM_STAURATION_LEVEL level)

Set saturation level.

Parameters:
Returns:

Return operation status

CamStatus setEV(ArducamCamera *camera, CAM_EV_LEVEL level)

Set EV level.

Parameters:
Returns:

Return operation status

CamStatus setContrast(ArducamCamera *camera, CAM_CONTRAST_LEVEL level)

Set Contrast level.

Parameters:
Returns:

Return operation status

CamStatus setBrightness(ArducamCamera *camera, CAM_BRIGHTNESS_LEVEL level)

Set Brightness level.

Parameters:
Returns:

Return operation status

CamStatus setSharpness(ArducamCamera *camera, CAM_SHARPNESS_LEVEL level)

Set Sharpness level.

Note

Only 3MP cameras support sharpness control

Parameters:
Returns:

Return operation status

CamStatus setImageQuality(ArducamCamera *camera, IMAGE_QUALITY qualtiy)

Set jpeg image quality.

Note

Only 3MP cameras support sharpness control

Parameters:
Returns:

Return operation status

uint32_t readBuff(ArducamCamera *camera, uint8_t *buff, uint32_t length)

Read image data with specified length to buffer.

Note

Transmission length should be less than 255

Parameters:
  • cameraArducamCamera instance

  • buff – Buffer for storing camera data

  • length – The length of the available data to be read

Returns:

Returns the length actually read

uint8_t readByte(ArducamCamera *camera)

Read a byte from FIFO.

Note

Before calling this function, make sure that the data is available in the buffer

Parameters:

cameraArducamCamera instance

Returns:

Returns Camera data

void debugWriteRegister(ArducamCamera *camera, uint8_t *buff)

Debug mode.

Parameters:
  • cameraArducamCamera instance

  • buff – There are four bytes of buff Byte 1 indicates the device address, Byte 2 indicates the high octet of the register, Byte 3 indicates the low octet of the register, and Byte 4 indicates the value written to the register

void registerCallback(ArducamCamera *camera, BUFFER_CALLBACK function, uint8_t blockSize, STOP_HANDLE handle)

Create callback function.

Note

Transmission length should be less than 255

Parameters:
  • cameraArducamCamera instance

  • function – Callback function name

  • blockSize – The length of the data transmitted by the callback function at one time

  • handle – stop function Callback function name

void lowPowerOn(ArducamCamera *camera)

Turn on low power mode.

Parameters:

cameraArducamCamera instance

void lowPowerOff(ArducamCamera *camera)

Turn off low power mode.

Parameters:

cameraArducamCamera instance

uint8_t cameraHeartBeat(ArducamCamera *camera)

Inform the other party of camera status.

Parameters:

cameraArducamCamera instance

Returns:

Returns camera status

struct SdkDate
#include <ArducamCamera.h>

SDK version update time.

Public Members

uint8_t year
uint8_t month
uint8_t day
uint8_t version
struct SdkInfo
#include <ArducamCamera.h>

Basic information of the sdk.

Public Members

unsigned long sdkVersion

Sdk version

struct SdkDate sdkInfo
struct CameraInfo
#include <ArducamCamera.h>

Basic information of the camera module.

Public Members

char *cameraId

Model of camera module

int supportResolution

Resolution supported by the camera module

int supportSpecialEffects

Special effects supported by the camera module

unsigned long exposureValueMax

Maximum exposure time supported by the camera module

unsigned int exposureValueMin

Minimum exposure time supported by the camera module

unsigned int gainValueMax

Maximum gain supported by the camera module

unsigned int gainValueMin

Minimum gain supported by the camera module

unsigned char supportFocus

Does the camera module support the focus function

unsigned char supportSharpness

Does the camera module support the sharpening function

unsigned char deviceAddress
struct ArducamCamera
#include <ArducamCamera.h>

Camera drive interface and information.

Public Members

int csPin

CS pin

uint32_t totalLength

The total length of the picture

uint32_t receivedLength

The remaining length of the picture

uint8_t blockSize

The length of the callback function transmission

uint8_t cameraId

Model of camera module

uint8_t burstFirstFlag

Flag bit for reading data for the first time in burst mode

uint8_t previewMode

Stream mode flag

uint8_t currentPixelFormat

The currently set image pixel format

uint8_t currentPictureMode

Currently set resolution

struct CameraInfo myCameraInfo

Basic information of the current camera

const struct CameraOperations *arducamCameraOp

Camera function interface

BUFFER_CALLBACK callBackFunction

Camera callback function

STOP_HANDLE handle
uint8_t verDateAndNumber[4]

Camera firmware version

union SdkInfo *currentSDK

Current SDK version

struct ClassCamera

Public Members

ArducamCamera cam
CameraStatus status