Public Member Functions
sal3d::RangeMap Class Reference

A 2D array of detected laser peak positions constituting a distorted 3D representation of an object. More...

#include <RangeMap.hpp>

List of all members.

Public Member Functions

 RangeMap (int profilesLength, int maxProfiles)
 Creates a new empty range map.
 RangeMap (const std::string &fileName)
 Creates a new range map from file.
 RangeMap (const Frame &frame, int plane)
 Creates a new range map getting the data from a Frame.
 RangeMap (const RangeMap &rangeMap)
 Copy constructor.
 RangeMap (sal3d_range_map rangemap)
 Constructor from a C sal3d_range_map. Creates a C++ object that holds it.
 ~RangeMap ()
 Destructor.
RangeMap copy () const
 Get a deep copy of the RangeMap.
int countProfiles () const
 Gets the number of profiles the range map has.
int maxProfiles () const
 Gets the maximum number of profiles the range map can have.
sal3d_range_map c_range_map () const
 Returns the C pointer to a rangemap.
RangeMapoperator= (const RangeMap &rhs)
 Assignment operator.
Profile getNewProfile () const
 Gets the next empty range map's Profile.
const Profile operator[] (int index) const
 Gets the const Profile at position index.
Profile operator[] (int index)
 Gets the Profile at position index.
int profilesLength () const
 Gets the length of the profiles in the rangemap.
Frame newFrame () const
 Creates a Frame from the current range map.
void saveToFile (const std::string &fileName) const
 Saves the range map to a file.

Detailed Description

A 2D array of detected laser peak positions constituting a distorted 3D representation of an object.

This class requires linking with acquire.lib (import library for acquire.dll).

A RangeMap is composed of Profiles, each of which containing the positions of the laser peak in a Frame. The process for which a range map is filled with this information is briefly explained in Acquisition Overview.

