38 #ifndef PCL_TRACKING_PYRAMIDAL_KLT_H
39 #define PCL_TRACKING_PYRAMIDAL_KLT_H
41 #include <pcl/point_types.h>
42 #include <pcl/tracking/tracker.h>
43 #include <pcl/common/intensity.h>
44 #include <pcl/common/transformation_from_correspondences.h>
62 template<
typename Po
intInT,
typename IntensityT = pcl::common::IntensityFieldAccessor<Po
intInT> >
79 PyramidalKLTTracker (
int nb_levels = 5,
int tracking_window_width = 7,
int tracking_window_height = 7)
93 kernel_ << 1.f/16 ,1.f/4 ,3.f/8 ,1.f/4 ,1.f/16;
174 inline PointCloudInConstPtr
230 derivatives (
const FloatImage& src, FloatImage& grad_x, FloatImage& grad_y)
const;
237 downsample (
const FloatImageConstPtr& input, FloatImageConstPtr& output)
const;
246 downsample (
const FloatImageConstPtr& input, FloatImageConstPtr& output,
247 FloatImageConstPtr& output_grad_x, FloatImageConstPtr& output_grad_y)
const;
254 convolve (
const FloatImageConstPtr& input, FloatImage& output)
const;
261 convolveCols (
const FloatImageConstPtr& input, FloatImage& output)
const;
268 convolveRows (
const FloatImageConstPtr& input, FloatImage& output)
const;
286 const FloatImage& grad_x,
287 const FloatImage& grad_y,
288 const Eigen::Array2i& location,
289 const Eigen::Array4f& weights,
290 Eigen::ArrayXXf& win,
291 Eigen::ArrayXXf& grad_x_win,
292 Eigen::ArrayXXf& grad_y_win,
293 Eigen::Array3f & covariance)
const;
296 const Eigen::ArrayXXf& prev_grad_x,
297 const Eigen::ArrayXXf& prev_grad_y,
298 const FloatImage& next,
299 const Eigen::Array2i& location,
300 const Eigen::Array4f& weights,
301 Eigen::Array2f &b)
const;
310 std::vector<FloatImageConstPtr>& pyramid,
314 track (
const PointCloudInConstPtr& previous_input,
315 const PointCloudInConstPtr& current_input,
316 const std::vector<FloatImageConstPtr>& previous_pyramid,
317 const std::vector<FloatImageConstPtr>& current_pyramid,
320 std::vector<int>& status,
321 Eigen::Affine3f& motion)
const;
371 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
376 #include <pcl/tracking/impl/pyramidal_klt.hpp>
int track_height_2_
half of tracking window height
int track_width_
tracking width
boost::shared_ptr< PointCloud< PointInT > > Ptr
void setEpsilon(float epsilon)
Set epsilon.
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
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...
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
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 initialized_
is the tracker initialized ?
PointCloudInConstPtr getReferenceCloud() const
Get a pointer of the cloud at t-1.
Pyramidal Kanade Lucas Tomasi tracker.
void convolve(const FloatImageConstPtr &input, FloatImage &output) const
Separately convolve image with decomposable convolution kernel.
pcl::PointIndicesConstPtr getPointsToTrackStatus() const
boost::shared_ptr< const PointCloud< PointInT > > ConstPtr
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
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
Eigen::Affine3f motion_
computed transformation between tracked points
pcl::PointCloud< float > FloatImage
virtual ~PyramidalKLTTracker()
Destructor.
float min_eigenvalue_threshold_
virtual bool initCompute()
This method should get called before starting the actual computation.
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
virtual void computeTracking()
Abstract tracking method.
boost::shared_ptr< ::pcl::PointIndices const > PointIndicesConstPtr
float accuracy_
accuracy criterion to stop iterating
Eigen::Affine3f getResult() const
Return the computed transfromation from tracked points.
IntensityT intensity_
intensity accessor
FloatImage::ConstPtr FloatImageConstPtr
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.
bool getInitialized() const
pcl::PointCloud< pcl::PointUV >::ConstPtr keypoints_
detected keypoints 2D coordinates
void setTrackingWindowWidth(int width)
Set tracking window width.
boost::shared_ptr< ::pcl::PointIndices > PointIndicesPtr
FloatImage::Ptr FloatImagePtr
PointCloudIn::Ptr PointCloudInPtr
void setNumberOfPyramidLevels(int levels)
Set the number of pyramid levels.
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()
PointCloudIn::ConstPtr PointCloudInConstPtr
PointCloudConstPtr input_
The input point cloud dataset.
TrackerBase::PointCloudIn PointCloudIn
pcl::tracking::Tracker< PointInT, Eigen::Affine3f > TrackerBase
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