Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches

#include <vpMeEllipse.h>

Inheritance diagram for vpMeEllipse:

Public Member Functions

 vpMeEllipse ()
 vpMeEllipse (const vpMeEllipse &me_ellipse)
virtual ~vpMeEllipse () VP_OVERRIDE
vpMeEllipseoperator= (const vpMeEllipse &me_ellipse)
void display (const vpImage< unsigned char > &I, const vpColor &col, unsigned int thickness=1)
void display (const vpImage< vpRGBa > &I, const vpColor &col, unsigned int thickness=1)
vpColVector get_nij () const
vpColVector get_ABE () const
double getArea () const
vpImagePoint getCenter () const
unsigned int getExpectedDensity () const
unsigned int getNumberOfGoodPoints () const
vpImagePoint getFirstEndpoint () const
double getHighestAngle () const
vpImagePoint getSecondEndpoint () const
double getSmallestAngle () const
void initTracking (const vpImage< unsigned char > &I, bool trackCircle=false, bool trackArc=false)
void initTracking (const vpImage< unsigned char > &I, std::optional< std::vector< vpImagePoint > > &opt_ips, bool trackCircle=false, bool trackArc=false)
void initTracking (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &iP, bool trackCircle=false, bool trackArc=false)
void initTracking (const vpImage< unsigned char > &I, const vpColVector &param, vpImagePoint *pt1=nullptr, const vpImagePoint *pt2=nullptr, bool trackCircle=false)
void printParameters () const
void setEndpoints (const vpImagePoint &pt1, const vpImagePoint &pt2)
void setThresholdRobust (double threshold)
void track (const vpImage< unsigned char > &I)
Public Member Functions Inherited from vpTracker
vpColVector get_p () const
vpColVector get_cP () const

Static Public Member Functions

