video_capture_start video_capture_stop navigation bar

Table of Contents

video_capture_read

Read one frame from the image source.

Description

The video_capture_read function reads one frame from the image source. The image is stored in the image buffer supplied. A value of 1 is returned if a new image is read. It teturns 0 if no new image is currently available. Otherwise it returns a negative error code.

Prototype

t_error
video_capture_read(t_video_capture capture, void * image_data);
    

Parameters

t_video_capture capture

A handle to the video capture session, as returned by video_capture_open.

void * image_data

A buffer for storing the image captured from the video capture device. The buffer memory to which this argument points must be large enough to hold an entire frame i.e., frame_width * frame_width * number of image planes * sizeof(image data type).

Return value

The return value is 1 if a new image is read. If there is no new image available then zero is returned. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_INVALID_ARGUMENT

An invalid capture session was passed as an argument. Once a capture session has been closed using video_capture_read the session handle is invalid.

Requirements

Include Files

Libraries

quanser_video.h

quanser_media.lib;quanser_communications.lib;quanser_runtime.lib;quanser_common.lib

Examples

t_video_capture capture;
t_error result = video_capture_open("video://localhost:0", 30.0, 640, 480, IMAGE_FORMAT_COL_MAJOR_PLANAR_RGB, IMAGE_DATA_TYPE_UINT8, &capture, NULL, 0);
if (result >= 0) {
    result = video_capture_start(capture);
    if (result >= 0) {
        t_uint8 image[480*640*3];
        
        result = video_capture_read(capture, image);
        if (result > 0) {
            ... process image ...
        }
        video_capture_stop(capture);
    }
    video_capture_close(capture);
} else {
    TCHAR message[512];
    msg_get_error_message(NULL, result, message, sizeof(message));
    _tprintf(_T("Failed to open video capture session. %s (error %d)\n"), message, -result);
}
    

See Also

 

navigation bar