libkovan  1
The kovan standard library
Camera

Functions

VF EXPORT_SYM int camera_open ()
 
VF EXPORT_SYM int camera_open_at_res (enum Resolution res)
 
VF EXPORT_SYM int camera_open_device (int number, enum Resolution res)
 
VF EXPORT_SYM int camera_load_config (const char *name)
 
VF EXPORT_SYM void set_camera_width (int width)
 
VF EXPORT_SYM void set_camera_height (int height)
 
VF EXPORT_SYM int get_camera_width (void)
 
VF EXPORT_SYM int get_camera_height (void)
 
VF EXPORT_SYM int camera_update (void)
 
VF EXPORT_SYM pixel get_camera_pixel (point2 p)
 
VF EXPORT_SYM int get_channel_count (void)
 
VF EXPORT_SYM int get_object_count (int channel)
 
VF EXPORT_SYM const char * get_object_data (int channel, int object)
 
VF EXPORT_SYM int get_object_data_length (int channel, int object)
 
VF EXPORT_SYM double get_object_confidence (int channel, int object)
 
VF EXPORT_SYM int get_object_area (int channel, int object)
 
VF EXPORT_SYM rectangle get_object_bbox (int channel, int object)
 
VF EXPORT_SYM point2 get_object_centroid (int channel, int object)
 
VF EXPORT_SYM point2 get_object_center (int channel, int object)
 
VF EXPORT_SYM void camera_close ()
 
VF EXPORT_SYM void set_camera_config_base_path (const char *const path)
 
VF EXPORT_SYM const unsigned char * get_camera_frame_row (unsigned row)
 
VF EXPORT_SYM const unsigned char * get_camera_frame ()
 

Detailed Description

Function Documentation

VF EXPORT_SYM void camera_close ( )

Cleanup the current camera instance.

See also
camera_open
camera_open_device
VF EXPORT_SYM int camera_load_config ( const char *  name)

Loads the config file specified by name.

Parameters
nameThe configuration to load. Configuration file names are case sensitive.
Note
You must include the config file extension ".conf" in the name parameter.
Returns
1 on success, 0 on failure.
VF EXPORT_SYM int camera_open ( )

Opens the default system camera for use at LOW_RES (160x120).

Returns
1 on success, 0 on failure
See also
camera_open_at_res
camera_open_device
camera_close
VF EXPORT_SYM int camera_open_at_res ( enum Resolution  res)

Opens the default system camera for use at a given resolution.

Parameters
resThe resolution the camera should operate at. This can be:
  • LOW_RES (160x120)
  • MED_RES (320x240)
  • HIGH_RES (640x480)
Returns
1 on success, 0 on failure
See also
camera_open
camera_open_device
camera_close
VF EXPORT_SYM int camera_open_device ( int  number,
enum Resolution  res 
)

Opens a camera for use.

Parameters
numberThe camera's id. 0 is the first camera, 1 is the second camera, etc.
resThe resolution the camera should operate at. This can be:
  • LOW_RES (160x120)
  • MED_RES (320x240)
  • HIGH_RES (640x480)
Returns
1 on success, 0 on failure
See also
camera_open
camera_close
VF EXPORT_SYM int camera_update ( void  )

Pulls a new image from the camera for processing.

Returns
1 on success, 0 on failure.
VF EXPORT_SYM const unsigned char* get_camera_frame ( )

Retrieves the current camera frame as a BGR (BGR888) array. The returned pointer is invalid after camera_update() is called again.

Returns
the current BGR888 camera frame.
VF EXPORT_SYM const unsigned char* get_camera_frame_row ( unsigned  row)

Retrieves the current camera frame row as a BGR (BGR888) array. The returned pointer is invalid after camera_update() is called again.

Returns
the current BGR888 camera frame row.
VF EXPORT_SYM int get_camera_height ( void  )

Gets the camera's y resolution.

Attention
This value might be different than the previously set y resolution. Never assume the y resolution.
Returns
The camera's y resolution, in pixels.
VF EXPORT_SYM pixel get_camera_pixel ( point2  p)
Parameters
pThe point at which the pixel lies.
Returns
The rgb value of the pixel located at point p.
Note
A (r, g, b) value of (-1, -1, -1) will be returned for points that are out of range.
VF EXPORT_SYM int get_camera_width ( void  )

Gets the camera's x resolution.

Attention
This value might be different than the previously set x resolution. Never assume the x resolution.
Returns
The camera's x resolution, in pixels.
VF EXPORT_SYM int get_channel_count ( void  )
Returns
Number of channels in the current configuration.
See also
get_object_count
VF EXPORT_SYM int get_object_area ( int  channel,
int  object 
)
Returns
The object's bounding box area. -1 is returned if the channel or object doesn't exist.
VF EXPORT_SYM rectangle get_object_bbox ( int  channel,
int  object 
)
Returns
The bounding box of the given object on the given channel.
VF EXPORT_SYM point2 get_object_center ( int  channel,
int  object 
)
Returns
The (x, y) center of the given object on the given channel.
VF EXPORT_SYM point2 get_object_centroid ( int  channel,
int  object 
)
Returns
The (x, y) centroid of the given object on the given channel.
VF EXPORT_SYM double get_object_confidence ( int  channel,
int  object 
)
Returns
The confidence, between 0.0 and 1.0, that given object on the given channel is significant. If the channel or object doesn't exist, 0.0 is returned.
VF EXPORT_SYM int get_object_count ( int  channel)
Parameters
channelThe channel to scan for objects.
Note
Objects are sorted by area, largest first.
Returns
Number of objects in the given channel, -1 if channel doesn't exist.
See also
get_channel_count
VF EXPORT_SYM const char* get_object_data ( int  channel,
int  object 
)
Returns
The string data associated with a given object on a given channel. If there is no data associated, 0 is returned.
Note
This data is not guaranteed to be null terminated.
This string pointer will be invalid after a call to camera_update()
See also
get_object_data_length
VF EXPORT_SYM int get_object_data_length ( int  channel,
int  object 
)
Returns
The length of the string data associated with a given object on a given channel. If there is no data associated, 0 is returned. If the channel or object is invalid, 0 is returned.
See also
get_object_data
VF EXPORT_SYM void set_camera_config_base_path ( const char *const  path)

Sets the path in which to look for camera configurations.

Parameters
paththe absolute directory path in which to look for camera configurations.
VF EXPORT_SYM void set_camera_height ( int  height)

Sets the camera's y resolution.

Parameters
widthThe height in pixels
VF EXPORT_SYM void set_camera_width ( int  width)

Sets the camera's x resolution.

Parameters
widthThe width in pixels