static void displayEllipse (const vpImage< unsigned char > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
static void displayEllipse (const vpImage< vpRGBa > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
static VP_DEPRECATED void display (const vpImage< unsigned char > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
static VP_DEPRECATED void display (const vpImage< vpRGBa > &I, const vpImagePoint &center, const double &A, const double &B, const double &E, const double &smallalpha, const double &highalpha, const vpColor &color=vpColor::green, unsigned int thickness=1)
Deprecated functions
static VP_DEPRECATED bool inMask (const vpImage< bool > *mask, unsigned int i, unsigned int j)

Public Attributes

Public Attributes Inherited from vpTracker
vpColVector p
vpColVector cP
bool cPAvailable

Protected Member Functions

void computeAbeFromNij ()
double computeAngleOnEllipse (const vpImagePoint &pt) const
void computeKiFromNij ()
void computeNijFromAbe ()
void computePointOnEllipse (const double angle, vpImagePoint &iP)
double computeTheta (const vpImagePoint &iP) const
double computeTheta (double u, double v) const
void getParameters ()
void leastSquare (const vpImage< unsigned char > &I, const std::vector< vpImagePoint > &iP)
unsigned int leastSquareRobust (const vpImage< unsigned char > &I)
void leastSquareRobustCircle (const double &um, const double &vm, unsigned int &k, vpColVector &w)
void leastSquareRobustEllipse (const double &um, const double &vm, unsigned int &k, vpColVector &w)
unsigned int plugHoles (const vpImage< unsigned char > &I)
virtual void sample (const vpImage< unsigned char > &I, bool doNotTrack=false) VP_OVERRIDE
void updateTheta ()

Protected Attributes

vpColVector m_K
vpImagePoint m_iPc
double m_a
double m_b
double m_e
vpImagePoint m_iP1
vpImagePoint m_iP2
double m_alpha1
double m_alpha2
double m_ce
double m_se
std::list< double > m_angleList
double m_m00
double m_thresholdWeight
double m_alphamin
double m_alphamax
double m_uc
double m_vc
double m_n20
double m_n11
double m_n02
unsigned int m_expectedDensity
unsigned int m_numberOfGoodPoints
bool m_trackCircle
bool m_trackArc
double m_arcEpsilon
Protected Attributes Inherited from vpMeTracker
std::list< vpMeSitem_meList
vpMem_me
int m_nGoodElement
const vpImage< bool > * m_mask
const vpImage< bool > * m_maskCandidates
vpMeSite::vpMeSiteDisplayType m_selectDisplay

Public Member Functions Inherited from vpMeTracker

void display (const vpImage< unsigned char > &I)
void display (const vpImage< vpRGBa > &I)
void display (const vpImage< unsigned char > &I, vpColVector &w, unsigned int &index_w)
vpMegetMe ()
std::list< vpMeSite > & getMeList ()
std::list< vpMeSitegetMeList () const
int getNbPoints () const
void init ()
void initTracking (const vpImage< unsigned char > &I)
unsigned int numberOfSignal ()
bool outOfImage (int i, int j, int border, int nrows, int ncols)
bool outOfImage (const vpImagePoint &iP, int border, int nrows, int ncols)
void reset ()
void setDisplay (vpMeSite::vpMeSiteDisplayType select)
virtual void setMask (const vpImage< bool > &mask)
virtual void setMaskCandidates (const vpImage< bool > *maskCandidates)
void setMe (vpMe *me)
void setMeList (const std::list< vpMeSite > &meList)
unsigned int totalNumberOfSignal ()
static bool inRoiMask (const vpImage< bool > *mask, unsigned int i, unsigned int j)
static bool inMeMaskCandidates (const vpImage< bool > *meMaskCandidates, unsigned int i, unsigned int j)

Detailed Description

Class that tracks an ellipse or a circle using moving edges.

In this class, an ellipse is defined as the set of image points $ (u,v) $ (for more information about the image frame see the vpImagePoint documentation) that satisfy the homogeneous equation:

\‍[ K_0 u^2 + K_1 v^2 + 2K_2 u v + 2K_3 u + 2K_4 v + K5 = 0 \‍]

with $K_0 = n_{02}$, $K_1 = n_{20}$, $K_2 = -n_{11}$, etc. (see Eq. (25) of Chaumette TRO 2004 paper [6])

If $ K_0 = K1 $ and $ K_2 = 0 $, the ellipse is a circle.

The six parameters are stored in the private attribute K.

An ellipse is also represented thanks to five parameters that are the center $ (uc,vc) $ of the ellipse and either:

  • three normalized moments $ n_{ij} $ of order 2,
  • or the semi major axis $ A $, the semi minor axis $ B $ and the ellipse orientation $ E \in [-\pi/2;\pi/2] $ defined by the angle between the major axis and the u axis of the image frame.

For more details, see [6]. The following figure illustrates these parameters.

Tutorials & Examples

Tutorials

The example below available in tutorial-me-ellipse-tracker.cpp and described in Tutorial: Moving-edges tracking, section 2.2. Ellipse or arc of ellipse tracking and section 2.3. Circle or arc of circle tracking shows how to use this class.

#include <iostream>
#include <visp3/core/vpConfig.h>
// If openCV available, priority to OpenCV capture, otherwise the user has to modify the code uncommenting/commenting
// one of the following lines
#if ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
#undef VISP_HAVE_V4L2
#undef VISP_HAVE_DC1394
#undef VISP_HAVE_CMU1394
#undef VISP_HAVE_FLYCAPTURE
#undef VISP_HAVE_REALSENSE2
// #undef HAVE_OPENCV_HIGHGUI
// #undef HAVE_OPENCV_VIDEOIO
#else
// Use the first grabber that is available. Uncomment/comment the following lines to disable usage of a grabber
// #undef VISP_HAVE_V4L2
// #undef VISP_HAVE_DC1394
// #undef VISP_HAVE_CMU1394
// #undef VISP_HAVE_FLYCAPTURE
// #undef VISP_HAVE_REALSENSE2
#undef HAVE_OPENCV_HIGHGUI
#undef HAVE_OPENCV_VIDEOIO
#endif
#if (defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || \
defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2) || defined(VISP_HAVE_OPENCV) && \
(((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))))
#ifdef VISP_HAVE_MODULE_SENSOR
#include <visp3/sensor/vp1394CMUGrabber.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
#include <visp3/sensor/vpFlyCaptureGrabber.h>
#include <visp3/sensor/vpRealSense2.h>
#include <visp3/sensor/vpV4l2Grabber.h>
#endif
#include <visp3/core/vpIoTools.h>
#include <visp3/gui/vpDisplayFactory.h>
#include <visp3/io/vpVideoWriter.h>
#include <visp3/me/vpMeEllipse.h>
#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
#include <opencv2/highgui/highgui.hpp> // for cv::VideoCapture
#elif defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
#include <opencv2/videoio/videoio.hpp> // for cv::VideoCapture
#endif
int main(int argc, char **argv)
{
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
std::shared_ptr<vpDisplay> display;
#else
vpDisplay *display = nullptr;
#endif
int opt_me_range = 10;
int opt_me_sample_step = 5;
int opt_me_threshold = 20; // Value in [0 ; 255]
int opt_track_circle = false; // By default we will track an ellipse
int opt_track_arc = false; // By default we will track a full circle or ellipse
std::string opt_save_filename; // Saved images filename
for (int i = 1; i < argc; i++) {
if (std::string(argv[i]) == "--me-range" && i + 1 < argc) {
opt_me_range = std::atoi(argv[++i]);
}
else if (std::string(argv[i]) == "--me-sample-step" && i + 1 < argc) {
opt_me_sample_step = std::atoi(argv[++i]);
}
else if (std::string(argv[i]) == "--me-threshold" && i + 1 < argc) {
opt_me_threshold = std::atoi(argv[++i]);
}
else if (std::string(argv[i]) == "--track-circle") {
opt_track_circle = true;
}
else if (std::string(argv[i]) == "--track-arc") {
opt_track_arc = true;
}
else if (std::string(argv[i]) == "--save" && i + 1 < argc) {
opt_save_filename = std::string(argv[++i]);
}
else if (std::string(argv[i]) == "--help" || std::string(argv[i]) == "-h") {
std::cout << "\nUsage: " << argv[0]
<< " [--me-range <range>]"
<< " [--me-sample-step <sample step>]"
<< " [--me-threshold <threshold>]"
<< " [--track-arc]"
<< " [--track-circle]"
<< " [--save <filename>]"
<< " [--help] [-h]\n"
<< std::endl;
return EXIT_SUCCESS;
}
else {
std::cout << "\nError: wrong parameter " << argv[i] << std::endl;
return EXIT_FAILURE;
}
}
try {
int opt_device = 0; // For OpenCV and V4l2 grabber to set the camera device
#if defined(VISP_HAVE_V4L2)
std::ostringstream device;
device << "/dev/video" << opt_device;
std::cout << "Use Video 4 Linux grabber on device " << device.str() << std::endl;
g.setDevice(device.str());
g.setScale(1);
g.open(I);
#elif defined(VISP_HAVE_DC1394)
(void)opt_device; // To avoid non used warning
std::cout << "Use DC1394 grabber" << std::endl;
g.open(I);
#elif defined(VISP_HAVE_CMU1394)
(void)opt_device; // To avoid non used warning
std::cout << "Use CMU1394 grabber" << std::endl;
g.open(I);
#elif defined(VISP_HAVE_FLYCAPTURE)
(void)opt_device; // To avoid non used warning
std::cout << "Use FlyCapture grabber" << std::endl;
g.open(I);
#elif defined(VISP_HAVE_REALSENSE2)
(void)opt_device; // To avoid non used warning
std::cout << "Use Realsense 2 grabber" << std::endl;
rs2::config config;
config.disable_stream(RS2_STREAM_DEPTH);
config.disable_stream(RS2_STREAM_INFRARED);
config.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_RGBA8, 30);
g.open(config);
g.acquire(I);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
std::cout << "Use OpenCV grabber on device " << opt_device << std::endl;
cv::VideoCapture g(opt_device); // Open the default camera
if (!g.isOpened()) { // Check if we succeeded
std::cout << "Failed to open the camera" << std::endl;
return EXIT_FAILURE;
}
int i = 0;
cv::Mat frame;
while ((i++ < 20) && !g.read(frame)) {
} // warm up camera by skiping unread frames
g >> frame; // get a new frame from camera
#endif
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
g.acquire(I);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
g >> frame; // get a new frame from camera
#endif
#if defined(VISP_HAVE_DISPLAY)
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
display = vpDisplayFactory::createDisplay(I, 0, 0, "Camera view");
#else
display = vpDisplayFactory::allocateDisplay(I, 0, 0, "Camera view");
#endif
#else
std::cout << "No image viewer is available..." << std::endl;
#endif
vpVideoWriter *writer = nullptr;
if (!opt_save_filename.empty()) {
std::string parent = vpIoTools::getParent(opt_save_filename);
if (!parent.empty()) {
std::cout << "Create output directory: " << parent << std::endl;
}
writer = new vpVideoWriter();
writer->setFileName(opt_save_filename);
writer->open(O);
}
vpMe me;
me.setRange(opt_me_range);
me.setThreshold(opt_me_threshold);
me.setSampleStep(opt_me_sample_step);
std::cout << "Moving-edges settings" << std::endl;
me.print();
std::cout << "\nTracker settings" << std::endl;
std::cout << " Tracker type....................."
<< (opt_track_arc ? std::string("arc of ") : std::string())
<< (opt_track_circle ? std::string("circle") : std::string("ellipse")) << std::endl;
std::cout << " Save results....................." << (opt_save_filename.empty() ? std::string("n/a") : opt_save_filename) << std::endl << std::endl;
vpMeEllipse ellipse;
ellipse.setMe(&me);
ellipse.setDisplay(vpMeSite::RANGE_RESULT);
ellipse.initTracking(I, opt_track_circle, opt_track_arc);
bool quit = false;
while (!quit) {
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_CMU1394) || defined(VISP_HAVE_FLYCAPTURE) || defined(VISP_HAVE_REALSENSE2)
g.acquire(I);
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
g >> frame;
#endif
vpDisplay::displayText(I, 20, 20, "Click to quit", vpColor::red);
ellipse.track(I);
ellipse.display(I, vpColor::red);
if (vpDisplay::getClick(I, false)) {
quit = true;
}
if (!opt_save_filename.empty()) {
writer->saveFrame(O);
}
}
}
catch (const vpException &e) {
std::cout << "Catch an exception: " << e << std::endl;
}
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
if (display != nullptr) {
delete display;
}
#endif
}
#else
int main()
{
#if defined(VISP_HAVE_OPENCV)
std::cout << "Install a 3rd party dedicated to frame grabbing (dc1394, cmu1394, v4l2, OpenCV, FlyCapture, "
<< "Realsense2), configure and build ViSP again to use this tutorial."
<< std::endl;
#else
std::cout << "Install OpenCV 3rd party, configure and build ViSP again to use this tutorial." << std::endl;
#endif
return EXIT_SUCCESS;
}
#endif
Firewire cameras video capture based on CMU 1394 Digital Camera SDK.
void open(vpImage< unsigned char > &I)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void open(vpImage< unsigned char > &I)
static const vpColor red
Definition vpColor.h:198
Class that defines generic functionalities for display.
Definition vpDisplay.h:171
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
Definition vpException.h:60
void open(vpImage< unsigned char > &I)
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition of the vpImage class member functions.
Definition vpImage.h:131
static void makeDirectory(const std::string &dirname)
static std::string getParent(const std::string &pathname)
Class that tracks an ellipse or a circle using moving edges.
void display(const vpImage< unsigned char > &I, const vpColor &col, unsigned int thickness=1)
@ RANGE_RESULT
Definition vpMeSite.h:85
void setMe(vpMe *me)
Definition vpMe.h:143
void print()
Definition vpMe.cpp:404
void setRange(const unsigned int &range)
Definition vpMe.h:438
void setLikelihoodThresholdType(const vpLikelihoodThresholdType likelihood_threshold_type)
Definition vpMe.h:531
void setThreshold(const double &threshold)
Definition vpMe.h:489
void setSampleStep(const double &sample_step)
Definition vpMe.h:445
@ NORMALIZED_THRESHOLD
Definition vpMe.h:154
void acquire(vpImage< unsigned char > &grey, double *ts=nullptr)
bool open(const rs2::config &cfg=rs2::config())
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void open(vpImage< unsigned char > &I)
void setScale(unsigned scale=vpV4l2Grabber::DEFAULT_SCALE)
void setDevice(const std::string &devname)
Class that enables to write easily a video file or a sequence of images.
void saveFrame(vpImage< vpRGBa > &I)
void setFileName(const std::string &filename)
void open(vpImage< vpRGBa > &I)
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
Examples
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 99 of file vpMeEllipse.h.

