A 2D array of detected laser peak positions constituting a distorted 3D representation of an object. More...
#include <RangeMap.hpp>
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. | |
| RangeMap & | operator= (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. | |
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.
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; }
| 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.
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().| [in] | profilesLength | The length of the profiles in the range map. |
| [in] | maxProfiles | The maximum number of profiles that the range map will be able to store. |
| sal3d::Error | On error |
Referenced by copy().
| sal3d::RangeMap::RangeMap | ( | const std::string & | fileName | ) | [inline, explicit] |
Creates a new range map from file.
maxProfiles equal to the number of Profiles in the range map. Thus, it is not possible to add more Profiles to the range map.| [in] | fileName | The name of the file to load. |
| sal3d::Error | On 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.
maxProfiles equal to the number of Profiles in the range map. Thus, it is not possible to add more Profiles to the range map.| [in] | frame | The 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] | plane | The plane to use to get the data from frame. |
| sal3d::Error | On error |
References sal3d::Frame::c_frame().
| sal3d::RangeMap::RangeMap | ( | const RangeMap & | rangeMap | ) | [inline] |
Copy constructor.
| [in] | rangeMap | The 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.
range_map, which means that you should not call sal3d_range_map_release() on this range_map, otherwise it would be called twice.| [in] | rangemap | The C sal3d_range_map to use to create this object. |
| sal3d::RangeMap::~RangeMap | ( | ) | [inline] |
Destructor.
If the reference counter reaches zero, the object is destroyed and its memory released.
| sal3d_range_map sal3d::RangeMap::c_range_map | ( | ) | const [inline] |
Returns the C pointer to a rangemap.
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.
| sal3d::Error | On 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.
Referenced by sal3d::AngularMetric::calibrate(), and sal3d::Metric::calibrate().
| Profile sal3d::RangeMap::getNewProfile | ( | ) | const [inline] |
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.
| sal3d::Error | On 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().
| 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.
| sal3d::Error | On error |
Assignment operator.
| [in] | rhs | The range map to copy from. |
| const Profile sal3d::RangeMap::operator[] | ( | int | index | ) | const [inline] |
Gets the const Profile at position index.
| [in] | index | The index of the profile to get. The allowed range is [0..countProfiles()-1] |
index.| sal3d::Error | On error |
| Profile sal3d::RangeMap::operator[] | ( | int | index | ) | [inline] |
Gets the Profile at position index.
| [in] | index | The index of the profile to get. The allowed range is [0..countProfiles()-1] |
index.| sal3d::Error | On error |
| int sal3d::RangeMap::profilesLength | ( | ) | const [inline] |
Gets the length of the profiles in the rangemap.
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.
| [in] | fileName | The name of the file to save the range map to. The used extension for this type of files is .arm. |
| sal3d::Error | On error |
by
1.7.6.1