Public Member Functions | Public Attributes | List of all members
crl::multisense::image::Header Class Reference

#include <MultiSenseTypes.hh>

Inheritance diagram for crl::multisense::image::Header:
Inheritance graph
[legend]

Public Member Functions

 Header ()
 
virtual bool inMask (DataSource mask)
 
- Public Member Functions inherited from crl::multisense::HeaderBase
virtual ~HeaderBase ()
 

Public Attributes

uint32_t bitsPerPixel
 
uint32_t exposure
 
int64_t frameId
 
float framesPerSecond
 
float gain
 
uint32_t height
 
const void * imageDataP
 
uint32_t imageLength
 
DataSource source
 
uint32_t timeMicroSeconds
 
uint32_t timeSeconds
 
uint32_t width
 

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 399 of file MultiSenseTypes.hh.

Constructor & Destructor Documentation

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

Default Constructor

Definition at line 431 of file MultiSenseTypes.hh.

Member Function Documentation

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 438 of file MultiSenseTypes.hh.

Member Data Documentation

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

Bits per pixel in the image

Definition at line 405 of file MultiSenseTypes.hh.

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

The image exposure time in microseconds

Definition at line 418 of file MultiSenseTypes.hh.

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

Unique ID used to describe an image. FrameIds increase sequentally from the device

Definition at line 411 of file MultiSenseTypes.hh.

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

The number of frames per second currently streaming from the device

Definition at line 422 of file MultiSenseTypes.hh.

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

The imager gain the image was captured with

Definition at line 420 of file MultiSenseTypes.hh.

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

Height of the image

Definition at line 409 of file MultiSenseTypes.hh.

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

A pointer to the image data

Definition at line 426 of file MultiSenseTypes.hh.

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

The length of the image data stored in imageDataP

Definition at line 424 of file MultiSenseTypes.hh.

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

DataSource corresponding to imageDataP

Definition at line 403 of file MultiSenseTypes.hh.

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

The time microseconds value corresponding to when the image was captured

Definition at line 415 of file MultiSenseTypes.hh.

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

The time seconds value corresponding to when the image was captured

Definition at line 413 of file MultiSenseTypes.hh.

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

Width of the image

Definition at line 407 of file MultiSenseTypes.hh.


The documentation for this class was generated from the following file:


multisense_lib
Author(s):
autogenerated on Sun Mar 14 2021 02:34:50