Constructor & Destructor Documentation

◆ vpMeEllipse() [1/2]

BEGIN_VISP_NAMESPACE vpMeEllipse::vpMeEllipse ( )

Basic constructor that calls the constructor of the class vpMeTracker.

Definition at line 47 of file vpMeEllipse.cpp.

References m_a, m_alpha1, m_alpha2, m_alphamax, m_alphamin, m_angleList, m_arcEpsilon, m_b, m_ce, m_e, m_expectedDensity, m_iP1, m_iP2, m_iPc, m_K, m_m00, m_n02, m_n11, m_n20, m_numberOfGoodPoints, m_se, m_thresholdWeight, m_trackArc, m_trackCircle, m_uc, and m_vc.

Referenced by operator=(), and vpMeEllipse().

◆ vpMeEllipse() [2/2]

vpMeEllipse::vpMeEllipse ( const vpMeEllipse & me_ellipse)

Copy constructor.

Definition at line 62 of file vpMeEllipse.cpp.

References vpMeEllipse(), and vpMeTracker::vpMeTracker().

◆ ~vpMeEllipse()

vpMeEllipse::~vpMeEllipse ( )
virtual

Destructor.

Definition at line 68 of file vpMeEllipse.cpp.

References m_angleList, and vpMeTracker::m_meList.

Member Function Documentation

◆ computeAbeFromNij()

void vpMeEllipse::computeAbeFromNij ( )
protected

Computes the length of the semi major axis $ a $, the length of the semi minor axis $ b $, and $ e $ that is the angle made by the major axis and the u axis of the image frame $ (u,v) $. They are computed from the normalized moments $ $ n_{ij} $.

Definition at line 213 of file vpMeEllipse.cpp.

References m_a, m_b, m_ce, m_e, m_n02, m_n11, m_n20, and m_se.

Referenced by getParameters(), and initTracking().

◆ computeAngleOnEllipse()

double vpMeEllipse::computeAngleOnEllipse ( const vpImagePoint & pt) const
protected

Compute the angle of a point on the ellipse wrt the ellipse major axis.

Parameters
pt: Image point on the ellipse.
Returns
The computed angle.

Definition at line 171 of file vpMeEllipse.cpp.

References vpImagePoint::get_u(), vpImagePoint::get_v(), m_a, m_b, m_ce, m_e, m_se, m_uc, and m_vc.

Referenced by initTracking(), initTracking(), leastSquareRobust(), leastSquareRobustCircle(), leastSquareRobustEllipse(), plugHoles(), and track().

◆ computeKiFromNij()

void vpMeEllipse::computeKiFromNij ( )
protected

Computes the parameters $ K = {K_0, ...,  K_5} $ from the center of the ellipse and the normalized moments $ n_{ij} $. The parameters $ K $ are such that $ K0 = n02, K1 = n20 $, etc. as in Eq (25) of Chaumette 2004 TRO paper.

Definition at line 235 of file vpMeEllipse.cpp.

References m_K, m_n02, m_n11, m_n20, m_uc, and m_vc.

Referenced by initTracking().

◆ computeNijFromAbe()

void vpMeEllipse::computeNijFromAbe ( )
protected

Computes the normalized moments $ n_{ij} $ from the $ A, B, E $ parameters as in Eq (24) of Chaumette 2004 TRO paper after simplifications to deal with the case cos(e) = 0.0

Definition at line 251 of file vpMeEllipse.cpp.

References m_a, m_b, m_ce, m_n02, m_n11, m_n20, and m_se.

◆ computePointOnEllipse()

void vpMeEllipse::computePointOnEllipse ( const double angle,
vpImagePoint & iP )
protected

Compute the coordinates of a point on an ellipse from its angle with respect to the main orientation of the ellipse.

Parameters
angle: Angle on the ellipse with respect to its major axis.
iP: Image point on the ellipse.

Definition at line 139 of file vpMeEllipse.cpp.

References m_a, m_b, m_ce, m_se, m_uc, m_vc, vpImagePoint::set_u(), vpImagePoint::set_uv(), and vpImagePoint::set_v().

Referenced by initTracking(), initTracking(), leastSquareRobustCircle(), leastSquareRobustEllipse(), plugHoles(), sample(), and track().

◆ computeTheta() [1/2]

double vpMeEllipse::computeTheta ( const vpImagePoint & iP) const
protected

Computes the $ \theta $ angle that represents the angle between the tangent to the curve and the u axis. This angle is used for tracking the vpMeSite.

Parameters
iP: The point belonging to the ellipse where the angle is computed.

Definition at line 105 of file vpMeEllipse.cpp.

References computeTheta(), vpImagePoint::get_u(), and vpImagePoint::get_v().

Referenced by computeTheta(), plugHoles(), sample(), and updateTheta().

◆ computeTheta() [2/2]

double vpMeEllipse::computeTheta ( double u,
double v ) const
protected

Computes the $ \theta $ angle that represents the angle between the tangent to the curve and the u axis. This angle is used for tracking the vpMeSite.

Parameters
[in]u: The coordinate along the x-axis (horizontal) of the point belonging to the ellipse where the angle is computed.
[in]v: The coordinate along the y-axis (vertical) of the point belonging to the ellipse where the angle is computed.

Definition at line 113 of file vpMeEllipse.cpp.

References m_K.

◆ display() [1/7]

void vpMeEllipse::display ( const vpImage< unsigned char > & I,
const vpColor & col,
unsigned int thickness = 1 )

Display the ellipse or arc of ellipse

Warning
To effectively display the ellipse a call to vpDisplay::flush() is needed.
Parameters
I: Image in which the ellipse appears.
col: Color of the displayed ellipse.
thickness: Thickness of the drawing.
Examples
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 589 of file vpMeEllipse.cpp.

References displayEllipse(), m_a, m_alpha1, m_alpha2, m_b, m_e, and m_iPc.

◆ display() [2/7]

void vpMeEllipse::display ( const vpImage< unsigned char > & I,
const vpImagePoint & center,
const double & A,
const double & B,
const double & E,
const double & smallalpha,
const double & highalpha,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static
Deprecated
Use rather displayEllipse().
Deprecated
This static function is deprecated. Use rather vpMeEllipse::displayEllipse().

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse.
A: Semi major axis of the ellipse.
B: Semi minor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad).
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse).
highalpha: Highest $ alpha $ angle in rad (2 $ \Pi $ for a complete ellipse).
color: Color used to display the ellipse.
thickness: Thickness of the drawings.

Definition at line 796 of file vpMeEllipse.cpp.

References displayEllipse().

◆ display() [3/7]

void vpMeEllipse::display ( const vpImage< vpRGBa > & I,
const vpColor & col,
unsigned int thickness = 1 )

Display the ellipse or arc of ellipse

Warning
To effectively display the ellipse a call to vpDisplay::flush() is needed.
Parameters
I: Image in which the ellipse appears.
col: Color of the displayed ellipse.
thickness: Thickness of the drawing.

Definition at line 594 of file vpMeEllipse.cpp.

References displayEllipse(), m_a, m_alpha1, m_alpha2, m_b, m_e, and m_iPc.

◆ display() [4/7]

void vpMeEllipse::display ( const vpImage< vpRGBa > & I,
const vpImagePoint & center,
const double & A,
const double & B,
const double & E,
const double & smallalpha,
const double & highalpha,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static
Deprecated
Use rather displayEllipse().
Deprecated
This static function is deprecated. Use rather vpMeEllipse::displayEllipse().

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse
A: Semi major axis of the ellipse.
B: Semi minor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad)
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse)
highalpha: Highest $ alpha $ angle in rad ( $ 2 \Pi $ for a complete ellipse)
color: Color used to display th lines.
thickness: Thickness of the drawings.
See also
vpDisplay::displayEllipse()

Definition at line 830 of file vpMeEllipse.cpp.

References displayEllipse().

◆ display() [5/7]

void vpMeTracker::display ( const vpImage< unsigned char > & I)
inherited

Display the moving edge sites with a color corresponding to their state.

  • If green : The vpMeSite is a good point.
  • If blue : The point is removed because of the vpMeSite tracking phase (contrast problem).
  • If purple : The point is removed because of the vpMeSite tracking phase (threshold problem).
  • If red : The point is removed because of the robust method in the virtual visual servoing (M-Estimator problem).
  • If cyan : The point is removed because it's too close to another.
  • Yellow otherwise.
