Skip to content

Commit

Permalink
Fix build on centos 7.2 ci that has OpenCV 2.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Mar 13, 2024
1 parent d478399 commit 25dcb1d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ vpImage<Type>::vpImage(const vpImage<Type> &I)
{
resize(I.getHeight(), I.getWidth());
if (bitmap) {
memcpy(static_cast<void*>(bitmap), static_cast<void*>(I.bitmap), I.npixels * sizeof(Type));
memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpImageConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <visp3/core/vpRGBa.h>

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif

static std::string ipath = vpIoTools::getViSPImagesDataPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif

static const std::string ipath = vpIoTools::getViSPImagesDataPath();
Expand Down
2 changes: 1 addition & 1 deletion modules/core/test/image-with-dataset/perfImageResize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif

static const std::string ipath = vpIoTools::getViSPImagesDataPath();
Expand Down
2 changes: 1 addition & 1 deletion modules/core/test/image-with-dataset/testConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif

/*!
Expand Down
7 changes: 7 additions & 0 deletions modules/gui/include/visp3/gui/vpDisplayOpenCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,18 @@
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
48 changes: 20 additions & 28 deletions modules/gui/src/display/vpDisplayOpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ void vpDisplayOpenCV::displayImageROI(const vpImage<unsigned char> &I, const vpI
\warning Display has to be initialized.
\warning suppres the overlay drawing
\warning suppress the overlay drawing
\param I : Image to display.
Expand Down Expand Up @@ -1142,7 +1142,7 @@ void vpDisplayOpenCV::displayText(const vpImagePoint &ip, const std::string &tex
if (m_displayHasBeenInitialized) {
if (color.id < vpColor::id_unknown) {
#if VISP_HAVE_OPENCV_VERSION < 0x020408
cvPutText(m_background, text,
cvPutText(m_background, text.c_str(),
cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font,
col[color.id]);
#else
Expand All @@ -1154,7 +1154,7 @@ void vpDisplayOpenCV::displayText(const vpImagePoint &ip, const std::string &tex
else {
cvcolor = CV_RGB(color.R, color.G, color.B);
#if VISP_HAVE_OPENCV_VERSION < 0x020408
cvPutText(m_background, text,
cvPutText(m_background, text.c_str(),
cvPoint(vpMath::round(ip.get_u() / m_scale), vpMath::round(ip.get_v() / m_scale + fontHeight)), font,
cvcolor);
#else
Expand Down Expand Up @@ -1209,11 +1209,10 @@ void vpDisplayOpenCV::displayCircle(const vpImagePoint &center, unsigned int rad
#else
int filled = CV_FILLED;
#endif
double opacity = static_cast<double>(color.A) / 255.0;
#if VISP_HAVE_OPENCV_VERSION < 0x020408
overlay([x, y, r, cv_color, filled](cv::Mat image) { cvCircle(image, cvPoint(x, y), r, cv_color, filled); },
opacity);
cvCircle(m_background, cvPoint(x, y), r, cv_color, filled);
#else
double opacity = static_cast<double>(color.A) / 255.0;
overlay([x, y, r, cv_color, filled](cv::Mat image) { cv::circle(image, cv::Point(x, y), r, cv_color, filled); },
opacity);
#endif
Expand Down Expand Up @@ -1426,15 +1425,12 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, unsigned int
#else
int filled = CV_FILLED;
#endif
double opacity = static_cast<double>(color.A) / 255.0;
#if VISP_HAVE_OPENCV_VERSION < 0x020408
overlay([left, top, right, bottom, cv_color, filled](
cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); },
opacity);
cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled);
#else
overlay(
[left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
double opacity = static_cast<double>(color.A) / 255.0;
overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
},
opacity);
#endif
Expand Down Expand Up @@ -1488,15 +1484,12 @@ void vpDisplayOpenCV::displayRectangle(const vpImagePoint &topLeft, const vpImag
#else
int filled = CV_FILLED;
#endif
double opacity = static_cast<double>(color.A) / 255.0;
#if VISP_HAVE_OPENCV_VERSION < 0x020408
overlay([left, top, right, bottom, cv_color, filled](
cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); },
opacity);
cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled);
#else
overlay(
[left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
double opacity = static_cast<double>(color.A) / 255.0;
overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
},
opacity);
#endif
Expand Down Expand Up @@ -1549,15 +1542,12 @@ void vpDisplayOpenCV::displayRectangle(const vpRect &rectangle, const vpColor &c
#else
int filled = CV_FILLED;
#endif
double opacity = static_cast<double>(color.A) / 255.0;
#if VISP_HAVE_OPENCV_VERSION < 0x020408
overlay([left, top, right, bottom, cv_color, filled](
cv::Mat image) { cvRectangle(image, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled); },
opacity);
cvRectangle(m_background, cvPoint(left, top), cvPoint(right, bottom), cv_color, filled);
#else
overlay(
[left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
double opacity = static_cast<double>(color.A) / 255.0;
overlay([left, top, right, bottom, cv_color, filled](cv::Mat image) {
cv::rectangle(image, cv::Point(left, top), cv::Point(right, bottom), cv_color, filled);
},
opacity);
#endif
Expand Down Expand Up @@ -2147,6 +2137,7 @@ unsigned int vpDisplayOpenCV::getScreenHeight()
return height;
}

#if VISP_HAVE_OPENCV_VERSION >= 0x020408
/*!
* Initialize display overlay layer for transparency.
* \param overlay_function : Overlay function
Expand All @@ -2161,7 +2152,7 @@ void vpDisplayOpenCV::overlay(std::function<void(cv::Mat &)> overlay_function, d
overlay = m_background.clone();
}
else {
// Shallow copy
// Shallow copy
overlay = m_background;
}

Expand All @@ -2172,6 +2163,7 @@ void vpDisplayOpenCV::overlay(std::function<void(cv::Mat &)> overlay_function, d
cv::addWeighted(overlay, opacity, m_background, 1.0 - opacity, 0.0, m_background);
}
}
#endif

#elif !defined(VISP_BUILD_SHARED_LIBS)
// Work around to avoid warning: libvisp_core.a(vpDisplayOpenCV.cpp.o) has no symbols
Expand Down
2 changes: 1 addition & 1 deletion tutorial/image/tutorial-image-converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGCODECS) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#endif

int main()
Expand Down

0 comments on commit 25dcb1d

Please sign in to comment.