LibMultiSense
LibMultiSense Documentation
crl::multisense::image::Header Class Reference

Class containing image Header information common to all image types. More...

#include <MultiSenseTypes.hh>

Inheritance diagram for crl::multisense::image::Header:
Collaboration diagram for crl::multisense::image::Header:

Public Member Functions

 Header ()
 Default Constructor. More...
 
virtual bool inMask (DataSource mask)
 Member function used to determine if the data contained in the header is contained in a specific image mask. More...
 
- Public Member Functions inherited from crl::multisense::HeaderBase
virtual ~HeaderBase ()
 

Public Attributes

DataSource source
 DataSource corresponding to imageDataP. More...
 
uint32_t bitsPerPixel
 Bits per pixel in the image. More...
 
uint32_t width
 Width of the image. More...
 
uint32_t height
 Height of the image. More...
 
int64_t frameId
 Unique ID used to describe an image. More...
 
uint32_t timeSeconds
 The time seconds value corresponding to when the image was captured. More...
 
uint32_t timeMicroSeconds
 The time microseconds value corresponding to when the image was captured. More...
 
uint32_t exposure
 The image exposure time in microseconds. More...
 
float gain
 The imager gain the image was captured with. More...
 
float framesPerSecond
 The number of frames per second currently streaming from the device. More...
 
uint32_t imageLength
 The length of the image data stored in imageDataP. More...
 
const void * imageDataP
 A pointer to the image data. More...
 

Detailed Description

Class containing image Header information common to all image types.

This will be passed to any callback, of type image::Callback, that is subscribed to image data.

See crl::multisense::Channel::addIsolatedCallback for more details

Example code to extract 8 bit image data from a image header and display it using OpenCV (header.bitsPerPixel = 8)

#include <iostream>
#include <stdexcept>
#include <signal.h>
#include <unistd.h>
//
// Note this example has only been tested under Linux
#include <opencv2/opencv.hpp>
volatile bool doneG = false;
void signalHandler(int sig)
{
std::cerr << "Shutting down on signal: " << strsignal(sig) << std::endl;
doneG = true;
}
class Camera
{
public:
Camera(crl::multisense::Channel* channel);
~Camera();
void imageCallback(const crl::multisense::image::Header& header);
private:
};
namespace {
//
// Shim for the C-style callbacks accepted by
// crl::mulisense::Channel::addIsolatedCallback
void monoCallback(const crl::multisense::image::Header& header, void* userDataP)
{ reinterpret_cast<Camera*>(userDataP)->imageCallback(header); }
};
Camera::Camera(crl::multisense::Channel* channel):
m_channel(channel)
{
//
// Attach our monoCallback to our Channel instance. It will get
// called every time there is new Left Luma or Right luma image
// data.
status = m_channel->addIsolatedCallback(monoCallback,
this);
//
// Check to see if the callback was successfully attached
throw std::runtime_error("Unable to attach isolated callback");
}
//
// Start streaming luma images for the left and right cameras.
//
// Check to see if the streams were sucessfully started
throw std::runtime_error("Unable to start image streams");
}
}
Camera::~Camera()
{
//
// Remove our isolated callback.
status = m_channel->removeIsolatedCallback(monoCallback);
//
// Check to see if the callback was successfully removed
throw std::runtime_error("Unable to remove isolated callback");
}
//
// Stop streaming luma images for the left and right cameras
//
// Check to see if the image streams were successfully stopped
throw std::runtime_error("Unable to stop streams");
}
}
void Camera::imageCallback(const crl::multisense::image::Header& header)
{
//
// Create a container for the image data
std::vector<uint8_t> imageData;
imageData.resize(header.imageLength);
//
// Copy image data from the header's image data pointer to our
// image container
memcpy(&(imageData[0]), header.imageDataP, header.imageLength);
//
// Create a OpenCV matrix using our image container
cv::Mat_<uint8_t> imageMat(header.height, header.width, &(imageData[0]));
//
// Display the image using OpenCV
cv::namedWindow("Example");
cv::imshow("Example", imageMat);
cv::waitKey(1000./header.framesPerSecond);
}
int main()
{
//
// Setup a signal handler to kill the application
signal(SIGINT, signalHandler);
//
// Instantiate a channel connecting to a sensor at the factory default
// IP address
channel = crl::multisense::Channel::Create("10.66.171.21");
channel->setMtu(7200);
try
{
Camera camera(channel);
while(!doneG)
{
usleep(100000);
}
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
}
//
// Destroy the channel instance
}

Definition at line 453 of file MultiSenseTypes.hh.

Constructor & Destructor Documentation

◆ Header()