Parameters
[in]I: The image.

Definition at line 252 of file vpMeTracker.cpp.

References vpMeSite::display(), and m_meList.

Referenced by display(), vpMeEllipse::initTracking(), vpMeEllipse::initTracking(), and vpMeLine::track().

◆ display() [6/7]

void vpMeTracker::display ( const vpImage< unsigned char > & I,
vpColVector & w,
unsigned int & index_w )
inherited

Displays the status of moving edge sites

Parameters
[in]I: The image.
[in]w: vector
[in]index_w: index

Definition at line 270 of file vpMeTracker.cpp.

References display(), vpMeSite::getState(), m_meList, vpMeSite::NO_SUPPRESSION, and vpMeSite::setWeight().

◆ display() [7/7]

void vpMeTracker::display ( const vpImage< vpRGBa > & I)
inherited

Display the moving edge sites with a color corresponding to their state.

  • If green : The vpMeSite is a good point.
  • If blue : The point is removed because of the vpMeSite tracking phase (contrast problem).
  • If purple : The point is removed because of the vpMeSite tracking phase (threshold problem).
  • If red : The point is removed because of the robust method in the virtual visual servoing (M-Estimator problem).
  • If cyan : The point is removed because it's too close to another.
  • Yellow otherwise.
Parameters
[in]I: The image.

Definition at line 261 of file vpMeTracker.cpp.

References vpMeSite::display(), and m_meList.

◆ displayEllipse() [1/2]

void vpMeEllipse::displayEllipse ( const vpImage< unsigned char > & I,
const vpImagePoint & center,
const double & A,
const double & B,
const double & E,
const double & smallalpha,
const double & highalpha,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse.
A: Semi major axis of the ellipse.
B: Semi minor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad).
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse).
highalpha: Highest $ alpha $ angle in rad (2 $ \Pi $ for a complete ellipse).
color: Color used to display the ellipse.
thickness: Thickness of the drawings.
See also
vpDisplay::displayEllipse()

Definition at line 839 of file vpMeEllipse.cpp.

References vpDisplay::displayEllipse().

Referenced by display(), display(), display(), and display().

◆ displayEllipse() [2/2]

void vpMeEllipse::displayEllipse ( const vpImage< vpRGBa > & I,
const vpImagePoint & center,
const double & A,
const double & B,
const double & E,
const double & smallalpha,
const double & highalpha,
const vpColor & color = vpColor::green,
unsigned int thickness = 1 )
static

Display the ellipse or the arc of ellipse thanks to the ellipse parameters.

Parameters
I: The image used as background.
center: Center of the ellipse
A: Semi-major axis of the ellipse.
B: Semi-minor axis of the ellipse.
E: Angle made by the major axis and the u axis of the image frame $ (u,v) $ (in rad)
smallalpha: Smallest $ alpha $ angle in rad (0 for a complete ellipse)
highalpha: Highest $ alpha $ angle in rad ( $ 2 \Pi $ for a complete ellipse)
color: Color used to display th lines.
thickness: Thickness of the drawings.
See also
vpDisplay::displayEllipse()

Definition at line 846 of file vpMeEllipse.cpp.

References vpDisplay::displayEllipse().

◆ get_ABE()

vpColVector vpMeEllipse::get_ABE ( ) const
inline

Gets the ellipse parameters as a 3-dim vector containing $ A, B, E $.

Returns
The 3-dim vector containing $ A, B, E $ corresponding respectively to the semi major axis, the semi minor axis and the angle in rad made by the major axis and the u axis of the image frame $ (u,v) $, $ e \in [-\pi/2;pi/2] $.
See also
getCenter(), get_nij(), getArea()

Definition at line 175 of file vpMeEllipse.h.

References m_a, m_b, and m_e.

◆ get_cP()

vpColVector vpTracker::get_cP ( ) const
inlineinherited

Return object parameters expressed in the 3D camera frame.

Definition at line 95 of file vpTracker.h.

References cP.

◆ get_nij()

vpColVector vpMeEllipse::get_nij ( ) const
inline

Gets the second order normalized centered moment $ n_{ij} $ as a 3-dim vector containing $ n_{20}, n_{11}, n_{02} $ such as $ n_{ij} = \mu_{ij}/m_{00} $

Returns
The 3-dim vector containing $ n_{20}, n_{11}, n_{02} $.
See also
getCenter(), get_ABE(), getArea()

Definition at line 153 of file vpMeEllipse.h.

References m_n02, m_n11, and m_n20.

Referenced by vpFeatureBuilder::create().

◆ get_p()

vpColVector vpTracker::get_p ( ) const
inlineinherited

Return object parameters expressed in the 2D image plane computed by perspective projection.

Definition at line 93 of file vpTracker.h.

References p.

◆ getArea()

double vpMeEllipse::getArea ( ) const
inline

Gets the area of the ellipse corresponding also to the zero order moment of the ellipse.

Returns
The ellipse area.
See also
getCenter(), get_nij(), get_ABE()

Definition at line 196 of file vpMeEllipse.h.

References m_m00.

◆ getCenter()

vpImagePoint vpMeEllipse::getCenter ( ) const
inline

Gets the center of the ellipse.

See also
get_nij(), get_ABE(), getArea()

Definition at line 203 of file vpMeEllipse.h.

References m_iPc.

Referenced by vpFeatureBuilder::create().

◆ getExpectedDensity()

unsigned int vpMeEllipse::getExpectedDensity ( ) const
inline
Returns
Expected number of moving edges to track along the ellipse.

Definition at line 208 of file vpMeEllipse.h.

References m_expectedDensity.

◆ getFirstEndpoint()

vpImagePoint vpMeEllipse::getFirstEndpoint ( ) const
inline

Gets the first endpoint of the ellipse arc (corresponding to alpha1, not alphamin) when an arc is tracked.

See also
getSecondEndpoint()

Definition at line 221 of file vpMeEllipse.h.

References m_iP1.

◆ getHighestAngle()

double vpMeEllipse::getHighestAngle ( ) const
inline

Gets the highest $ alpha $ angle of the moving edges tracked $ \alpha_{max} \in [\alpha_min;\alpha_2] $.

See also
getSmallestAngle()

Definition at line 229 of file vpMeEllipse.h.

References m_alphamax.

◆ getMe()

vpMe * vpMeTracker::getMe ( )
inlineinherited

Return the moving edges initialisation parameters.

Returns
Moving Edges.
Examples
trackMeCircle.cpp, trackMeEllipse.cpp, and trackMeLine.cpp.

Definition at line 153 of file vpMeTracker.h.

References m_me.

◆ getMeList() [1/2]

std::list< vpMeSite > & vpMeTracker::getMeList ( )
inlineinherited

Return the list of moving edges

Returns
List of Moving Edges.

Definition at line 160 of file vpMeTracker.h.

References m_meList.

◆ getMeList() [2/2]

std::list< vpMeSite > vpMeTracker::getMeList ( ) const
inlineinherited

Return the list of moving edges

Returns
List of Moving Edges.

Definition at line 167 of file vpMeTracker.h.

References m_meList.

◆ getNbPoints()

int vpMeTracker::getNbPoints ( ) const
inlineinherited

Return the number of points that has not been suppressed.

Returns
Number of good points.

Definition at line 174 of file vpMeTracker.h.

References m_nGoodElement.

◆ getNumberOfGoodPoints()

unsigned int vpMeEllipse::getNumberOfGoodPoints ( ) const
inline
Returns
Number of valid edges tracked along the ellipse.

Definition at line 213 of file vpMeEllipse.h.

References m_numberOfGoodPoints.

◆ getParameters()

void vpMeEllipse::getParameters ( )
protected

Computes the coordinates of the ellipse center, the normalized moments $ n_{ij} $, the length of the semi major axis $ a $, the length of the semi minor axis $ b $, and $ e $ that is the angle made by the major axis and the u axis of the image frame $ (u,v) $.

All those computations are made from the parameters $ K ={K_0, ..., K_5} $ so that $ K_0 u^2 + K1 v^2 + 2 K2 u v + 2 K3 u + 2 K4 v + K5 = 0 $.

Definition at line 258 of file vpMeEllipse.cpp.

