|
camera_usb
|
#include <cam_gst.h>
Public Member Functions | |
| CamGst (std::string const &device) | |
| ~CamGst () | |
| void | createDefaultPipeline (bool check_for_valid_params=false, uint32_t width=DEFAULT_WIDTH, uint32_t height=DEFAULT_HEIGHT, uint32_t fps=DEFAULT_FPS, uint32_t bpp=DEFAULT_BPP, base::samples::frame::frame_mode_t mode=base::samples::frame::MODE_UNDEFINED, uint32_t jpeg_quality=DEFAULT_JPEG_QUALITY) |
| void | deletePipeline () |
| bool | startPipeline () |
| void | stopPipeline () |
| bool | getBuffer (std::vector< uint8_t > &buffer, bool blocking_read=false, int32_t timeout=0) |
| bool | skipBuffer () |
| bool | storeImageToFile (std::vector< uint8_t > const &buffer, std::string const &file_name) |
| bool | hasNewBuffer () |
| bool | isPipelineRunning () |
| int | getFileDescriptor () |
Static Public Attributes | |
| static const uint32_t | DEFAULT_WIDTH = 640 |
| static const uint32_t | DEFAULT_HEIGHT = 480 |
| static const uint32_t | DEFAULT_FPS = 10 |
| static const uint32_t | DEFAULT_BPP = 24 |
| static const uint32_t | DEFAULT_JPEG_QUALITY = 85 |
| static const uint32_t | DEFAULT_PIPELINE_TIMEOUT = 4000000 |
Allows to create a default GStreamer pipeline, which requests images using v4l2src, converts them to jpegs and gives access to the image data. Successfully tested with the Microsoft LifeCam Cinema Web camera and the Gumstix e-CAM32 camera.
| camera::CamGst::CamGst | ( | std::string const & | device | ) |
Initialize GStreamer and starts the GMainLoop in its own thread.
| device | Only used to configure the GStreamer source (e.g. /dev/video0). |
| cam_config | Pointer to a CamConfig object, used to get a valid image size and fps and for general configurations. |
| camera::CamGst::~CamGst | ( | ) |
Stops the GMainLoop and its thread.
| void camera::CamGst::createDefaultPipeline | ( | bool | check_for_valid_params = false, |
| uint32_t | width = DEFAULT_WIDTH, |
||
| uint32_t | height = DEFAULT_HEIGHT, |
||
| uint32_t | fps = DEFAULT_FPS, |
||
| uint32_t | bpp = DEFAULT_BPP, |
||
| base::samples::frame::frame_mode_t | mode = base::samples::frame::MODE_UNDEFINED, |
||
| uint32_t | jpeg_quality = DEFAULT_JPEG_QUALITY |
||
| ) |
Creates a simple pipeline to write images with the requested format to a buffer.
| check_for_valid_params | If set to true the parameters (width, height, fps) are validated. If they are not valid on the camera valid parameters are used. In addition if you pass 0 for a parameter, the last valid parameter on the camera will be used. E.g. 'createDefaultPipeline(true,0,0,0,80)' would just change the JPEG quality. But for this functionality a CamConfig object has to be created, which uses the same device like GStreamer what should be avoided. In addition using this method within the CamUsb driver is not necessary because all parameters have been validated and set already. If set to false the pipeline may not be created if the parameters are not supported by the camera (a CamGstException may be thrown). |
| mode | Valid modes: MODE_GRAYSCALE, MODE_RGB, MODE_UYVY, MODE_JPEG. If MODE_UNDEFINED is passed the raw image video/x-raw-yuv will be requested. |
| void camera::CamGst::deletePipeline | ( | ) |
Deletes pipeline, clears buffer.
| bool camera::CamGst::getBuffer | ( | std::vector< uint8_t > & | buffer, |
| bool | blocking_read = false, |
||
| int32_t | timeout = 0 |
||
| ) |
Allows to request a copy of the new image.
| buffer | Will receive the image if available. |
| blocking_read | If true, method will return as soon as a new image is available. |
| timeout | Max. time to wait for the frame in msec. < 1 means no timeout. |
|
inline |
Returns the file descriptor used by GStreamer. The pipeline has to be running, otherwise -1 will be returned.
|
inline |
True if a new buffer is available.
|
inline |
| bool camera::CamGst::skipBuffer | ( | ) |
Just sets mNewBuffer to false.
| bool camera::CamGst::startPipeline | ( | ) |
Starts current pipeline in another a intern GStreamer thread. Pipeline has to be already created. Restarting may not work, in this case an error message will be printed and false will be returned.
| void camera::CamGst::stopPipeline | ( | ) |
| bool camera::CamGst::storeImageToFile | ( | std::vector< uint8_t > const & | buffer, |
| std::string const & | file_name | ||
| ) |
Stores the image to a file.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
1.8.6