Skip to content

File ns_camera.h

FileList > includes-api > ns_camera.h

Go to the source code of this file

  • #include "ns_core.h"
  • #include "ns_spi.h"
  • #include "arm_math.h"
  • #include <stdint.h>

Classes

Type Name
struct ns_camera_cfg

Public Types

Type Name
typedef int8_t img_t
typedef struct ns_camera_cfg ns_camera_config_t
typedef void(* ns_camera_dma_cb
enum ns_camera_hw_e
typedef void(* ns_camera_picture_cb
enum ns_image_mode_e
enum ns_image_pix_fmt_e

Public Attributes

Type Name
const ns_core_api_t ns_camera_V1_0_0
const ns_core_api_t ns_camera_current_version
const ns_core_api_t ns_camera_oldest_supported_version

Public Functions

Type Name
void arducam_delay_ms (uint16_t delay)
void arducam_delay_us (uint16_t delay)
int arducam_spi_read (const void * buf, uint32_t bufLen, uint64_t reg, uint32_t regLen, uint32_t csPin)
int arducam_spi_write (const void * buf, uint32_t bufLen, uint64_t reg, uint32_t regLen, uint32_t csPin)
int camera_decode_image (uint8_t * camBuf, uint32_t camLen, uint8_t * imgBuf, uint32_t imgWidth, uint32_t imgHeight, uint32_t scaleFactor)
Converts a JPG to an RGB565 image.
void ns_camera_adjust_settings (int8_t contrast, int8_t brightness, int8_t ev)
Adjust camera settings.
uint32_t ns_camera_init (ns_camera_config_t * cfg)
Initialize the camera.
uint32_t ns_chop_off_trailing_zeros (uint8_t * buff, uint32_t length)
Chop off trailing zeros from a buffer.
int ns_is_camera_capturing ()
Check if camera is still capturing This is a helper function, it should typically only be used by ns_camera.
uint32_t ns_press_shutter_button (ns_camera_config_t * cfg)
Press the shutter button Start the capture process, turns on a timer to poll the camera for completion.
uint32_t ns_start_camera (ns_camera_config_t * cfg)
Start the camera (take out of low power mode)
uint32_t ns_start_dma_read (ns_camera_config_t * cfg, uint8_t * camBuf, uint32_t * buffer_offset, uint32_t bufLen)
Start a DMA read of the camera buffer.
uint32_t ns_stop_camera (ns_camera_config_t * cfg)
Stop the camera (put into low power mode)
uint32_t ns_take_picture (ns_camera_config_t * cfg)
Take a picture in mode specified by cfg Once picture is taken, it can be transferred using ns_transfer_picture.
uint32_t ns_transfer_picture (ns_camera_config_t * cfg, uint8_t * camBuf, uint32_t * buffer_offset, uint32_t bufLen)
Transfer captured frame over SPI to local buffer NOTE: This routine is blocking and will wait for inflight capture.

Macros

Type Name
define NS_CAMERA_API_ID 0xCA000A
define NS_CAMERA_CURRENT_VERSION NS_CAMERA_V1_0_0
define NS_CAMERA_OLDEST_SUPPORTED_VERSION NS_CAMERA_V1_0_0
define NS_CAMERA_V1_0_0 { .major = 1, .minor = 0, .revision = 0 }

Public Types Documentation

typedef img_t

typedef int8_t img_t;

typedef ns_camera_config_t

typedef struct ns_camera_cfg ns_camera_config_t;

typedef ns_camera_dma_cb

typedef void(* ns_camera_dma_cb) (struct ns_camera_cfg *cfg);

enum ns_camera_hw_e

enum ns_camera_hw_e {
    NS_ARDUCAM = 0
};

typedef ns_camera_picture_cb

typedef void(* ns_camera_picture_cb) (struct ns_camera_cfg *cfg);

enum ns_image_mode_e

enum ns_image_mode_e {
    NS_CAM_IMAGE_MODE_QQVGA = 0x00,
    NS_CAM_IMAGE_MODE_QVGA = 0x01,
    NS_CAM_IMAGE_MODE_VGA = 0x02,
    NS_CAM_IMAGE_MODE_SVGA = 0x03,
    NS_CAM_IMAGE_MODE_HD = 0x04,
    NS_CAM_IMAGE_MODE_SXGAM = 0x05,
    NS_CAM_IMAGE_MODE_UXGA = 0x06,
    NS_CAM_IMAGE_MODE_FHD = 0x07,
    NS_CAM_IMAGE_MODE_QXGA = 0x08,
    NS_CAM_IMAGE_MODE_WQXGA2 = 0x09,
    NS_CAM_IMAGE_MODE_96X96 = 0x0a,
    NS_CAM_IMAGE_MODE_128X128 = 0x0b,
    NS_CAM_IMAGE_MODE_320X320 = 0x0c
};

enum ns_image_pix_fmt_e

enum ns_image_pix_fmt_e {
    NS_CAM_IMAGE_PIX_FMT_RGB565 = 0x02,
    NS_CAM_IMAGE_PIX_FMT_JPEG = 0x01
};

Public Attributes Documentation

variable ns_camera_V1_0_0

const ns_core_api_t ns_camera_V1_0_0;

variable ns_camera_current_version

const ns_core_api_t ns_camera_current_version;

variable ns_camera_oldest_supported_version

const ns_core_api_t ns_camera_oldest_supported_version;

Public Functions Documentation

function arducam_delay_ms

void arducam_delay_ms (
    uint16_t delay
) 

function arducam_delay_us

void arducam_delay_us (
    uint16_t delay
) 

function arducam_spi_read

int arducam_spi_read (
    const void * buf,
    uint32_t bufLen,
    uint64_t reg,
    uint32_t regLen,
    uint32_t csPin
) 

function arducam_spi_write

int arducam_spi_write (
    const void * buf,
    uint32_t bufLen,
    uint64_t reg,
    uint32_t regLen,
    uint32_t csPin
) 

function camera_decode_image

Converts a JPG to an RGB565 image.

int camera_decode_image (
    uint8_t * camBuf,
    uint32_t camLen,
    uint8_t * imgBuf,
    uint32_t imgWidth,
    uint32_t imgHeight,
    uint32_t scaleFactor
) 

Parameters:

  • camBuf Buffer containing JPG image
  • camLen Length of JPG image in bytes
  • imgBuf Buffer to store RGB565 image
  • imgWidth Width of RGB565 image
  • imgHeight Height of RGB565 image
  • scaleFactor Scale factor to reduce image size

Returns:

int

Converts a JPG to an RGB565 image.

Parameters:

  • camBuf Camera buffer to decode
  • camLen Length of camera buffer
  • imgBuf Image buffer to store decoded image
  • imgWidth Width of image
  • imgHeight Height of image
  • scaleFactor Scale factor for image

Returns:

int

function ns_camera_adjust_settings

Adjust camera settings.

void ns_camera_adjust_settings (
    int8_t contrast,
    int8_t brightness,
    int8_t ev
) 

Parameters:

  • contrast
  • brightness
  • ev

function ns_camera_init

Initialize the camera.

uint32_t ns_camera_init (
    ns_camera_config_t * cfg
) 

Parameters:

  • cfg

Returns:

uint32_t

function ns_chop_off_trailing_zeros

Chop off trailing zeros from a buffer.

uint32_t ns_chop_off_trailing_zeros (
    uint8_t * buff,
    uint32_t length
) 

Parameters:

  • buff JPG buffer
  • length Adjusted length after trailing zeros are removed

Returns:

uint32_t

function ns_is_camera_capturing

Check if camera is still capturing This is a helper function, it should typically only be used by ns_camera.

int ns_is_camera_capturing () 

Returns:

int

function ns_press_shutter_button

Press the shutter button Start the capture process, turns on a timer to poll the camera for completion.

uint32_t ns_press_shutter_button (
    ns_camera_config_t * cfg
) 

Parameters:

  • cfg

Returns:

uint32_t

function ns_start_camera

Start the camera (take out of low power mode)

uint32_t ns_start_camera (
    ns_camera_config_t * cfg
) 

Parameters:

  • cfg

Returns:

uint32_t

function ns_start_dma_read

Start a DMA read of the camera buffer.

uint32_t ns_start_dma_read (
    ns_camera_config_t * cfg,
    uint8_t * camBuf,
    uint32_t * buffer_offset,
    uint32_t bufLen
) 

Parameters:

  • cfg
  • camBuf Buffer to store image
  • buffer_offset Returned value of buffer offset
  • bufLen Length of buffer

Returns:

uint32_t Total size of image in bytes

function ns_stop_camera

Stop the camera (put into low power mode)

uint32_t ns_stop_camera (
    ns_camera_config_t * cfg
) 

Parameters:

  • cfg

Returns:

uint32_t

function ns_take_picture

Take a picture in mode specified by cfg Once picture is taken, it can be transferred using ns_transfer_picture.

uint32_t ns_take_picture (
    ns_camera_config_t * cfg
) 

Parameters:

  • cfg

Returns:

uint32_t

function ns_transfer_picture

Transfer captured frame over SPI to local buffer NOTE: This routine is blocking and will wait for inflight capture.

uint32_t ns_transfer_picture (
    ns_camera_config_t * cfg,
    uint8_t * camBuf,
    uint32_t * buffer_offset,
    uint32_t bufLen
) 

Parameters:

  • cfg
  • camBuf Camera buffer to store frame
  • buffer_offset JPG images are stored 1 byte offset from start of buffer, so use this to find it
  • bufLen Buffer size

Returns:

uint32_t

Macro Definition Documentation

define NS_CAMERA_API_ID

#define NS_CAMERA_API_ID 0xCA000A

define NS_CAMERA_CURRENT_VERSION

#define NS_CAMERA_CURRENT_VERSION NS_CAMERA_V1_0_0

define NS_CAMERA_OLDEST_SUPPORTED_VERSION

#define NS_CAMERA_OLDEST_SUPPORTED_VERSION NS_CAMERA_V1_0_0

define NS_CAMERA_V1_0_0

#define NS_CAMERA_V1_0_0 { .major = 1, .minor = 0, .revision = 0 }

The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-camera/includes-api/ns_camera.h