Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings and issue in tutorial/imgproc/tutorial-circle-hough.cpp #1501

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#############################################################################
#
# ViSP, open source Visual Servoing Platform software.
# Copyright (C) 2005 - 2023 by Inria. All rights reserved.
# Copyright (C) 2005 - 2024 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 as published by
Expand Down Expand Up @@ -1896,7 +1896,7 @@ endif()
status("")
status(" Library dirs:")
if(USE_EIGEN3)
status(" Eigen3 include dir:" "${Eigen3_DIR}")
status(" Eigen3 dir:" "${Eigen3_DIR}")
endif()
if(USE_MKL)
status(" MKL include dir:" "${MKL_INCLUDE_DIRS}")
Expand All @@ -1910,6 +1910,16 @@ endif()
if(USE_PCL)
status(" PCL dir:" "${PCL_DIR}")
endif()
if(USE_PANDA3D)
if(Panda3D_DIR)
status(" Panda3D dir:" "${Panda3D_DIR}")
else()
status(" Panda3D dir:" "$ENV{Panda3D_DIR}")
endif()
endif()
if(USE_YARP)
status(" Yarp dir:" "${YARP_DIR}")
endif()

# ========================== auxiliary ==========================
status("")
Expand Down
3 changes: 2 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ ViSP 3.x.x (Version in development)
. [#1296] Unable to parse camera parameters with vpXmlParserCamera::parse() when camera name is empty
. [#1307] Cannot set cxx standard when configuring for Visual Studio
. [#1320] Broken links in the documentation
. [#1337] The pose of the automatic datageneration pipeline from blenderproc seems wrong
. [#1337] The pose of the automatic data generation pipeline from blenderproc seems wrong
. [#1341] SVD computation fails with Lapack when m < n
. [#1370] encountered compilation errors while building the ViSP library
. [#1424] Unable to detect Yarp 3.9.0
. [#1485] Build issue around nlohmann_json usage with VTK 9.2.0 or more recent version used as an embedded
3rdparty by PCL
. [#1487] Segfault with vpCannyEdgeDetection with a certain image
. [#1494] Memory management issue in vpArray2D::resize()
. [#1495] vpMeLine is unable to seek extremities
----------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int main(int argc, const char **argv)
std::stringstream ss_gray;
ss_gray << input_name << "_adjust_alpha=" << alpha << "_beta=" << beta << "_gray.png";
display(I_display, I_color_res, I_color_adjust, I_gray_res, I_gray_adjust, I_gray_display,
"Brightness and contrast adjustment. Click to continue.", ss_color.str(), ss_gray.str());
"Brightness and contrast adjustment. Click to continue.", ss_color.str(), ss_gray.str());

//! [Gamma correction]
if (method != VISP_NAMESPACE_NAME::GAMMA_MANUAL) {
Expand Down
1 change: 1 addition & 0 deletions tutorial/imgproc/hough-transform/drawingHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using namespace VISP_NAMESPACE_NAME;
bool drawingHelpers::display(vpImage< vpRGBa> &I, const std::string &title, const bool &blockingMode)
{
vpDisplay::display(I);
vpDisplay::setTitle(I, title);
vpDisplay::displayText(I, 15, 15, "Left click to continue...", vpColor::red);
vpDisplay::displayText(I, 35, 15, "Right click to stop...", vpColor::red);
vpDisplay::flush(I);
Expand Down
124 changes: 63 additions & 61 deletions tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
using namespace VISP_NAMESPACE_NAME;
#endif

bool run_detection(const vpImage<unsigned char> &I_src, vpImage<vpRGBa> &I_disp, vpImage<vpRGBa> &I_dispCanny, vpCircleHoughTransform &detector, const int &nbCirclesToDetect, const bool &blockingMode, const bool &displayCanny)
bool run_detection(const vpImage<unsigned char> &I_src, vpImage<vpRGBa> &I_disp, vpImage<vpRGBa> &I_dispCanny,
vpCircleHoughTransform &detector, const int &nbCirclesToDetect, const bool &blockingMode,
const bool &displayCanny)
{
double t0 = vpTime::measureTimeMicros();
//! [Run detection]
Expand Down Expand Up @@ -60,23 +62,17 @@ bool run_detection(const vpImage<unsigned char> &I_src, vpImage<vpRGBa> &I_disp,
}
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
std::optional<vpImage<bool>> opt_mask = std::nullopt;
std::optional<std::vector<std::vector<std::pair<unsigned int, unsigned int>>>> opt_votingPoints = std::nullopt;
#elif (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
vpImage<bool> *opt_mask = nullptr;
std::vector<std::vector<std::pair<unsigned int, unsigned int>>> *opt_votingPoints = nullptr;
detector.computeVotingMask(I_src, detectedCircles, &opt_mask, &opt_votingPoints); // Get, if available, the voting points
std::optional<std::vector<std::vector<std::pair<unsigned int, unsigned int> > > > opt_votingPoints = std::nullopt;
#else
vpImage<bool> *opt_mask = NULL;
std::vector<std::vector<std::pair<unsigned int, unsigned int> > > *opt_votingPoints = NULL;
vpImage<bool> *opt_mask = nullptr;
std::vector<std::vector<std::pair<unsigned int, unsigned int> > > *opt_votingPoints = nullptr;
detector.computeVotingMask(I_src, detectedCircles, &opt_mask, &opt_votingPoints); // Get, if available, the voting points
#endif

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
if (opt_votingPoints)
#elif (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
if (opt_votingPoints != nullptr)
#else
if (opt_votingPoints != NULL)
if (opt_votingPoints != nullptr)
#endif
{
const unsigned int crossSize = 3;
Expand All @@ -94,25 +90,14 @@ bool run_detection(const vpImage<unsigned char> &I_src, vpImage<vpRGBa> &I_disp,
}
}
#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_17)
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
if (opt_mask != nullptr)
#else
if (opt_mask != NULL)
#endif
{
if (opt_mask != nullptr) {
delete opt_mask;
}
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
if (opt_votingPoints != nullptr)
#else
if (opt_votingPoints != NULL)
#endif
{
if (opt_votingPoints != nullptr) {
delete opt_votingPoints;
}
#endif
//! [Iterate detections]

//! [Iterate detections]
if (displayCanny) {
vpImage<unsigned char> edgeMap = detector.getEdgeMap();
drawingHelpers::display(edgeMap, I_dispCanny, "Edge map", blockingMode);
Expand Down Expand Up @@ -511,39 +496,9 @@ int main(int argc, char **argv)
//! [Algo init]
std::cout << detector;

//! [Display init]
vpImage<unsigned char> I_src;
vpImage<vpRGBa> I_disp;
vpImage<vpRGBa> I_dispCanny;
// Read the (first) image
char *filename = new char[opt_input.size() + 50];
if (opt_input.find("%") != std::string::npos) {
// Read the first frame
sprintf(filename, opt_input.c_str(), 0);
}
else {
// Simply get the filename
strcpy(filename, opt_input.c_str());
}
std::string filenameAsStr(filename);
delete[] filename;
vpImageIo::read(I_src, filenameAsStr);
I_disp.resize(I_src.getHeight(), I_src.getWidth());
I_dispCanny.resize(I_src.getHeight(), I_src.getWidth());
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
std::shared_ptr<vpDisplay> dColor = vpDisplayFactory::createDisplay(I_disp, -1, -1, "Input image");;
std::shared_ptr<vpDisplay> dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::createDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#else
vpDisplay *dColor = vpDisplayFactory::allocateDisplay(I_disp, -1, -1, "Input image");;
vpDisplay *dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::allocateDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#endif
//! [Display init]

//! [Manage video]
if (opt_input.find("%") != std::string::npos) {
Expand All @@ -552,11 +507,38 @@ int main(int argc, char **argv)
vpVideoReader g;
g.setFileName(opt_input);
g.open(I_src);

//! [Display init]
I_disp.resize(I_src.getHeight(), I_src.getWidth());
I_dispCanny.resize(I_src.getHeight(), I_src.getWidth());
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
std::shared_ptr<vpDisplay> dColor = vpDisplayFactory::createDisplay(I_disp, -1, -1, "Input image");;
std::shared_ptr<vpDisplay> dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::createDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#else
vpDisplay *dColor = vpDisplayFactory::allocateDisplay(I_disp, -1, -1, "Input image");;
vpDisplay *dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::allocateDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#endif
//! [Display init]
while (!g.end() && hasToContinue) {
g.acquire(I_src);
hasToContinue = run_detection(I_src, I_disp, I_dispCanny, detector, opt_nbCirclesToDetect, false, opt_displayCanny);
vpTime::wait(40);
}

#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
delete dColor;
if (dCanny != nullptr) {
if (opt_displayCanny) {
delete dCanny;
}
}
#endif
}
//! [Manage video]
else {
Expand All @@ -567,15 +549,35 @@ int main(int argc, char **argv)
}
// Read the image and perform detection on it
vpImageIo::read(I_src, opt_input);

I_disp.resize(I_src.getHeight(), I_src.getWidth());
I_dispCanny.resize(I_src.getHeight(), I_src.getWidth());
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
std::shared_ptr<vpDisplay> dColor = vpDisplayFactory::createDisplay(I_disp, -1, -1, "Input image");;
std::shared_ptr<vpDisplay> dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::createDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#else
vpDisplay *dColor = vpDisplayFactory::allocateDisplay(I_disp, -1, -1, "Input image");;
vpDisplay *dCanny(nullptr);
if (opt_displayCanny) {
dCanny = vpDisplayFactory::allocateDisplay(I_dispCanny, I_src.getWidth() + 40, -1, "Edge-map");
}
#endif

run_detection(I_src, I_disp, I_dispCanny, detector, opt_nbCirclesToDetect, true, opt_displayCanny);
//! [Manage single image]
}

#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
delete dColor;
if (dCanny != nullptr) {
delete dCanny;
}
delete dColor;
if (dCanny != nullptr) {
if (opt_displayCanny) {
delete dCanny;
}
}
#endif
//! [Manage single image]
}

return EXIT_SUCCESS;
}
Loading