crl::multisense::image::Header::Header ( )
inline

Default Constructor.

Definition at line 485 of file MultiSenseTypes.hh.

Member Function Documentation

◆ inMask()

virtual bool crl::multisense::image::Header::inMask ( DataSource  mask)
inlinevirtual

Member function used to determine if the data contained in the header is contained in a specific image mask.

Reimplemented from crl::multisense::HeaderBase.

Definition at line 492 of file MultiSenseTypes.hh.

Member Data Documentation

◆ bitsPerPixel

uint32_t crl::multisense::image::Header::bitsPerPixel

Bits per pixel in the image.

Definition at line 459 of file MultiSenseTypes.hh.

◆ exposure

uint32_t crl::multisense::image::Header::exposure

The image exposure time in microseconds.

Definition at line 472 of file MultiSenseTypes.hh.

◆ frameId

int64_t crl::multisense::image::Header::frameId

Unique ID used to describe an image.

FrameIds increase sequentally from the device

Definition at line 465 of file MultiSenseTypes.hh.

◆ framesPerSecond

float crl::multisense::image::Header::framesPerSecond

The number of frames per second currently streaming from the device.

Definition at line 476 of file MultiSenseTypes.hh.

◆ gain

float crl::multisense::image::Header::gain

The imager gain the image was captured with.

Definition at line 474 of file MultiSenseTypes.hh.

◆ height

uint32_t crl::multisense::image::Header::height

Height of the image.

Definition at line 463 of file MultiSenseTypes.hh.

◆ imageDataP

const void* crl::multisense::image::Header::imageDataP

A pointer to the image data.

Definition at line 480 of file MultiSenseTypes.hh.

◆ imageLength

uint32_t crl::multisense::image::Header::imageLength

The length of the image data stored in imageDataP.

Definition at line 478 of file MultiSenseTypes.hh.

◆ source

DataSource crl::multisense::image::Header::source

DataSource corresponding to imageDataP.

Definition at line 457 of file MultiSenseTypes.hh.

◆ timeMicroSeconds

uint32_t crl::multisense::image::Header::timeMicroSeconds

The time microseconds value corresponding to when the image was captured.

Definition at line 469 of file MultiSenseTypes.hh.

◆ timeSeconds

uint32_t crl::multisense::image::Header::timeSeconds

The time seconds value corresponding to when the image was captured.

Definition at line 467 of file MultiSenseTypes.hh.

◆ width

uint32_t crl::multisense::image::Header::width

Width of the image.

Definition at line 461 of file MultiSenseTypes.hh.


The documentation for this class was generated from the following file:
crl::multisense::Channel
Class which manages all communications with a MultiSense device.
Definition: MultiSenseChannel.hh:69
crl::multisense::Status_Ok
static CRL_CONSTEXPR Status Status_Ok
Definition: MultiSenseTypes.hh:98
crl::multisense::Source_Luma_Left
static CRL_CONSTEXPR DataSource Source_Luma_Left
Definition: MultiSenseTypes.hh:120
crl::multisense::image::Header::height
uint32_t height
Height of the image.
Definition: MultiSenseTypes.hh:463
MultiSenseChannel.hh
MultiSenseTypes.hh
crl::multisense::image::Header::imageLength
uint32_t imageLength
The length of the image data stored in imageDataP.
Definition: MultiSenseTypes.hh:478
crl::multisense::Source_Luma_Right
static CRL_CONSTEXPR DataSource Source_Luma_Right
Definition: MultiSenseTypes.hh:121
crl::multisense::image::Header::width
uint32_t width
Width of the image.
Definition: MultiSenseTypes.hh:461
crl::multisense::Channel::Destroy
static void Destroy(Channel *instanceP)
Destroy a channel instance that was created using the static member function Channel::Create().
crl::multisense::image::Header::framesPerSecond
float framesPerSecond
The number of frames per second currently streaming from the device.
Definition: MultiSenseTypes.hh:476
crl::multisense::image::Header::imageDataP
const void * imageDataP
A pointer to the image data.
Definition: MultiSenseTypes.hh:480
crl::multisense::Status
int32_t Status
General status typdef used as a return value for get/set crl::multisense::Channel methods.
Definition: MultiSenseTypes.hh:93
crl::multisense::Channel::setMtu
virtual Status setMtu(int32_t mtu)=0
Set the current sensor's MTU.
crl::multisense::image::Header
Class containing image Header information common to all image types.
Definition: MultiSenseTypes.hh:453
crl::multisense::Channel::Create
static Channel * Create(const std::string &sensorAddress)
Create a Channel instance, used to manage all communications with a sensor.