mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::improc::milkImage< _dataT > Class Template Reference

template<typename _dataT>
class mx::improc::milkImage< _dataT >

Class to interface with an ImageStreamIO image in shared memory.

Use with Eigen::Map (aliased as mx::improc::eigenMap)

using namespace mx::improc;
milkImage<float> mim("image"); //connects to image.im.shm
eigenMap<float> im(mim); //the conversion operator passes a reference to the internal map
im.setRandom(); // im is now a map pointed at the image data. Eigen functions are now available.
im(64,64) *= 2000;
im /= 0.2;

Once you have changed something via the Eigen::Map you want to notify others connected to the stream via

mim.post();

Definition at line 146 of file milkImage.hpp.

#include <improc/milkImage.hpp>

Public Types

typedef _dataT dataT
 The data type. More...
 

Public Member Functions

 milkImage ()
 Default c'tor. More...
 
 milkImage (const std::string &imname)
 Constructor which opens the specified image. More...
 
void open (const std::string &imname)
 Open and connect to an image, allocating the eigenMap. More...
 
void create (const std::string &imname, uint32_t sz0, uint32_t sz1)
 Create and connect to an image, allocating the eigenMap. More...
 
bool valid ()
 Checks if the image is connected and is still the same format as when connected. More...
 
void reopen ()
 Reopens the image. More...
 
 operator eigenMap< dataT > ()
 Conversion operator returns an eigenMap. More...
 
void post ()
 Update the metadata and post all semaphores. More...
 

Protected Attributes

std::string m_name
 The image name, from name.im.shm (the .im.shm should not be given). More...
 
IMAGE * m_image {nullptr}
 Pointer to the ImageStreamIO IMAGE structure. More...
 
uint64_t m_size_0 {0}
 The size[0] of the image when last opened. More...
 
uint64_t m_size_1 {0}
 The size[1] of the image when last opened. More...
 

Member Typedef Documentation

◆ dataT

template<typename _dataT >
typedef _dataT mx::improc::milkImage< _dataT >::dataT

The data type.

Definition at line 150 of file milkImage.hpp.

Constructor & Destructor Documentation

◆ milkImage() [1/2]

template<typename dataT >
mx::improc::milkImage< dataT >::milkImage

Default c'tor.

Definition at line 234 of file milkImage.hpp.

◆ milkImage() [2/2]

template<typename dataT >
mx::improc::milkImage< dataT >::milkImage ( const std::string &  imname)

Constructor which opens the specified image.

Parameters
[in]imnameThe image name, from name.im.shm (the .im.shm should not be given).

Definition at line 239 of file milkImage.hpp.

Member Function Documentation

◆ create()

template<typename dataT >
void mx::improc::milkImage< dataT >::create ( const std::string &  imname,
uint32_t  sz0,
uint32_t  sz1 
)

Create and connect to an image, allocating the eigenMap.

Exceptions
std::invalid_argumentif the image type_code does not match dataT.
Parameters
[in]imnameThe image name, for name.im.shm (the .im.shm should not be given).
[in]sz0the x size of the image
[in]sz1the y size of the image

Definition at line 279 of file milkImage.hpp.

◆ open()

template<typename dataT >
void mx::improc::milkImage< dataT >::open ( const std::string &  imname)

Open and connect to an image, allocating the eigenMap.

Exceptions
std::invalid_argumentif the image type_code does not match dataT.
Parameters
[in]imnameThe image name, from name.im.shm (the .im.shm should not be given).

Definition at line 245 of file milkImage.hpp.

◆ operator eigenMap< dataT >()

template<typename dataT >
mx::improc::milkImage< dataT >::operator eigenMap< dataT >

Conversion operator returns an eigenMap.

Use this like

milkImage<float> mim("imname");
eigenMap<float> im(mim); //you now have an Eigen interface to the image

but with caution:

  • there is no way to know if the image has changed

Note: we assume this does a move

Returns
an Eigen::Map<Array,-1,-1> object
Exceptions
mx::err::mxExceptionif the image is not opened

Definition at line 323 of file milkImage.hpp.

◆ post()

template<typename dataT >
void mx::improc::milkImage< dataT >::post

Update the metadata and post all semaphores.

Exceptions
mx::err::mxExceptionif the image is not opened

Definition at line 380 of file milkImage.hpp.

◆ reopen()

template<typename dataT >
void mx::improc::milkImage< dataT >::reopen

Reopens the image.

Same as

close();
std::string m_name
The image name, from name.im.shm (the .im.shm should not be given).
Definition: milkImage.hpp:154
void open(const std::string &imname)
Open and connect to an image, allocating the eigenMap.
Definition: milkImage.hpp:245

Definition at line 339 of file milkImage.hpp.

◆ valid()

template<typename dataT >
bool mx::improc::milkImage< dataT >::valid

Checks if the image is connected and is still the same format as when connected.

Checks on pointer value, size[], and data_type.

Returns
true if connected and no changes
false if not connected or something changed. All maps are now invalid.

Definition at line 361 of file milkImage.hpp.

Member Data Documentation

◆ m_image

template<typename _dataT >
IMAGE* mx::improc::milkImage< _dataT >::m_image {nullptr}
protected

Pointer to the ImageStreamIO IMAGE structure.

Definition at line 156 of file milkImage.hpp.

◆ m_name

template<typename _dataT >
std::string mx::improc::milkImage< _dataT >::m_name
protected

The image name, from name.im.shm (the .im.shm should not be given).

Definition at line 154 of file milkImage.hpp.

◆ m_size_0

template<typename _dataT >
uint64_t mx::improc::milkImage< _dataT >::m_size_0 {0}
protected

The size[0] of the image when last opened.

Definition at line 160 of file milkImage.hpp.

◆ m_size_1

template<typename _dataT >
uint64_t mx::improc::milkImage< _dataT >::m_size_1 {0}
protected

The size[1] of the image when last opened.

Definition at line 162 of file milkImage.hpp.


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