References computeAbeFromNij(), vpTrackingException::fatalError, m_iPc, m_K, m_n02, m_n11, m_n20, m_uc, and m_vc.

Referenced by leastSquare(), leastSquareRobustCircle(), and leastSquareRobustEllipse().

◆ getSecondEndpoint()

vpImagePoint vpMeEllipse::getSecondEndpoint ( ) const
inline

Gets the second endpoint of the ellipse arc (corresponding to alpha2, not alphamax) when an arc is tracked.

See also
getFirstEndpoint()

Definition at line 237 of file vpMeEllipse.h.

References m_iP2.

◆ getSmallestAngle()

double vpMeEllipse::getSmallestAngle ( ) const
inline

Gets the smallest $ alpha $ angle of the moving edges tracked $ \alpha_{min} \in [\alpha_1;\alpha_2] $.

See also
getHighestAngle()

Definition at line 245 of file vpMeEllipse.h.

References m_alphamin.

◆ init()

BEGIN_VISP_NAMESPACE void vpMeTracker::init ( )
inherited

Initialize the tracker.

Definition at line 48 of file vpMeTracker.cpp.

References vpTracker::init(), m_selectDisplay, vpMeSite::NONE, and vpTracker::p.

Referenced by vpMeTracker(), and vpMeTracker().

◆ initTracking() [1/5]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > & I,
bool trackCircle = false,
bool trackArc = false )

Initialize the tracking of an ellipse or an arc of an ellipse when trackArc is set to true. Ask the user to click on five points located on the ellipse to be tracked.

Warning
The points should be selected as far as possible from each other. When an arc of an ellipse is tracked, it is recommended to select the 5 points clockwise.
Parameters
I: Image in which the ellipse appears.
trackCircle: When true, track a circle, when false track an ellipse.
trackArc: When true track an arc of the ellipse/circle. In that case, first and last points specify the extremities of the arc (clockwise). When false track the complete ellipse/circle.
Examples
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 599 of file vpMeEllipse.cpp.

References vpDisplay::displayCross(), vpDisplay::flush(), vpDisplay::getClick(), initTracking(), m_trackArc, m_trackCircle, and vpColor::red.

Referenced by initTracking().

◆ initTracking() [2/5]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > & I,
const std::vector< vpImagePoint > & iP,
bool trackCircle = false,
bool trackArc = false )

Initialize the tracking of an ellipse/circle or an arc of an ellipse/circle when trackArc is set to true. The ellipse/circle is defined thanks to a vector of image points.

Warning
It is mandatory to use at least five image points to estimate the ellipse parameters while three points are needed to estimate the circle parameters.
The image points should be selected as far as possible from each other. When an arc of an ellipse/circle is tracked, it is recommended to select the 5/3 points clockwise.
Parameters
I: Image in which the ellipse/circle appears.
iP: A vector of image points belonging to the ellipse/circle edge used to initialize the tracking.
trackCircle: When true, track a circle, when false track an ellipse.
trackArc: When true track an arc of the ellipse/circle. In that case, first and last points specify the extremities of the arc (clockwise). When false track the complete ellipse/circle.

Definition at line 641 of file vpMeEllipse.cpp.

References computeAngleOnEllipse(), computePointOnEllipse(), vpMeTracker::display(), vpDisplay::flush(), leastSquare(), m_alpha1, m_alpha2, m_arcEpsilon, m_iP1, m_iP2, m_trackArc, m_trackCircle, sample(), and track().

◆ initTracking() [3/5]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > & I,
const vpColVector & param,
vpImagePoint * pt1 = nullptr,
const vpImagePoint * pt2 = nullptr,
bool trackCircle = false )

Initialize the tracking of an ellipse/circle or an arc of an ellipse/circle when arc extremities are given. The ellipse/circle is defined by the vector containing the coordinates of its center and the three second order centered normalized moments $ n_ij $. Without setting the arc extremities with parameters pt1 and pt2, the complete ellipse/circle is considered. When extremities are set, we consider an ellipse/circle arc defined clockwise from first extremity to second extremity.

Parameters
I: Image in which the ellipse appears.
param: Vector with the five parameters $(u_c, v_c, n_{20}, n_{11}, n_{02})$ defining the ellipse (expressed in pixels).
pt1: Image point defining the first extremity of the arc or nullptr to track a complete ellipse.
pt2: Image point defining the second extremity of the arc or nullptr to track a complete ellipse.
trackCircle: When true enable tracking of a circle, when false the tracking of an ellipse.

Definition at line 674 of file vpMeEllipse.cpp.

References computeAbeFromNij(), computeAngleOnEllipse(), computeKiFromNij(), computePointOnEllipse(), vpMeTracker::display(), vpDisplay::flush(), m_alpha1, m_alpha2, m_arcEpsilon, m_iP1, m_iP2, m_iPc, m_n02, m_n11, m_n20, m_trackArc, m_trackCircle, m_uc, m_vc, sample(), and track().

◆ initTracking() [4/5]

void vpMeEllipse::initTracking ( const vpImage< unsigned char > & I,
std::optional< std::vector< vpImagePoint > > & opt_ips,
bool trackCircle = false,
bool trackArc = false )
inline

Initialize the tracking of an ellipse or an arc of an ellipse when trackArc is set to true. If ips is set, use the contained points to initialize the ME if there are some, or initialize by clicks the ME and ips will contained the clicked points. If ips is not set, call the method vpMeEllipse::initTracking(const vpImage<unsigned char>&, bool, bool).

See also
vpMeEllipse::initTracking()
Warning
The points should be selected as far as possible from each other. When an arc of an ellipse is tracked, it is recommended to select the 5 points clockwise.
Parameters
I: Image in which the ellipse appears.
opt_ipsIf set, either a vector that contains the vpImagePoint to use or will be filled with the clicked points.
trackCircle: When true, track a circle, when false track an ellipse.
trackArc: When true track an arc of the ellipse/circle. In that case, first and last points specify the extremities of the arc (clockwise). When false track the complete ellipse/circle.

Definition at line 282 of file vpMeEllipse.h.

References vpDisplay::displayCross(), vpDisplay::flush(), vpDisplay::getClick(), vpMeTracker::initTracking(), m_trackArc, m_trackCircle, and vpColor::red.

◆ initTracking() [5/5]

void vpMeTracker::initTracking ( const vpImage< unsigned char > & I)
inherited

◆ inMask()

VP_DEPRECATED bool vpMeTracker::inMask ( const vpImage< bool > * mask,
unsigned int i,
unsigned int j )
inlinestaticinherited
Deprecated
You should rather use inRoiMask(). Test whether the pixel is inside the region of interest mask. Mask values that are set to true are considered in the tracking.
Parameters
[in]mask: Mask corresponding to the region of interest in the image or nullptr if not wanted. Mask values that are set to true are considered in the tracking. To disable a pixel, set false.
[in]i: Pixel coordinate along the rows.
[in]j: Pixel coordinate along the columns.

Definition at line 294 of file vpMeTracker.h.

References inRoiMask().

◆ inMeMaskCandidates()

bool vpMeTracker::inMeMaskCandidates ( const vpImage< bool > * meMaskCandidates,
unsigned int i,
unsigned int j )
staticinherited

Test whether the moving-edge (ME) is inside the mask of ME candidates for the initialization. Mask values that are set to true and their 8 neighbors are considered for the initialization.

Parameters
[in]meMaskCandidates: Mask corresponding the ME location in the image or nullptr if not wanted. Mask values that are set to true are considered for the initialization. To disable a pixel, set false.
[in]i: ME coordinate along the rows.
[in]j: ME coordinate along the columns.

Definition at line 113 of file vpMeTracker.cpp.

References vpImage< Type >::getCols(), and vpImage< Type >::getRows().

Referenced by vpMeLine::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), and vpMeLine::seekExtremities().

◆ inRoiMask()

bool vpMeTracker::inRoiMask ( const vpImage< bool > * mask,
unsigned int i,
unsigned int j )
staticinherited

Test whether the pixel is inside the region of interest mask. Mask values that are set to true are considered in the tracking.

Parameters
[in]mask: Mask corresponding to the region of interest in the image or nullptr if not wanted. Mask values that are set to true are considered in the tracking. To disable a pixel, set false.
[in]i: Pixel coordinate along the rows.
[in]j: Pixel coordinate along the columns.

