![]() |
capture
|
Capture Interface, for reading images. More...
Go to the source code of this file.
Macros | |
#define | IMAGE_JPEG |
The media_type for a JPEG stream. (RGB colorspace) | |
#define | IMAGE_UNCOMPRESSED |
The media_type for an uncompressed YUV stream. YUV Format can be specified using media property option "sdk_format=<format>". See VIDEO_FORMAT_*. More... | |
#define | VIDEO_H264 |
The media_type for an H.264 stream. The stream consists of a sequence of packetized network abstraction layer units (NALUs). The first four bytes in the stream defines the lenght of the packet. Media property option "&spsppsenabled=yes|no" can be used to include SPS (Sequence Parameter Set) and PPS (Picture Parameter Set) in the stream. | |
#define | VIDEO_FORMAT_Y800 |
#define | VIDEO_FORMAT_I420 |
#define | VIDEO_FORMAT_UYVY |
#define | CAPTURE_TIME_FORMAT |
The format used when printing capture_time. | |
Typedefs | |
typedef struct _stream_info | stream_info |
typedef struct _media_stream | media_stream |
typedef struct _media_frame | media_frame |
typedef unsigned long long | capture_time |
The datatype to hold a timestamp for the time of capture for a frame, measured in nanoseconds for the system uptime (CLOCK_MONOTONIC). | |
Functions | |
media_stream * | capture_open_stream (const char *media_type, const char *media_props) |
Opens a new stream of the specified media type with the specified properties. More... | |
media_frame * | capture_get_frame (media_stream *stream) |
Read a media_frame from an open stream. More... | |
media_frame ** | capture_get_burst (media_stream *stream) |
void * | capture_frame_data (const media_frame *frame) |
Obtain the data from the media_frame. More... | |
size_t | capture_frame_size (const media_frame *frame) |
Obtain the data size from the media_frame. More... | |
capture_time | capture_frame_timestamp (const media_frame *frame) |
Obtain the timestamp of the media_frame, measured in nanoseconds. More... | |
size_t | capture_frame_height (const media_frame *frame) |
Obtain the height of the media_frame. More... | |
size_t | capture_frame_width (const media_frame *frame) |
Obtain the width of the media_frame. More... | |
size_t | capture_frame_stride (const media_frame *frame) |
Obtain the stride length of the Y800 media_frame. More... | |
void | capture_frame_free (media_frame *frame) |
Free the media_frame retrieved from capture_get_frame(). More... | |
void | capture_burst_free (media_frame **frames) |
void | capture_close_stream (media_stream *stream) |
Close a running stream. More... | |
stream_info ** | capture_stream_info_get () |
Get information about the stream currently running on the camera. More... | |
char * | capture_stream_info_props (const stream_info *info) |
Obtain the properties of the stream. More... | |
char * | capture_stream_info_type (const stream_info *info) |
Obtain the type of the stream. More... | |
void | capture_stream_info_free (stream_info **info) |
Free the array of stream_info acquired by capture_strem_info_get. More... | |
char * | capture_get_resolutions_list (int channel) |
Returns a list with all available resolutions for the current capture mode. More... | |
char * | capture_get_optimal_resolutions_list (int channel) |
Returns a list with the most optimal resolutions with respect to performance for the current capture mode. More... | |
Capture Interface, for reading images.
The capture interface contains functions for opening and closing an image stream and for reading image frames from the stream.
The media_type parameter of the capture_open_stream function defines what kind of stream to open. Right now It can be IMAGE_JPEG
for a JPEG stream or IMAGE_UNCOMPRESSED
for a stream of uncompressed YUV images. The default YUV type is planar I420 but other formats can be specified by using the media_props
argument to capture_open_stream()
. Note: Retrieval of uncompressed is only supported on products with major version 0 of the capture interface.
The media_props
argument is an extended version of the VAPIX option string. The following options are availble for the different stream types.
For JPEG images the media_props
argument accepts the same kind of parameters as specified in the VAPIX.
Read more at http://www.axis.com/techsup/cam_servers/dev/cam_http_api_2.php#api_blocks_image_video_mjpg_video
Note: Retrieval of uncompressed is only supported on products with major version 0 of the capture interface.
For uncompressed YUV images the following parameters are defined:
The fps parameter specifies the frame rate of the images being pushed out on the stream.
The sdk_format string is in FOURCC format. A FOURCC is a sequence of four bytes used do identify data formats. Supported formats include:
For ARTPEC-4 based products UYVY is native and require no internal conversion
The resolution string specifies the dimensions of the images in the stream. The syntax is the same as the corresponding VAPIX parameter.
The Burst mode, capture_get_burst()
is no longer supported. This function will always return NULL.
The new VAPIX parameters cropsize and croppos can be used to read a cropped area from an image. To read an area of 160x120 from an 640x480 image, apply the VAPIX parameters:
To support the processing enhancements provided by the RAPP library, uncompressed Y800 images will consist of aligned image data. And the interface defines a row length, called stride. Each uncompressed Y800 image is described by data, width, height and stride:
Pointer to the pixel data. The pixel data buffer is aligned. The alignment number is platform specific and compatible with the RAPP library.
The width of the image in number of pixels.
The height of the image in number of pixels.
The length of the rows in the image in bytes. The stride value is aligned and can be greater than the image width.
The stride of the image needs to be taken into account when working with Y800 images. After the first width bytes of image data,
the row is padded to achieve the stride. When a Y800 image with a resolution of 350x288 is requested each row has a length of 350
bytes image data and then a 2 byte padding, giving a stride of 352.
There is also an architecture dependent interface, called native. It can be used to read YUV images in the format native to the current hardware. (UYVY on artpec-3 and artpec-4, NV12 on ambarella-a5s) Through the interface, width and height is specified and a pointer to a buffer of YUV data can be read. The memory for the buffer is reused and it needs to be copied if it is to be saved. If the application need to be fast and the format of YUV or the need to use VAPIX functionality like cropping is not important, then this interface can be useful
In this section some examples of how to use the Capture interface is shown.
This will request a stream of JPEG images, with a framerate of 10 images per second.
Note: Retrieval of uncompressed is only supported on products with major version 0 of the capture interface.
A more complete example of how to use the capture interface. This will request a stream of Y800 uncompressed images, the different media_props
options are also documented in the VAPIX API at http://www.axis.com/techsup/cam_servers/dev/cam_http_api_index.php
The code will retrieve a frame of Y800 data and write it as a pgm-file. The stride is needed to make sure the image gets written correctly.
An example of how to use the architecture dependent interface. Note: The architecture dependent interface is only supported on products with major version 0 of the capture interface.
An example of how to use the architecture dependent interface when images from a specific video channel is requested. Note: The architecture dependent interface is only supported on products with major version 0 of the capture interface.
To build a program using the capture interface you need to supply the library name as -lcapture
. And you need to include the header file capture.h
.
The capture interface is available for development and debugging in a PC environment. The library is called capturehost (-lcapturehost)and the interface can read existing mjpeg files. Needed are a Linux PC and an Axis camera or video encoder connected to the PC via LAN.
Supported formats are: - Y800 - I420
This is an example of how to use the capture interface on the host.
Note 1: replace <IP> with the IP address of the camera. Replace <user> with an existing user, and <password> with the password of this user.
Note 2: the capture-camera must be the first item in media_props, capture-pass the second, and followed by all other media_props
Note 3: The capturehost interface will use an http proxy whenever the environment variable http_proxy is set using the same principle as curl.
This is an example of how to use the capturehost interface with an existing mjpeg file.
First, acquire an mjpeg file from a camera.
Then use this mjpeg file to retrieve gray scale frames.
The capturehost interface is able to reduce the frame rate of an existing mjpeg file selecting a few frames and ignoring the rest, for example, 5 fps can be reduced 1 fps by picking 1 frame and ignoring 4 frames. The capturehost interface can simulate real-time timing of the requested fps by blocking the caller a short while and downscaling the resolution by skipping pixels.
On host it is also possible to read a mjeg file from STDIN. In this case the call to capture_open_stream() takes no capture-cameraIP parameter.
For example to use the file sunset.mjpeg with the host program 'my_host_viewer' reading from STDIN:
#define IMAGE_UNCOMPRESSED |
The media_type for an uncompressed YUV stream. YUV Format can be specified using media property option "sdk_format=<format>". See VIDEO_FORMAT_*.
media_stream* capture_open_stream | ( | const char * | media_type, |
const char * | media_props | ||
) |
Opens a new stream of the specified media type with the specified properties.
The function will open a stream of the specified media type in the camera. The stream will be taken from an universal cache. If the media type with the specified properties already is running in the camera, they will share the data.
media_type | The specified media type of the stream. |
media_props | The properties of the media type, represented as VAPIX option string. |
media_frame* capture_get_frame | ( | media_stream * | stream | ) |
Read a media_frame from an open stream.
The function will get a frame of data from the stream and return it. The frame contains the data, the size and the timestamp. The frame needs to be freed after use, using capture_frame_free.
stream | The structure associated with the stream. |
media_frame** capture_get_burst | ( | media_stream * | stream | ) |
void* capture_frame_data | ( | const media_frame * | frame | ) |
Obtain the data from the media_frame.
frame | The media_frame to obtain data from. |
size_t capture_frame_size | ( | const media_frame * | frame | ) |
Obtain the data size from the media_frame.
frame | The media_frame to obtain data size from. |
capture_time capture_frame_timestamp | ( | const media_frame * | frame | ) |
Obtain the timestamp of the media_frame, measured in nanoseconds.
The returned value is nanoseconds for the system uptime (CLOCK_MONOTONIC).
If the frame is jpeg, the same information is found in the jpeg header.
Additional note: if there are 2 different stream used, with different resolution or framerate, then there is no guarantee, that both streams deliver frames which have the same source image (from the sensor or camera). But if the timestamps are identical, then they have the same source image.
frame | The media_frame to obtain timestamp from. |
size_t capture_frame_height | ( | const media_frame * | frame | ) |
Obtain the height of the media_frame.
frame | The media_frame to obtain height from. |
size_t capture_frame_width | ( | const media_frame * | frame | ) |
Obtain the width of the media_frame.
frame | The media_frame to obtain width from. |
size_t capture_frame_stride | ( | const media_frame * | frame | ) |
Obtain the stride length of the Y800 media_frame.
frame | The media_frame to obtain stride length from. |
void capture_frame_free | ( | media_frame * | frame | ) |
Free the media_frame retrieved from capture_get_frame().
frame | pointer to the media_frame received from capture_get_frame() |
void capture_burst_free | ( | media_frame ** | frames | ) |
void capture_close_stream | ( | media_stream * | stream | ) |
Close a running stream.
The function closes the specified stream.
stream | The structure associated with the stream. |
stream_info** capture_stream_info_get | ( | ) |
Get information about the stream currently running on the camera.
char* capture_stream_info_props | ( | const stream_info * | info | ) |
Obtain the properties of the stream.
info | The stream_info to obtain the properties of. |
char* capture_stream_info_type | ( | const stream_info * | info | ) |
Obtain the type of the stream.
info | The stream_info to obtain the type of. |
void capture_stream_info_free | ( | stream_info ** | info | ) |
Free the array of stream_info acquired by capture_strem_info_get.
info | The stream_info array. |
char* capture_get_resolutions_list | ( | int | channel | ) |
Returns a list with all available resolutions for the current capture mode.
channel | The videochannel. |
char* capture_get_optimal_resolutions_list | ( | int | channel | ) |
Returns a list with the most optimal resolutions with respect to performance for the current capture mode.
This will be a sub-set from the resolutions achieved by get_resolutions_list(int channel);
channel | The videochannel. |