/usr/include/visp/vpMeNurbs.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 | /****************************************************************************
*
* $Id: vpMeNurbs.h 4062 2013-01-09 10:30:06Z 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:
* Moving edges.
*
* Authors:
* Nicolas Melchior
*
*****************************************************************************/
/*!
\file vpMeNurbs.h
\brief Moving edges on a form reprsented by a NURBS (Non Uniform Rational B-Spline)
*/
#ifndef vpMeNurbs_HH
#define vpMeNurbs_HH
#include <visp/vpMatrix.h>
#include <visp/vpMath.h>
#include <visp/vpMeTracker.h>
#include <visp/vpNurbs.h>
#include <math.h>
#include <iostream>
#include <list>
/*!
\class vpMeNurbs
\ingroup TrackingImageME
\brief Class that tracks in an image a edge defined by a Nurbs.
The advantage of this class is that it enables to track an edge whose equation is
not known in advance. At each iteration, the Nurbs corresponding to the edge is computed.
It is possible to have a direct access to the nurbs. It is indeed a public parameter.
The code below shows how to use this class.
\code
#include <visp/vpImage.h>
#include <visp/vpMeNurbs.h>
#include <visp/vpImagePoint.h>
int main()
{
vpImage<unsigned char> I(240, 320);
// Fill the image with a black rectangle
I = 0;
for (int i = 100; i < 180; i ++) {
for (int j = 0; j < 320; j ++) {
I[i][j] = 255;
}
}
// Set the moving-edges tracker parameters
vpMe me;
me.setRange(25);
me.setPointsToTrack(20);
me.setThreshold(15000);
me.setSampleStep(10);
// Initialize the moving-edges tracker parameters
vpMeNurbs meNurbs;
meNurbs.setNbControlPoints(4);
meNurbs.setMe(&me);
// Initialize the location of the edge to track (here a horizontal line
std::list<vpImagePoint> ipList; //List of points belonginig to the edge
ipList.push_back(vpImagePoint(110,119));
ipList.push_back(vpImagePoint(140,119));
ipList.push_back(vpImagePoint(160,119));
ipList.push_back(vpImagePoint(170,119));
meNurbs.initTracking(I, ipList);
while ( 1 )
{
// ... Here the code to read or grab the next image.
// Track the line.
meNurbs.track(I);
}
return 0;
}
\endcode
\note It is possible to display the nurbs as an overlay. For that you
must use the display function of the class vpMeNurbs.
\note In case of an edge which is not smooth, it can be interesting to use the
canny detection to find the extremities. In this case, use the method
setEnableCannyDetection to enable it. Warning : This function requires OpenCV.
*/
class VISP_EXPORT vpMeNurbs : public vpMeTracker
{
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
public:
#else
private:
#endif
//! The Nurbs which represents the tracked edge.
vpNurbs nurbs;
private:
//! Size of the nurbs
double dist;
//! Number of control points used to compute the Nurbs.
unsigned int nbControlPoints;
//! counter used to trigger the canny edge detection at the beginning of the Nurbs.
int beginPtFound;
//! counter used to trigger the canny edge detection at the end of the Nurbs.
int endPtFound;
//! True if the canny detection has to be used during the extremities search.
bool enableCannyDetection;
//! First canny threshold
double cannyTh1;
//! Second canny threshold
double cannyTh2;
public:
vpMeNurbs();
vpMeNurbs(const vpMeNurbs &menurbs);
virtual ~vpMeNurbs();
/*!
Sets the number of control points used to compute the Nurbs.
\param nbControlPoints : The number of control points used to compute the Nurbs.
*/
void setNbControlPoints(const unsigned int nbControlPoints) {this->nbControlPoints = nbControlPoints;}
/*!
Enables or disables the canny detection used during the extremities search.
\param enableCannyDetection : if true it enables the canny detection.
*/
void setEnableCannyDetection(const bool enableCannyDetection) {this->enableCannyDetection =enableCannyDetection;}
/*!
Enables to set the two thresholds use by the canny detection.
\param th1 : The first threshold;
\param th2 : The second threshold;
*/
void setCannyThreshold(const double th1, const double th2)
{
this->cannyTh1 = th1;
this->cannyTh2 = th2;
}
void initTracking(const vpImage<unsigned char> &I) ;
void initTracking(const vpImage<unsigned char> &I,
const std::list<vpImagePoint> &ptList) ;
void track(const vpImage<unsigned char>& Im);
void sample(const vpImage<unsigned char>&image);
void reSample(const vpImage<unsigned char> &I) ;
void updateDelta();
void setExtremities() ;
void seekExtremities(const vpImage<unsigned char> &I) ;
void seekExtremitiesCanny(const vpImage<unsigned char> &I) ;
void suppressPoints() ;
void supressNearPoints();
void localReSample(const vpImage<unsigned char> &I);
/*!
Gets the nurbs;
*/
inline vpNurbs getNurbs() const {return nurbs; }
void display(const vpImage<unsigned char>& I, vpColor col) ;
#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
/*!
@name Deprecated functions
*/
vp_deprecated void initTracking(const vpImage<unsigned char> &I,
vpList<vpImagePoint> &ptList) ;
#endif
private:
bool computeFreemanChainElement(const vpImage<unsigned char> &I,
vpImagePoint &iP,
unsigned int &element);
bool hasGoodLevel(const vpImage<unsigned char>& I,
const vpImagePoint& iP) const;
bool isInImage(const vpImage<unsigned char>& I, const vpImagePoint &iP) const;
void computeFreemanParameters( unsigned int element, vpImagePoint &diP);
bool farFromImageEdge(const vpImage<unsigned char>& I, const vpImagePoint& iP);
public:
static void display(const vpImage<unsigned char>& I, vpNurbs &n, vpColor color = vpColor::green);
static void display(const vpImage<vpRGBa>& I, vpNurbs &n, vpColor color = vpColor::green);
};
#endif
|