Definition at line 103 of file vpMeTracker.cpp.

References vpImage< Type >::getValue().

Referenced by vpMbtFaceDepthDense::computeDesiredFeatures(), vpMbtFaceDepthDense::computeDesiredFeatures(), vpMbtFaceDepthDense::computeDesiredFeatures(), vpMbtFaceDepthNormal::computeDesiredFeatures(), vpMbtFaceDepthNormal::computeDesiredFeatures(), vpMbtFaceDepthNormal::computeDesiredFeatures(), vpMbtDistanceKltPoints::computeNbDetectedCurrent(), vpMbtDistanceKltPoints::init(), inMask(), vpMeEllipse::plugHoles(), vpMeLine::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), vpMeLine::seekExtremities(), and track().

◆ leastSquare()

BEGIN_VISP_NAMESPACE void vpMeEllipse::leastSquare ( const vpImage< unsigned char > & I,
const std::vector< vpImagePoint > & iP )
protected

Least squares method to compute the circle/ ellipse to which the points belong.

Parameters
I: Image in which the circle/ellipse appears (useful just to get its number of rows and columns...
iP: A vector of points belonging to the circle/ellipse.

Definition at line 39 of file vpMeEllipse_least_square.cpp.

References vpException::dimensionError, getParameters(), m_K, m_trackCircle, vpMatrix::nullSpace(), vpMatrixException::rankDeficient, and vpMatrix::solveBySVD().

Referenced by initTracking().

◆ leastSquareRobust()

unsigned int vpMeEllipse::leastSquareRobust ( const vpImage< unsigned char > & I)
protected

Robust least squares method to compute the ellipse to which the vpMeSite belong. Manage also the lists of vpMeSite and corresponding angles, and update the expected density of points.

Parameters
I: Image where tracking is done (useful just to get its number of rows and columns...

Definition at line 358 of file vpMeEllipse_least_square.cpp.

References computeAngleOnEllipse(), vpTrackingException::fatalError, vpMeSite::getState(), leastSquareRobustCircle(), leastSquareRobustEllipse(), m_a, m_alpha1, m_alpha2, m_alphamax, m_alphamin, m_angleList, m_b, m_expectedDensity, vpMeSite::m_ifloat, vpMeSite::m_jfloat, vpMeTracker::m_me, vpMeTracker::m_meList, m_thresholdWeight, m_trackArc, m_trackCircle, vpMeSite::NO_SUPPRESSION, vpMeTracker::numberOfSignal(), and vpImagePoint::set_ij().

Referenced by track().

◆ leastSquareRobustCircle()

void vpMeEllipse::leastSquareRobustCircle ( const double & um,
const double & vm,
unsigned int & k,
vpColVector & w )
protected

Robust least squares method to compute the ellipse to which the vpMeSite belong, when we track a circle. Manage also the lists of vpMeSite and corresponding angles, and update the expected density of points.

Parameters
umHalf width of the image.
vmHalf height of the image.
kCount the number of tracked MEs.
wWeights computed by robust estimation.

Definition at line 132 of file vpMeEllipse_least_square.cpp.

References computeAngleOnEllipse(), computePointOnEllipse(), vpException::dimensionError, vpImagePoint::distance(), vpMeSite::get_ifloat(), vpMeSite::get_jfloat(), vpArray2D< Type >::getCols(), getParameters(), vpMeSite::getState(), m_K, vpMeTracker::m_meList, m_uc, m_vc, vpMeSite::NO_SUPPRESSION, vpMeTracker::numberOfSignal(), vpImagePoint::set_uv(), vpMatrix::solveBySVD(), and vpRobust::TUKEY.

Referenced by leastSquareRobust().

◆ leastSquareRobustEllipse()

void vpMeEllipse::leastSquareRobustEllipse ( const double & um,
const double & vm,
unsigned int & k,
vpColVector & w )
protected

Robust least squares method to compute the ellipse to which the vpMeSite belong, when we track an ellipse. Manage also the lists of vpMeSite and corresponding angles, and update the expected density of points.

Parameters
umHalf width of the image.
vmHalf height of the image.
kCount the number of tracked MEs.
wWeights computed by robust estimation.

Definition at line 241 of file vpMeEllipse_least_square.cpp.

References computeAngleOnEllipse(), computePointOnEllipse(), vpException::dimensionError, vpImagePoint::distance(), vpMeSite::get_ifloat(), vpMeSite::get_jfloat(), vpArray2D< Type >::getCols(), getParameters(), vpMeSite::getState(), m_K, vpMeTracker::m_meList, m_uc, m_vc, vpMeSite::NO_SUPPRESSION, vpMatrix::nullSpace(), vpMeTracker::numberOfSignal(), vpMatrixException::rankDeficient, vpImagePoint::set_uv(), and vpRobust::TUKEY.

Referenced by leastSquareRobust().

◆ numberOfSignal()

unsigned int vpMeTracker::numberOfSignal ( )
inherited

◆ operator=()

◆ outOfImage() [1/2]

bool vpMeTracker::outOfImage ( const vpImagePoint & iP,
int border,
int nrows,
int ncols )
inherited

Check if a pixel i,j is out of the image.

Parameters
[in]iP: Pixel coordinates.
[in]border: Number of pixels along the image border to exclude. When border is set to 0, consider the complete image.
[in]nrows: Image number of rows.
[in]ncols: Image number of cols.
Returns
true when the pixel is inside the image minus the border size, false otherwise.

Definition at line 172 of file vpMeTracker.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), and vpMath::round().

◆ outOfImage() [2/2]

bool vpMeTracker::outOfImage ( int i,
int j,
int border,
int nrows,
int ncols )
inherited

Check if a pixel i,j is out of the image.

Parameters
[in]i: Pixel coordinate along the image rows.
[in]j: Pixel coordinates along the image columns.
[in]border: Number of pixels along the image border to exclude. When border is set to 0, consider the complete image.
[in]nrows: Image number of rows.
[in]ncols: Image number of cols.
Returns
true when the pixel is inside the image minus the border size, false otherwise.

Definition at line 164 of file vpMeTracker.cpp.

Referenced by vpMeNurbs::localReSample(), vpMeEllipse::plugHoles(), vpMeLine::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), vpMeNurbs::sample(), vpMeLine::seekExtremities(), and vpMeNurbs::seekExtremities().

◆ plugHoles()

unsigned int vpMeEllipse::plugHoles ( const vpImage< unsigned char > & I)
protected

Seek along the ellipse or arc of ellipse its two extremities to try recovering lost points. Try also to complete the parts with no tracked points.

Parameters
I: Image in which the ellipse appears.
Returns
The function returns the number of points added to the list.
Exceptions
vpTrackingException::initializationError: Moving edges not initialized.

Definition at line 369 of file vpMeEllipse.cpp.

References computeAngleOnEllipse(), computePointOnEllipse(), computeTheta(), vpMeSite::convolution(), vpTrackingException::fatalError, vpImagePoint::get_i(), vpMeSite::get_ifloat(), vpImagePoint::get_j(), vpMeSite::get_jfloat(), vpMeSite::getState(), vpMeSite::init(), vpMeTracker::inRoiMask(), m_a, m_alpha1, m_alpha2, m_alphamax, m_alphamin, m_angleList, m_b, vpMeTracker::m_mask, vpMeTracker::m_me, vpMeTracker::m_meList, vpMeTracker::m_selectDisplay, vpMeSite::NO_SUPPRESSION, vpMeTracker::outOfImage(), vpImagePoint::set_ij(), vpMeSite::setContrastThreshold(), vpMeSite::setDisplay(), vpMeSite::setState(), and vpMeSite::track().

Referenced by track().

◆ printParameters()

void vpMeEllipse::printParameters ( ) const

Print the parameters $ K = {K_0, ..., K_5} $, the coordinates of the ellipse center, the normalized moments, and the A, B, E parameters.

Definition at line 291 of file vpMeEllipse.cpp.

References vpMath::deg(), m_a, m_b, m_e, m_K, m_n02, m_n11, m_n20, m_uc, and m_vc.

◆ reset()

void vpMeTracker::reset ( )
inherited

Reset the tracker by removing all the moving edges.

Definition at line 73 of file vpMeTracker.cpp.

References m_meList, and m_nGoodElement.

Referenced by ~vpMeTracker().

◆ sample()

