/usr/include/visp/vpKltOpencv.h is in libvisp-dev 2.8.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /****************************************************************************
*
* $Id: vpKltOpencv.h 4231 2013-04-29 16:26:28Z fspindle $
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact INRIA about acquiring a ViSP Professional
* Edition License.
*
* See http://www.irisa.fr/lagadic/visp/visp.html for more information.
*
* This software was developed at:
* INRIA Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
* http://www.irisa.fr/lagadic
*
* If you have questions regarding the use of this file, please contact
* INRIA at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* Description:
* Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented
* with opencv.
*
* Authors:
* Fabien Servant
* Fabien Spindler
*
*****************************************************************************/
/*!
\file vpKltOpencv.h
\brief Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker
implemented with opencv.
*/
#ifndef vpKltOpencv_h
#define vpKltOpencv_h
#include <visp/vpConfig.h>
#ifdef VISP_HAVE_OPENCV
#ifdef _CH_
#pragma package <opencv>
#endif
#if (VISP_HAVE_OPENCV_VERSION >= 0x020101) // Require opencv >= 2.1.1
# include <opencv2/imgproc/imgproc.hpp>
# include <opencv2/video/tracking.hpp>
# include <opencv2/legacy/legacy.hpp>
# include <opencv2/highgui/highgui.hpp>
#else
# ifndef _EiC
# include <cv.h>
# include <highgui.h>
# include <stdio.h>
# include <ctype.h>
# endif
#endif
#include <visp/vpConfig.h>
#include <visp/vpImage.h>
#include <visp/vpImageIo.h>
#include <visp/vpDisplay.h>
#include <visp/vpDebug.h>
#include <visp/vpException.h>
#include <visp/vpTrackingException.h>
typedef int (*funccheck)(int,double,double);
typedef void (*funcinfo)(int,int,int,double,double);
typedef void (*funcevent)(int);
/*!
\class vpKltOpencv
\ingroup TrackingImagePoint
\brief Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker
implemented in OpenCV.
The following example available in tutorial-klt-tracker.cpp shows how to use
the main functions of the class.
\include tutorial-klt-tracker.cpp
A line by line explanation is provided in \ref tutorial-tracking-keypoint.
*/
class VISP_EXPORT vpKltOpencv
{
private:
int initialized; //Is the tracker ready ?
int maxFeatures; //Maximum number of features to track (Default 50)
int globalcountFeatures; //Keep over time for ID
int win_size; //Size of search window for tracker (default 10)
double quality; //Multiplier for the maxmin eigenvalue; specifies minimal accepted quality of image corners (default 0.01)
double min_distance; //Limit, specifying minimum possible distance between returned corners; Euclidian distance is used. (default 10)
double harris_free_parameter; //Harris detector free parameter. (default 0.04)
int block_size; //Size of the averaging block used by the corner detector (default 3)
int use_harris; //0 use a simple Minimum EigenValue Detector, != 0 use Harris (default 1)
int pyramid_level; //Number of level for the tracker's gaussian pyramid data (default 3)
int _tid; //tracker id for multiple trackers
IplImage *image; //Image buffer
IplImage *prev_image; //Image buffer for the previous iteration
IplImage *pyramid; //Gaussian pyramid data
IplImage *prev_pyramid; //Gaussian pyramid data for the previous iteration
IplImage *swap_temp; //Internal
int countFeatures; //Currently tracked features
int countPrevFeatures; //Previously tracked features
CvPoint2D32f *features; //List of features
CvPoint2D32f *prev_features; //List of features for previous iteration
long *featuresid; //Array of ids for features
long *prev_featuresid; //Array of ids for previous features
int flags; //Flags for tracking (internal)
bool initial_guess; //Bool to precise if the next call to track() uses an initial guess
bool *lostDuringTrack; // Result of the tracker for every feature : 1 = lost, 0 = still present
char *status; //Result of the tracker for every features : 0 = lost, 1 = found
//EVENT FUNCTION POINTERS
funcevent OnInitialize;
funcinfo OnFeatureLost;
funcinfo OnNewFeature;
funcinfo OnMeasureFeature;
funccheck IsFeatureValid;
private:
//Internal
void clean();
void cleanAll();
void reset();
public:
vpKltOpencv();
vpKltOpencv(const vpKltOpencv& copy);
virtual ~vpKltOpencv();
void addFeature(const int &id, const float &x, const float &y);
//Draw the tracked features on the given image
void display(const vpImage<unsigned char> &I,
vpColor color = vpColor::red, unsigned int thickness=1);
//! Get the block size
int getBlockSize() const {return block_size;}
void getFeature(int index, int &id, float &x, float &y) const;
//! Get the list of features
CvPoint2D32f* getFeatures() const {return features;}
//! Get the list of features id
long* getFeaturesId() const {return featuresid;}
//! Get Harris free parameter
double getHarrisFreeParameter() const {return harris_free_parameter;}
//! Get the list of lost feature
bool *getListOfLostFeature() const { return lostDuringTrack; }
//! Get Max number of features
int getMaxFeatures() const {return maxFeatures;}
//! Get Min Distance
double getMinDistance() const {return min_distance;}
//! Get the current number of features
int getNbFeatures() const { return countFeatures; }
//! Get the previous number of features
int getNbPrevFeatures() const { return countPrevFeatures; }
void getPrevFeature(int index, int &id, float &x, float &y) const;
//! Get the list of features
CvPoint2D32f* getPrevFeatures() const {return prev_features;}
//! Get the list of features id
long* getPrevFeaturesId() const {return prev_featuresid;}
//! Get the number of pyramid levels
int getPyramidLevels() const {return pyramid_level;}
//! Get the quality of the tracker
double getQuality() const {return quality;}
//! Get Max number of features
int getWindowSize() const {return win_size;}
//Detect corners in the image. Initialize the tracker
void initTracking(const IplImage *I, const IplImage *mask = NULL);
//Track !
void track(const IplImage *I);
//Seters
/*!
Set the size of the averaging block used to track the features.
\warning The input is a signed integer to be compatible with OpenCV. However,
it must be a positive integer.
\param input : The new size of the block.
*/
void setBlockSize(const int input) {initialized = 0; block_size=input;}
/*!
Set the Harris parameter (The \e k value).
\warning The tracker must be re-initialised using the method initTracking().
\param input : The new Harris parameter.
*/
void setHarrisFreeParameter(double input) {initialized = 0; harris_free_parameter=input;}
void setInitialGuess(CvPoint2D32f **guess_pts);
/*!
Is a feature valid (e.g. : test if not too close to borders) -> event(id_tracker, x, y)
*/
void setIsFeatureValid(funccheck input) {IsFeatureValid = input;}
/* Should be used only before initTracking */
void setMaxFeatures(const int input);
/*!
Set the minimal distance between two points during the initialisation.
\warning The tracker must be re-initialised using the method initTracking().
\param input : The new minimal distance between two points.
*/
void setMinDistance(double input) {initialized = 0; min_distance=input;}
//Functors
//Event when tracker is initialized -> event(id_tracker)
void setOnInitialize(funcevent input) {OnInitialize = input;}
//Event when a feature is lost -> event(id_tracker, index, uid, x, y)
void setOnFeatureLost(funcinfo input) {OnFeatureLost = input;}
//Event when a new feature is found -> event(id_tracker, index, uid, x, y)
void setOnNewFeature(funcinfo input) {OnNewFeature = input;}
//Event when a feature is found while tracking -> event(id_tracker, index, uid, x, y)
void setOnMeasureFeature(funcinfo input) {OnMeasureFeature = input;}
/*!
Set the maximal pyramid level. If the level is zero, then no pyramid is
computed for the optical flow.
\warning The tracker must be re-initialised using the method initTracking().
\param input : The new maximal pyramid level.
*/
void setPyramidLevels(const int input) {initialized = 0; pyramid_level=input;}
void setQuality(double input) {initialized = 0; quality=input;}
void setTrackerId(int tid) {_tid = tid;}
/*!
Set the window size for the sub-pixel computation.
\warning The tracker must be re-initialised using the method initTracking().
\param input : The new number of maximum features.
*/
void setUseHarris(const int input) {initialized = 0; use_harris=input;}
void setWindowSize(const int input) {initialized = 0; win_size=input;}
void suppressFeature(int index);
//Static Functions
public:
static void display(const vpImage<unsigned char>& I, const CvPoint2D32f* features_list,
const int &nbFeatures, vpColor color = vpColor::green,
unsigned int thickness=1);
static void display(const vpImage<vpRGBa>& I, const CvPoint2D32f* features_list,
const int &nbFeatures, vpColor color = vpColor::green,
unsigned int thickness=1);
static void display(const vpImage<unsigned char>& I, const CvPoint2D32f* features_list,
const long *featuresid_list, const int &nbFeatures,
vpColor color = vpColor::green, unsigned int thickness=1);
static void display(const vpImage<vpRGBa>& I, const CvPoint2D32f* features_list,
const long *featuresid_list, const int &nbFeatures,
vpColor color = vpColor::green, unsigned int thickness=1);
};
#endif
#endif
|