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>
#include <MultiSenseTypes.hh>
#include <MultiSenseChannel.hh>
//
// 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::multisense::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 successfully 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(1500);
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 460 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

Constructor & Destructor Documentation

◆ Header()

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

Default Constructor

Definition at line 492 of file Legacy/include/MultiSense/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 499 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

Member Data Documentation

◆ bitsPerPixel

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

Bits per pixel in the image

Definition at line 466 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ exposure

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

The image exposure time in microseconds

Definition at line 479 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ frameId

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

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

Definition at line 472 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ framesPerSecond

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

The number of frames per second currently streaming from the device

Definition at line 483 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ gain

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

The imager gain the image was captured with

Definition at line 481 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ height

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

Height of the image

Definition at line 470 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ imageDataP

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

A pointer to the image data

Definition at line 487 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ imageLength

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

The length of the image data stored in imageDataP

Definition at line 485 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ source

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

DataSource corresponding to imageDataP

Definition at line 464 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ timeMicroSeconds

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

The time microseconds value corresponding to when the image was captured

Definition at line 476 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ timeSeconds

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

The time seconds value corresponding to when the image was captured

Definition at line 474 of file Legacy/include/MultiSense/MultiSenseTypes.hh.

◆ width

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

Width of the image

Definition at line 468 of file Legacy/include/MultiSense/MultiSenseTypes.hh.


The documentation for this class was generated from the following file:
crl::multisense::Status_Ok
static CRL_CONSTEXPR Status Status_Ok
Definition: Legacy/include/MultiSense/MultiSenseTypes.hh:99
crl::multisense::Channel::Destroy
static void Destroy(Channel *instanceP)
Definition: Legacy/details/channel.cc:863
crl::multisense::Source_Luma_Left
static CRL_CONSTEXPR DataSource Source_Luma_Left
Definition: Legacy/include/MultiSense/MultiSenseTypes.hh:121
main
int main(int argc, char **argvPP)
Definition: AprilTagTestUtility.cc:135
crl::multisense::Channel::setMtu
virtual Status setMtu(int32_t mtu)=0
crl::multisense::Source_Luma_Right
static CRL_CONSTEXPR DataSource Source_Luma_Right
Definition: Legacy/include/MultiSense/MultiSenseTypes.hh:122
crl::multisense::Channel::Create
static Channel * Create(const std::string &sensorAddress)
Definition: Legacy/details/channel.cc:817
crl::multisense::Status
int32_t Status
Definition: Legacy/include/MultiSense/MultiSenseTypes.hh:94
header
std_msgs::Header const * header(const M &m)
crl::multisense::Channel
Definition: Legacy/include/MultiSense/MultiSenseChannel.hh:69
crl::multisense::image::Header
Definition: Legacy/include/MultiSense/MultiSenseTypes.hh:460


multisense_lib
Author(s):
autogenerated on Thu Apr 17 2025 02:49:10