ark::image::VideoDevice

Defined in header “ark/image/video_device.hh”.


This class represents a video device. It allows you to open a single device (video4linux) and then stream camera images. It’s meant to be called from a central command loop.

Methods

  • VideoDevice(VideoDeviceConfiguration config)
    Constructor. Opens up the given device and configures it based on the passed-in configuration. Exceptions if it fails to do so.

  • ~VideoDevice()
    Destructor, cleans up descriptors.

  • const VideoControlTypes & available_controls()
    Get the list of available controls for this device.

  • VideoControlsState get_controls_state()
    Get the desired control state.

  • void set_controls(const std::map< std::string, int64_t > & desired_controls)
    Set the desired control state.

  • void enable_streaming()
    Activates streaming on every configured type. Call this to begin streaming data into the internal buffers for every type.

  • void enable_streaming(VideoStreamType stream_type)
    Activates streaming on the specified type. Call this to begin streaming data into the internal buffers for that type.

  • VideoBufferConfiguration buffer_configuration(VideoStreamType stream_type)
    Returns the buffer configuration for this stream. This contains the actual width/height/format of the images coming over the buffer. Typically this matches what you configured, but in the event that you requested “auto-configure”, this contains the real values.

  • VideoBufferPtr read_buffer(VideoStreamType stream_type)
    Reads the next buffer from the video device. This will hold onto the memory buffer until you release the captured buffer.

    Failure to call release_buffer() once you are done reading from it will cause all of the internal buffers to become exhausted and future calls to block.

  • ScopedVideoBuffer read_scoped_buffer(VideoStreamType stream_type)
    Reads the next buffer from the video device (identically to read_buffer). This is a scoped buffer, and will automatically release back to the device when it falls out of scope.

  • VideoBufferPtr write_buffer(VideoStreamType stream_type)
    Retrieves a buffer for writing. It is expected that you will fill in the frame information, and then call release_buffer() when you are done.

  • void release_buffer(VideoStreamType stream_type, VideoBufferPtr & buffer)
    When you have finished reading the given buffer, call this to release its resources back to this device.

  • bool wait_for(std::chrono::nanoseconds duration)
    Waits for at least one camera image to be available for reading. If the duration expires before a image is ready, this will return false.