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

Remove template for vpDisplayFactory::createDisplay() #1450

Merged
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
7 changes: 2 additions & 5 deletions modules/gui/include/visp3/gui/vpDisplayFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,12 @@ vpDisplay *allocateDisplay(vpImage<T> &I, const int winx = -1, const int winy =

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
/**
* \brief Return a smart pointer vpDisplay specialization initialized with \b I
* \brief Return a smart pointer vpDisplay specialization
* if a GUI library is available or nullptr otherwise.
*
* \tparam T : Any type that an image can handle and that can be displayed.
*
* \return A smart pointer pointing to a vpDisplay specialization initialized with \b I
* \return A smart pointer pointing to a vpDisplay specialization
* if a GUI library is available or nullptr otherwise.
*/
template<typename T>
std::shared_ptr<vpDisplay> createDisplay()
{
#if defined(VISP_HAVE_DISPLAY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include <memory>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpIoTools.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayOpenCV.h>
#include <visp3/gui/vpDisplayFactory.h>
#include <visp3/io/vpImageIo.h>
#include <visp3/core/vpImageDraw.h>

#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI)) \
&& (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
#if defined(VISP_HAVE_DISPLAY) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
namespace
{
// https://en.cppreference.com/w/cpp/io/c/fprintf
Expand All @@ -22,23 +19,12 @@

return str;
}

template<typename T, typename... Args>
std::unique_ptr<T> make_unique_compat(Args&&... args)
{
#if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)))
return std::make_unique<T>(args...);
#else
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
#endif
}
}
#endif

int main(int argc, char *argv[])
{
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI)) \
&& (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ)
#if defined(VISP_HAVE_DISPLAY) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ)
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
Expand Down Expand Up @@ -114,14 +100,8 @@
vpImage<unsigned char> I(height, width);
vpImage<vpRGBa> I_display(height, width);

std::unique_ptr<vpDisplay> display;
#if defined(VISP_HAVE_X11)
display = make_unique_compat<vpDisplayX>(I_display, 100, 100, "Model-based tracker");
#elif defined(VISP_HAVE_GDI)
display = make_unique_compat<vpDisplayGDI>(I_display, 100, 100, "Model-based tracker");
#elif defined(HAVE_OPENCV_HIGHGUI)
display = make_unique_compat<vpDisplayOpenCV>(I_display, 100, 100, "Model-based tracker");
#endif
std::shared_ptr<vpDisplay> display = vpDisplayFactory::createDisplay();
display->init(I_display, 100, 100, "Model-based tracker");

Check warning on line 104 in tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp#L104

Added line #L104 was not covered by tests

visp::cnpy::NpyArray arr_nb_data = npz_data["nb_data"];
int nb_data = *arr_nb_data.data<int>();
Expand Down
Loading