Skip to content

Commit

Permalink
Changes to set OpenCV 2.4.8 as minimal required version
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Mar 13, 2024
1 parent 25dcb1d commit 0a7d3f3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 440 deletions.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,23 @@ if(USE_PCL)
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
endif()

# ----------------------------------------------------------------------------
# Handle OpenCV 2.4.8 as minimal version
# ----------------------------------------------------------------------------
if(USE_OPENCV)
if(OpenCV_VERSION)
if(OpenCV_VERSION VERSION_LESS "2.4.8")
message(WARNING "OpenCV 3rd party was detected but its version ${OpenCV_VERSION} is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
else()
message(WARNING "OpenCV 3rd party was detected but its version cannot be found or is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
endif()

# ----------------------------------------------------------------------------
# Handle cxx standard depending on specific 3rd parties. Should be before module parsing and VISP3rdParty.cmake include
# ----------------------------------------------------------------------------
Expand All @@ -642,7 +659,7 @@ endif()

if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_14)
if(USE_FTIITSDK)
message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_OPENCV=OFF.")
message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_FTIITSDK=OFF.")
unset(USE_FTIITSDK)
set(USE_FTIITSDK OFF CACHE BOOL "Include IIT force-torque SDK support" FORCE)
endif()
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ViSP 3.x.x (Version in development)
. End of supporting c++98 standard. As a consequence, ViSP is no more compatible with Ubuntu 12.04
. vpDisplay::displayCharString() is marked deprecated. Use vpDisplay::displayText() instead
- New features and improvements
. OpenCV 2.4.8 is the minimal supported version
. Introduce applications in apps folder, a collection of useful tools that
have a dependency to the install target
. Bump minimal c++ standard to c++11
Expand Down
21 changes: 9 additions & 12 deletions doc/tutorial/tracking/tutorial-tracking-keypoint.dox
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ It can also be run with [--init-by-click] option. In that case, the user can sel
$ ./tutorial-klt-tracker --init-by-click
\endcode

Here is the line by line explanation of the source :
Here is the line by line explanation of the source :

\snippet tutorial-klt-tracker.cpp Include

Expand All @@ -60,19 +60,19 @@ This image \c I is then converted into \c cvI, an OpenCV image format that will

\snippet tutorial-klt-tracker.cpp Convert to OpenCV image

We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I.
We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I.

\snippet tutorial-klt-tracker.cpp Init display

From now we have to create an instance of the tracker and set the parameters of the Harris keypoint detector.

\snippet tutorial-klt-tracker.cpp Create tracker

The tracker is then initialized on \c cvI image.

\snippet tutorial-klt-tracker.cpp Init tracker

With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization.
With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization.

\snippet tutorial-klt-tracker.cpp How many features

Expand All @@ -92,7 +92,7 @@ We are waiting for a mouse click event on image \c I to end the program.

\section tracking_keypoint_klt_init KLT tracker with re-initialisation

Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection.
Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection.

To get the number of detected or tracked features just call:

Expand All @@ -107,10 +107,10 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
\code
if (reader.getFrameIndex() == 25) {
std::cout << "Re initialize the tracker" << std::endl;
#if (VISP_HAVE_OPENCV_VERSION >= 0x020408)

// Save of previous features
std::vector<cv::Point2f> prev_features = tracker.getFeatures();

// Start a new feature detection
tracker.initTracking(cvI);
std::vector<cv::Point2f> new_features = tracker.getFeatures();
Expand All @@ -122,7 +122,7 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
// Test if a previous feature is not redundant with one of the newly detected
is_redundant = false;
for (size_t j=0; j < new_features.size(); j++){
distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x)
distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x)
+ vpMath::sqr(new_features[j].y-prev_features[i].y));
if(distance < minDistance_){
is_redundant = true;
Expand All @@ -135,9 +135,6 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
//std::cout << "Add previous feature with index " << i << std::endl;
tracker.addFeature(prev_features[i]);
}
#else
...
#endif
}
// Track the features
tracker.track(cvI);
Expand Down
17 changes: 2 additions & 15 deletions modules/gui/include/visp3/gui/vpDisplayOpenCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,11 @@
class VISP_EXPORT vpDisplayOpenCV : public vpDisplay
{
private:
#if (VISP_HAVE_OPENCV_VERSION < 0x020408)
IplImage *m_background;
CvScalar *col;
CvScalar cvcolor;
CvFont *font;
#else
cv::Mat m_background;
cv::Scalar *col;
cv::Scalar cvcolor;
int font;
float fontScale;
#endif
static std::vector<std::string> m_listTitles;
static unsigned int m_nbWindows;
int fontHeight;
Expand Down Expand Up @@ -175,14 +168,8 @@ class VISP_EXPORT vpDisplayOpenCV : public vpDisplay
// private:
//#ifndef DOXYGEN_SHOULD_SKIP_THIS
// vpDisplayOpenCV(const vpDisplayOpenCV &)
// : vpDisplay(),
// #if (VISP_HAVE_OPENCV_VERSION < 0x020408)
// background(nullptr), col(nullptr), cvcolor(), font(nullptr),
// #else
// background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN),
// fontScale(0.8f),
// #endif
// fontHeight(10), x_move(0), y_move(0) , move(false),
// : vpDisplay(), background(), col(nullptr), cvcolor(), font(cv::FONT_HERSHEY_PLAIN),
// fontScale(0.8f), fontHeight(10), x_move(0), y_move(0) , move(false),
// x_lbuttondown(0), y_lbuttondown(0), lbuttondown(false),
// x_mbuttondown(0), y_mbuttondown(0), mbuttondown(false),
// x_rbuttondown(0), y_rbuttondown(0), rbuttondown(false),
Expand Down
Loading

0 comments on commit 0a7d3f3

Please sign in to comment.