40 #include <pcl/memory.h>
41 #include <pcl/pcl_macros.h>
42 #include <pcl/point_types.h>
43 #include <pcl/tracking/tracker.h>
44 #include <pcl/common/intensity.h>
45 #include <pcl/common/transformation_from_correspondences.h>
63 template<
typename Po
intInT,
typename IntensityT = pcl::common::IntensityFieldAccessor<Po
intInT> >
74 using Ptr = shared_ptr<PyramidalKLTTracker<PointInT, IntensityT> >;
75 using ConstPtr = shared_ptr<const PyramidalKLTTracker<PointInT, IntensityT> >;
82 PyramidalKLTTracker (
int nb_levels = 5,
int tracking_window_width = 7,
int tracking_window_height = 7)
96 kernel_ << 1.f/16 ,1.f/4 ,3.f/8 ,1.f/4 ,1.f/16;
291 const Eigen::Array2i& location,
292 const Eigen::Array4f& weights,
293 Eigen::ArrayXXf& win,
294 Eigen::ArrayXXf& grad_x_win,
295 Eigen::ArrayXXf& grad_y_win,
296 Eigen::Array3f & covariance)
const;
299 const Eigen::ArrayXXf& prev_grad_x,
300 const Eigen::ArrayXXf& prev_grad_y,
302 const Eigen::Array2i& location,
303 const Eigen::Array4f& weights,
304 Eigen::Array2f &b)
const;
313 std::vector<FloatImageConstPtr>& pyramid,
319 const std::vector<FloatImageConstPtr>& previous_pyramid,
320 const std::vector<FloatImageConstPtr>& current_pyramid,
323 std::vector<int>& status,
324 Eigen::Affine3f& motion)
const;
379 #include <pcl/tracking/impl/pyramidal_klt.hpp>
int track_height_2_
half of tracking window height
int track_width_
tracking width
typename PointCloudIn::ConstPtr PointCloudInConstPtr
~PyramidalKLTTracker()
Destructor.
void setEpsilon(float epsilon)
Set epsilon.
typename PointCloudIn::Ptr PointCloudInPtr
void mismatchVector(const Eigen::ArrayXXf &prev, const Eigen::ArrayXXf &prev_grad_x, const Eigen::ArrayXXf &prev_grad_y, const FloatImage &next, const Eigen::Array2i &location, const Eigen::Array4f &weights, Eigen::Array2f &b) const
shared_ptr< const PyramidalKLTTracker< PointInT, IntensityT > > ConstPtr
void setTrackingWindowHeight(int height)
Set tracking window height.
void setNumberOfKeypoints(std::size_t number)
Set the maximum number of points to track.
void convolveRows(const FloatImageConstPtr &input, FloatImage &output) const
Convolve image rows.
void convolveCols(const FloatImageConstPtr &input, FloatImage &output) const
Convolve image columns.
void setAccuracy(float accuracy)
Set accuracy.
int track_width_2_
half of tracking window width
int nb_levels_
number of pyramid levels
virtual void spatialGradient(const FloatImage &img, const FloatImage &grad_x, const FloatImage &grad_y, const Eigen::Array2i &location, const Eigen::Array4f &weights, Eigen::ArrayXXf &win, Eigen::ArrayXXf &grad_x_win, Eigen::ArrayXXf &grad_y_win, Eigen::Array3f &covariance) const
extract the patch from the previous image, previous image gradients surrounding pixel alocation while...
FloatImage::ConstPtr FloatImageConstPtr
IndicesPtr indices_
A pointer to the vector of point indices to use.
PyramidalKLTTracker(int nb_levels=5, int tracking_window_width=7, int tracking_window_height=7)
Constructor.
void downsample(const FloatImageConstPtr &input, FloatImageConstPtr &output) const
downsample input
pcl::PointCloud< PointInT > PointCloudIn
Eigen::Affine3f getResult() const override
Return the computed transformation from tracked points.
std::vector< FloatImageConstPtr > ref_pyramid_
input pyranid at t-1
pcl::TransformationFromCorrespondences transformation_computer_
compute transformation from successfully tracked points
std::size_t getNumberOfKeypoints()
bool initCompute() override
This method should get called before starting the actual computation.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
typename TrackerBase::PointCloudIn PointCloudIn
bool initialized_
is the tracker initialized ?
PointCloudInConstPtr getReferenceCloud() const
Get a pointer of the cloud at t-1.
pcl::PointCloud< float > FloatImage
FloatImage::Ptr FloatImagePtr
Pyramidal Kanade Lucas Tomasi tracker.
void convolve(const FloatImageConstPtr &input, FloatImage &output) const
Separately convolve image with decomposable convolution kernel.
pcl::PointIndicesConstPtr getPointsToTrackStatus() const
virtual void track(const PointCloudInConstPtr &previous_input, const PointCloudInConstPtr ¤t_input, const std::vector< FloatImageConstPtr > &previous_pyramid, const std::vector< FloatImageConstPtr > ¤t_pyramid, const pcl::PointCloud< pcl::PointUV >::ConstPtr &previous_keypoints, pcl::PointCloud< pcl::PointUV >::Ptr ¤t_keypoints, std::vector< int > &status, Eigen::Affine3f &motion) const
shared_ptr< PyramidalKLTTracker< PointInT, IntensityT > > Ptr
int kernel_last_
index of last element in kernel
void setTrackingWindowSize(int width, int height)
set the tracking window size
void setPointsToTrack(const pcl::PointIndicesConstPtr &points)
Provide a pointer to points to track.
std::size_t keypoints_nbr_
number of points to detect
shared_ptr< PointCloud< float > > Ptr
Eigen::Affine3f motion_
computed transformation between tracked points
float min_eigenvalue_threshold_
PointIndices::ConstPtr PointIndicesConstPtr
PointCloudInConstPtr ref_
point cloud at t-1
void setMaxIterationsNumber(unsigned int max)
Set the maximum number of iterations in the Lucas Kanade loop.
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
Eigen::Array< float, 5, 1 > kernel_
smoothing kernel
float accuracy_
accuracy criterion to stop iterating
IntensityT intensity_
intensity accessor
float epsilon_
epsilon for subpixel computation
void derivatives(const FloatImage &src, FloatImage &grad_x, FloatImage &grad_y) const
compute Scharr derivatives of a source cloud.
shared_ptr< const PointCloud< float > > ConstPtr
bool getInitialized() const
pcl::PointCloud< pcl::PointUV >::ConstPtr keypoints_
detected keypoints 2D coordinates
void setTrackingWindowWidth(int width)
Set tracking window width.
void setNumberOfPyramidLevels(int levels)
Set the number of pyramid levels.
void computeTracking() override
Abstract tracking method.
float getAccuracy() const
virtual void computePyramids(const PointCloudInConstPtr &input, std::vector< FloatImageConstPtr > &pyramid, pcl::InterpolationType border_type) const
Compute the pyramidal representation of an image.
int getTrackingWindowHeight()
Tracker represents the base tracker class.
int getTrackingWindowWidth()
PointCloudConstPtr input_
The input point cloud dataset.
pcl::PointCloud< pcl::PointUV >::ConstPtr getTrackedPoints() const
pcl::PointIndicesPtr keypoints_status_
status of keypoints of t-1 at t
int getNumberOfPyramidLevels() const
unsigned int threads_
number of hardware threads
unsigned int getMaxIterationsNumber() const
int track_height_
tracking height
int kernel_size_2_
smoothing kernel half size
std::string tracker_name_
The tracker name.
unsigned int max_iterations_
maximum number of iterations
PointIndices::Ptr PointIndicesPtr