void vpMeEllipse::sample ( const vpImage< unsigned char > & I,
bool doNotTrack = false )
protectedvirtual

Construct a list of vpMeSite moving edges at a particular sampling step between the two extremities. The two extremities are defined by the points with the smallest and the biggest $ alpha $ angle.

Parameters
I: Image in which the ellipse appears.
doNotTrack: If true, moving-edges are not tracked.
Exceptions
vpTrackingException::initializationError: Moving edges not initialized.

Implements vpMeTracker.

Definition at line 299 of file vpMeEllipse.cpp.

References computePointOnEllipse(), computeTheta(), vpMeSite::convolution(), vpDisplay::displayCross(), vpTrackingException::fatalError, vpImagePoint::get_i(), vpImagePoint::get_j(), vpMeSite::init(), vpMeTracker::initTracking(), vpMeTracker::inMeMaskCandidates(), vpMeTracker::inRoiMask(), m_a, m_alpha1, m_alpha2, m_angleList, m_b, m_expectedDensity, vpMeTracker::m_mask, vpMeTracker::m_maskCandidates, vpMeTracker::m_me, vpMeTracker::m_meList, vpMeTracker::m_selectDisplay, m_trackArc, vpMeSite::NO_SUPPRESSION, vpMeTracker::outOfImage(), vpColor::red, vpMeSite::setContrastThreshold(), vpMeSite::setDisplay(), and vpMeSite::setState().

Referenced by initTracking(), initTracking(), and track().

◆ setDisplay()

void vpMeTracker::setDisplay ( vpMeSite::vpMeSiteDisplayType select)
inlineinherited

Set type of moving-edges display.

Parameters
select: Display type selector.
Examples
servoAfma6Line2DCamVelocity.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, trackMeLine.cpp, trackMeNurbs.cpp, tutorial-me-ellipse-tracker.cpp, and tutorial-me-line-tracker.cpp.

Definition at line 234 of file vpMeTracker.h.

References m_selectDisplay.

◆ setEndpoints()

void vpMeEllipse::setEndpoints ( const vpImagePoint & pt1,
const vpImagePoint & pt2 )
inline

Set the two endpoints of the ellipse arc when an arc is tracked.

Definition at line 390 of file vpMeEllipse.h.

References m_iP1, and m_iP2.

◆ setMask()

virtual void vpMeTracker::setMask ( const vpImage< bool > & mask)
inlinevirtualinherited

Set the mask.

Parameters
mask: Mask.

Definition at line 241 of file vpMeTracker.h.

References m_mask.

◆ setMaskCandidates()

virtual void vpMeTracker::setMaskCandidates ( const vpImage< bool > * maskCandidates)
inlinevirtualinherited

Set the mask of candidates points for initialization.

Parameters
[in]maskCandidates: Pointer towards the mask of candidates points for initialization.

Definition at line 248 of file vpMeTracker.h.

References m_maskCandidates.

◆ setMe()

void vpMeTracker::setMe ( vpMe * me)
inlineinherited

Set the moving edges initialisation parameters.

Parameters
[in]me: Moving Edges.
Examples
servoAfma62DhalfCamVelocity.cpp, servoAfma6Line2DCamVelocity.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, trackMeLine.cpp, trackMeNurbs.cpp, tutorial-me-ellipse-tracker.cpp, and tutorial-me-line-tracker.cpp.

Definition at line 255 of file vpMeTracker.h.

References m_me.

◆ setMeList()

void vpMeTracker::setMeList ( const std::list< vpMeSite > & meList)
inlineinherited

Set the list of moving edges.

Parameters
[in]meList: List of Moving Edges.

Definition at line 262 of file vpMeTracker.h.

References m_meList.

◆ setThresholdRobust()

void vpMeEllipse::setThresholdRobust ( double threshold)
inline

Set the threshold for the weights in the robust estimation of the ellipse parameters. If the weight of a point is below this threshold, this one is removed from the list of tracked meSite. Value must be between 0 (never rejected) and 1 (always rejected).

Parameters
threshold: The new value of the threshold.

Definition at line 405 of file vpMeEllipse.h.

References m_thresholdWeight.

◆ totalNumberOfSignal()

unsigned int vpMeTracker::totalNumberOfSignal ( )
inherited

Return the total number of moving-edges.

Definition at line 101 of file vpMeTracker.cpp.

References m_meList.

◆ track()

void vpMeEllipse::track ( const vpImage< unsigned char > & I)

Track a set of MEs along an ellipse or a circle. The number of valid tracked MEs is obtained from getNumberOfGoodPoints().

Track the ellipse in the image I.

Parameters
I: Image in which the ellipse appears.
Examples
trackMeCircle.cpp, trackMeEllipse.cpp, and tutorial-me-ellipse-tracker.cpp.

Definition at line 728 of file vpMeEllipse.cpp.

References computeAngleOnEllipse(), computePointOnEllipse(), leastSquareRobust(), m_a, m_alpha1, m_alpha2, m_arcEpsilon, m_b, m_iP1, m_iP2, m_m00, m_numberOfGoodPoints, m_trackArc, vpTrackingException::notEnoughPointError, plugHoles(), sample(), vpMeTracker::track(), and updateTheta().

Referenced by initTracking(), and initTracking().

◆ updateTheta()

void vpMeEllipse::updateTheta ( )
protected

Compute the $ theta $ angle for each vpMeSite.

Note
The $ theta $ angle is useful during the tracking part.

Definition at line 125 of file vpMeEllipse.cpp.

References computeTheta(), vpMeSite::m_alpha, vpMeSite::m_ifloat, vpMeSite::m_jfloat, vpMeTracker::m_meList, and vpImagePoint::set_ij().

Referenced by track().

Member Data Documentation

◆ cP

◆ cPAvailable

bool vpTracker::cPAvailable
inherited

Flag used to indicate if the feature parameters cP expressed in the camera frame are available.

Definition at line 79 of file vpTracker.h.

Referenced by init(), operator=(), vpTracker(), and vpTracker().

◆ m_a

double vpMeEllipse::m_a
protected

◆ m_alpha1

double vpMeEllipse::m_alpha1
protected

The angle $ \alpha_1 \in [-\pi;\pi] $ on the ellipse corresponding to the first endpoint. Its value is 0 for tracking a complete ellipse

Definition at line 508 of file vpMeEllipse.h.

Referenced by display(), display(), initTracking(), initTracking(), leastSquareRobust(), operator=(), plugHoles(), sample(), track(), and vpMeEllipse().

◆ m_alpha2

double vpMeEllipse::m_alpha2
protected

The angle $ \alpha_2 \in [\alpha_1;\alpha_1+2\pi]$ on the ellipse corresponding to the second endpoint. Its value is $ 2 \pi $ for tracking a complete ellipse

Definition at line 513 of file vpMeEllipse.h.

Referenced by display(), display(), initTracking(), initTracking(), leastSquareRobust(), operator=(), plugHoles(), sample(), track(), and vpMeEllipse().

◆ m_alphamax

double vpMeEllipse::m_alphamax
protected

The highest angle $ \alpha_{max} \in [\alpha_{min};\alpha_2]$ of the current moving edge list

Definition at line 533 of file vpMeEllipse.h.

Referenced by getHighestAngle(), leastSquareRobust(), operator=(), plugHoles(), and vpMeEllipse().

◆ m_alphamin

double vpMeEllipse::m_alphamin
protected

The smallest angle $ \alpha_{min} \in [\alpha_1;\alpha_2]$ of the current moving edge list

Definition at line 529 of file vpMeEllipse.h.

Referenced by getSmallestAngle(), leastSquareRobust(), operator=(), plugHoles(), and vpMeEllipse().

◆ m_angleList

std::list<double> vpMeEllipse::m_angleList
protected

Stores the value in increasing order of the $ alpha $ angle on the ellipse for each vpMeSite.

Definition at line 519 of file vpMeEllipse.h.

Referenced by leastSquareRobust(), operator=(), plugHoles(), sample(), vpMeEllipse(), and ~vpMeEllipse().

◆ m_arcEpsilon

double vpMeEllipse::m_arcEpsilon
protected

Epsilon value used to check if arc angles are the same.

Definition at line 553 of file vpMeEllipse.h.

Referenced by initTracking(), initTracking(), operator=(), track(), and vpMeEllipse().

◆ m_b