Points in a RangeMap are referred by their u, v and g coordinates, where u is the Profile index (corresponding to the u'th row of the range map), v is the position within a Profile (or the column in the range map) and g is the value storing the position of the laser stripe at that point.

A RangeMap can be created by specifying its size or from a Frame. When creating from size, the user must specify the length of the profiles and the maximum number of profiles that the range map could have. When creating from Frame, a range map the same size as the image is created, with each element having the same value as the corresponding pixel in the image.

The RangeMap copy constructor does not copy the internal Profiles, but instead keeps reference counting for the internal information. That internal information is destroyed at destruction of the last RangeMap object referencing it.

Example of RangeMap acquisition

To show an example of the acquisition procedure, we will use the PeakFinderH module of SAL3D even though, as stated above, any function capable of filling a Profile from a RangeMap would be suitable. In the example, we stop accumulating profiles when the range map is full or when a timeout from the frame grabber is received. Other conditions could be used as needed.

 sal3d::RangeMap
 getRangeMap(sal3d::FrameGrabber fg, int maxProfiles, int timeout)
 {
     sal3d::PeakFinderH finder(threshold);
     std::auto_ptr<sal3d::RangeMap> rmap;

     fg.grab();

     // Consider the RangeMap finished when it acquired maxProfiles
     while(rmap.countProfiles() < maxProfiles)
     {
         try
         {
             fg.wait(timeout);
         } catch (const Timeout &t)
         {
             // Consider the RangeMap finished on timeout.
             break;
         }
         sal3d::Frame f(fg.frame());
         if (rmap.get() == 0)
         {
             const int profilesLen = finder.profileLength(f);
             rmap.reset(new sal3d::RangeMap(profilesLen, maxProfiles));
         }
         sal3d::Profile p(rmap.getNewProfile());
         finder(f, p);
     }

     fg.freeze();

     return *rmap;
 }

Constructor & Destructor Documentation

sal3d::RangeMap::RangeMap ( int  profilesLength,
int  maxProfiles 
) [inline]

Creates a new empty range map.

Both profilesLength and maxProfiles define the size of the RangeMap. If the SAL3D PeakFinderH is used, given a sample frame one can use the PeakFinderH::profileLength() method to obtain profilesLength. maxProfiles defines the maximum number of Profiles that the RangeMap is able to store.

Remarks:
maxProfiles is just an internal limit. All operations that deal with range maps (save to file, convert into a COP, ...) only take into account the current number of Profiles, given by countProfiles().
Parameters:
[in]profilesLengthThe length of the profiles in the range map.
[in]maxProfilesThe maximum number of profiles that the range map will be able to store.
Exceptions:
sal3d::ErrorOn error

Referenced by copy().

sal3d::RangeMap::RangeMap ( const std::string &  fileName) [inline, explicit]

Creates a new range map from file.

Remarks:
The new RangeMap is created with maxProfiles equal to the number of Profiles in the range map. Thus, it is not possible to add more Profiles to the range map.
Parameters:
[in]fileNameThe name of the file to load.
Exceptions:
sal3d::ErrorOn error
sal3d::RangeMap::RangeMap ( const Frame frame,
int  plane 
) [inline]

Creates a new range map getting the data from a Frame.

The newly created RangeMap will have the same size as the Frame, with each g point having the same value as the pixel at that point.

Remarks:
The new RangeMap is created with maxProfiles equal to the number of Profiles in the range map. Thus, it is not possible to add more Profiles to the range map.
Parameters:
[in]frameThe frame to get the data from. The resultant range map will have as many profiles as frame's height and each one will have frame's width as length.
[in]planeThe plane to use to get the data from frame.
Exceptions:
sal3d::ErrorOn error

References sal3d::Frame::c_frame().

sal3d::RangeMap::RangeMap ( const RangeMap rangeMap) [inline]

Copy constructor.

Parameters:
[in]rangeMapThe range map to copy from.
sal3d::RangeMap::RangeMap ( sal3d_range_map  rangemap) [inline, explicit]

Constructor from a C sal3d_range_map. Creates a C++ object that holds it.

Warning:
The new C++ RangeMap object will get the ownership of the C range_map, which means that you should not call sal3d_range_map_release() on this range_map, otherwise it would be called twice.
Parameters:
[in]rangemapThe C sal3d_range_map to use to create this object.

Destructor.

If the reference counter reaches zero, the object is destroyed and its memory released.


Member Function Documentation

sal3d_range_map sal3d::RangeMap::c_range_map ( ) const [inline]

Returns the C pointer to a rangemap.

Warning:
Never call sal3d_range_map_release() with the pointer returned by this function or the application will fail.
Returns:
The pointer to sal3d's C interface.

Referenced by sal3d::AngularMetric::calibrate(), sal3d::Metric::calibrate(), sal3d::Merger::calibrate(), sal3d::COP::COP(), and sal3d::Viewer::display().

RangeMap sal3d::RangeMap::copy ( ) const [inline]

Get a deep copy of the RangeMap.

This means that the object and its memory is duplicated. More information about this can be fount at Memory management: reference counting.

Returns:
A RangeMap which is a deep copy of this RangeMap.
Exceptions:
sal3d::ErrorOn error

References RangeMap().

int sal3d::RangeMap::countProfiles ( ) const [inline]

Gets the number of profiles the range map has.

When an empty range map is created, this value is set to zero. Each time the getNewProfile() method is called, this counter is increased.

Returns:
The number of profiles the range map has.

Referenced by sal3d::AngularMetric::calibrate(), and sal3d::Metric::calibrate().

Gets the next empty range map's Profile.

This method is used to get successive Profiles from an empty RangeMap, to fill them in. Each time it is called, the first empty profile is returned and the counter of profiles for the range map is increased, up to maxProfiles. To get a specific profile in the range map, use the operator[] instead.

Remarks:
As the range maps loaded from file or a frame are created with maxProfiles equal to the number of profiles in them, calling this function on them will fail.
Returns:
The first empty profile in the range map.
Exceptions:
sal3d::ErrorOn error
int sal3d::RangeMap::maxProfiles ( ) const [inline]

Gets the maximum number of profiles the range map can have.

When creating an empty range map, this function returns the parameter that was passed to the constructor. For loaded range maps from file, or created from Frame, this function returns the same value as countProfiles().

Returns:
The maximum number of profiles the range map can have.
Frame sal3d::RangeMap::newFrame ( ) const [inline]

Creates a Frame from the current range map.

The created frame will have the same size as the range map, i.e., a width equal to profilesLength() and a height equal to countProfiles(). It will have only one plane, with 32bit floating point data.

Returns:
The newly created Frame.
Exceptions:
sal3d::ErrorOn error
RangeMap& sal3d::RangeMap::operator= ( const RangeMap rhs) [inline]

Assignment operator.

Parameters:
[in]rhsThe range map to copy from.
Returns:
A reference to this object.
const Profile sal3d::RangeMap::operator[] ( int  index) const [inline]

Gets the const Profile at position index.

Parameters:
[in]indexThe index of the profile to get. The allowed range is [0..countProfiles()-1]
Returns:
The const profile with index index.
Exceptions:
sal3d::ErrorOn error
Profile sal3d::RangeMap::operator[] ( int  index) [inline]

Gets the Profile at position index.

Parameters:
[in]indexThe index of the profile to get. The allowed range is [0..countProfiles()-1]
Returns:
The profile with index index.
Exceptions:
sal3d::ErrorOn error
int sal3d::RangeMap::profilesLength ( ) const [inline]

Gets the length of the profiles in the rangemap.

Returns:
The length of the profiles.

Referenced by sal3d::AngularMetric::calibrate(), and sal3d::Metric::calibrate().

void sal3d::RangeMap::saveToFile ( const std::string &  fileName) const [inline]

Saves the range map to a file.

Parameters:
[in]fileNameThe name of the file to save the range map to. The used extension for this type of files is .arm.
Exceptions:
sal3d::ErrorOn error

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