double vpMeEllipse::m_b
protected

◆ m_ce

double vpMeEllipse::m_ce
protected

◆ m_e

double vpMeEllipse::m_e
protected

$ e \in [-\pi/2;\pi/2] $ is the angle made by the major axis and the u axis of the image frame $ (u,v) $.

Definition at line 495 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeAngleOnEllipse(), display(), display(), get_ABE(), operator=(), printParameters(), and vpMeEllipse().

◆ m_expectedDensity

unsigned int vpMeEllipse::m_expectedDensity
protected

Expected number of points to track along the ellipse.

Definition at line 545 of file vpMeEllipse.h.

Referenced by getExpectedDensity(), leastSquareRobust(), operator=(), sample(), and vpMeEllipse().

◆ m_iP1

vpImagePoint vpMeEllipse::m_iP1
protected

The coordinates of the first endpoint of the ellipse arc corresponding to angle $ \alpha_1 $

Definition at line 500 of file vpMeEllipse.h.

Referenced by getFirstEndpoint(), initTracking(), initTracking(), operator=(), setEndpoints(), track(), and vpMeEllipse().

◆ m_iP2

vpImagePoint vpMeEllipse::m_iP2
protected

The coordinates of the second endpoint of the ellipse arc corresponding to angle $ \alpha_2 $

Definition at line 504 of file vpMeEllipse.h.

Referenced by getSecondEndpoint(), initTracking(), initTracking(), operator=(), setEndpoints(), track(), and vpMeEllipse().

◆ m_iPc

vpImagePoint vpMeEllipse::m_iPc
protected

The coordinates of the ellipse center.

Definition at line 487 of file vpMeEllipse.h.

Referenced by display(), display(), getCenter(), getParameters(), initTracking(), operator=(), and vpMeEllipse().

◆ m_K

vpColVector vpMeEllipse::m_K
protected

Parameters of the ellipse satisfying the homogeneous equation :

\‍[ K_0 u^2 + K_1 v^2 + 2K_2 uv + 2K_3u + 2K_4v + K5 = 0 \‍]

Definition at line 485 of file vpMeEllipse.h.

Referenced by computeKiFromNij(), computeTheta(), getParameters(), leastSquare(), leastSquareRobustCircle(), leastSquareRobustEllipse(), operator=(), printParameters(), and vpMeEllipse().

◆ m_m00

double vpMeEllipse::m_m00
protected

Ellipse area.

Definition at line 521 of file vpMeEllipse.h.

Referenced by getArea(), operator=(), track(), and vpMeEllipse().

◆ m_mask

const vpImage<bool>* vpMeTracker::m_mask
protectedinherited

Mask used to disable tracking on a part of image.

Definition at line 312 of file vpMeTracker.h.

Referenced by vpMeEllipse::plugHoles(), vpMeLine::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), vpMeLine::seekExtremities(), setMask(), track(), vpMeTracker(), and vpMeTracker().

◆ m_maskCandidates

const vpImage<bool>* vpMeTracker::m_maskCandidates
protectedinherited

Mask used to determine candidate points for initialization in an image.

Definition at line 314 of file vpMeTracker.h.

Referenced by vpMeLine::plugHoles(), vpMeEllipse::sample(), vpMeLine::sample(), vpMeLine::seekExtremities(), setMaskCandidates(), vpMeTracker(), and vpMeTracker().

◆ m_me

◆ m_meList

◆ m_n02

double vpMeEllipse::m_n02
protected

Second order centered and normalized moments $ n_{02} $.

Definition at line 543 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeKiFromNij(), computeNijFromAbe(), get_nij(), getParameters(), initTracking(), operator=(), printParameters(), and vpMeEllipse().

◆ m_n11

double vpMeEllipse::m_n11
protected

Second order centered and normalized moments $ n_{11} $.

Definition at line 541 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeKiFromNij(), computeNijFromAbe(), get_nij(), getParameters(), initTracking(), operator=(), printParameters(), and vpMeEllipse().

◆ m_n20

double vpMeEllipse::m_n20
protected

Second order centered and normalized moments $ n_{20} $.

Definition at line 539 of file vpMeEllipse.h.

Referenced by computeAbeFromNij(), computeKiFromNij(), computeNijFromAbe(), get_nij(), getParameters(), initTracking(), operator=(), printParameters(), and vpMeEllipse().

◆ m_nGoodElement

int vpMeTracker::m_nGoodElement
protectedinherited

Number of good moving-edges that are tracked.

Definition at line 310 of file vpMeTracker.h.

Referenced by getNbPoints(), initTracking(), operator=(), reset(), track(), vpMeTracker(), and vpMeTracker().

◆ m_numberOfGoodPoints

unsigned int vpMeEllipse::m_numberOfGoodPoints
protected

Number of correct points tracked along the ellipse.

Definition at line 547 of file vpMeEllipse.h.

Referenced by getNumberOfGoodPoints(), operator=(), track(), and vpMeEllipse().

◆ m_se

double vpMeEllipse::m_se
protected

◆ m_selectDisplay

◆ m_thresholdWeight

double vpMeEllipse::m_thresholdWeight
protected

Threshold on the weights for the robust least square.

Definition at line 524 of file vpMeEllipse.h.

Referenced by leastSquareRobust(), operator=(), setThresholdRobust(), and vpMeEllipse().

◆ m_trackArc

bool vpMeEllipse::m_trackArc
protected

Track an arc of ellipse/circle (true) or a complete one (false).

Definition at line 551 of file vpMeEllipse.h.

Referenced by initTracking(), initTracking(), initTracking(), initTracking(), leastSquareRobust(), operator=(), sample(), track(), and vpMeEllipse().

◆ m_trackCircle

bool vpMeEllipse::m_trackCircle
protected

Track a circle (true) or an ellipse (false).

Definition at line 549 of file vpMeEllipse.h.

Referenced by initTracking(), initTracking(), initTracking(), initTracking(), leastSquare(), leastSquareRobust(), operator=(), and vpMeEllipse().

◆ m_uc

double vpMeEllipse::m_uc
protected

◆ m_vc

double vpMeEllipse::m_vc
protected

◆ p

vpColVector vpTracker::p
inherited

Feature coordinates expressed in the image plane p. They correspond to 2D normalized coordinates expressed in meters.

Definition at line 69 of file vpTracker.h.

Referenced by vpCircle::computeIntersectionPoint(), vpMeterPixelConversion::convertEllipse(), vpMeterPixelConversion::convertEllipse(), vpMeterPixelConversion::convertEllipse(), vpMeterPixelConversion::convertEllipse(), vpCircle::display(), vpCircle::display(), vpCylinder::display(), vpCylinder::display(), vpLine::display(), vpLine::display(), vpPoint::display(), vpPoint::display(), vpSphere::display(), vpSphere::display(), vpFeatureDisplay::displayEllipse(), vpFeatureDisplay::displayEllipse(), vpPose::displayModel(), vpPose::displayModel(), vpImageDraw::drawFrame(), vpImageDraw::drawFrame(), vpCircle::get_mu02(), vpSphere::get_mu02(), vpCircle::get_mu11(), vpSphere::get_mu11(), vpCircle::get_mu20(), vpSphere::get_mu20(), vpCircle::get_n02(), vpSphere::get_n02(), vpCircle::get_n11(), vpSphere::get_n11(), vpCircle::get_n20(), vpSphere::get_n20(), get_p(), vpPoint::get_w(), vpCircle::get_x(), vpPoint::get_x(), vpSphere::get_x(), vpCircle::get_y(), vpPoint::get_y(), vpSphere::get_y(), vpLine::getRho(), vpCylinder::getRho1(), vpCylinder::getRho2(), vpLine::getTheta(), vpCylinder::getTheta1(), vpCylinder::getTheta2(), vpCircle::init(), vpCylinder::init(), vpLine::init(), vpMeTracker::init(), vpPoint::init(), vpSphere::init(), vpCircle::operator=(), operator=(), vpForwardProjection::print(), vpPose::printPoint(), vpForwardProjection::project(), vpCircle::projection(), vpCylinder::projection(), vpForwardProjection::projection(), vpLine::projection(), vpPoint::projection(), vpSphere::projection(), vpPoint::set_w(), vpPoint::set_x(), vpPoint::set_y(), vpLine::setRho(), vpLine::setTheta(), vpTracker(), and vpTracker().