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

OpenCV compatibility issue ??? #23

Open
jiapei100 opened this issue Feb 12, 2020 · 2 comments
Open

OpenCV compatibility issue ??? #23

jiapei100 opened this issue Feb 12, 2020 · 2 comments

Comments

@jiapei100
Copy link

[ 17%] Building CXX object CMakeFiles/DLib.dir/src/DUtils/DebugFunctions.cpp.o
/usr/bin/c++  -DDLib_EXPORTS -I....../DLib/include/DUtils -I....../DLib/include/DUtilsCV -I....../DLib/include/DVision -isystem /usr/local/include/opencv4  -Wall -pedantic -O3 -DNDEBUG -fPIC   -o CMakeFiles/DLib.dir/src/DUtils/DebugFunctions.cpp.o -c ....../DLib/src/DUtils/DebugFunctions.cpp
....../DLib/src/DUtilsCV/GUI.cpp: In static member function ‘static int DUtilsCV::GUI::showImage(const cv::Mat&, bool, DUtilsCV::GUI::tWinHandler*, int)’:
....../DLib/src/DUtilsCV/GUI.cpp:42:27: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
     if(autosize) flags |= CV_WINDOW_AUTOSIZE;
                           ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:42:27: note: suggested alternative: ‘CV_MINOR_VERSION’
     if(autosize) flags |= CV_WINDOW_AUTOSIZE;
                           ^~~~~~~~~~~~~~~~~~
                           CV_MINOR_VERSION
....../DLib/src/DUtilsCV/GUI.cpp: In static member function ‘static int DUtilsCV::GUI::showImageInfo(const cv::Mat&, bool, DUtilsCV::GUI::tWinHandler*)’:
....../DLib/src/DUtilsCV/GUI.cpp:84:36: error: ‘CV_GRAY2RGB’ was not declared in this scope
     cv::cvtColor(image, image_rgb, CV_GRAY2RGB);
                                    ^~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:84:36: note: suggested alternative: ‘CV_RGB’
     cv::cvtColor(image, image_rgb, CV_GRAY2RGB);
                                    ^~~~~~~~~~~
                                    CV_RGB
....../DLib/src/DUtilsCV/GUI.cpp: In static member function ‘static bool DUtilsCV::GUI::windowExists(const tWinHandler&)’:
....../DLib/src/DUtilsCV/GUI.cpp:179:10: error: ‘cvGetWindowHandle’ was not declared in this scope
   return cvGetWindowHandle(hwnd.c_str()) != NULL;
          ^~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:179:10: note: suggested alternative: ‘tWinHandler’
   return cvGetWindowHandle(hwnd.c_str()) != NULL;
          ^~~~~~~~~~~~~~~~~
          tWinHandler
....../DLib/src/DUtilsCV/GUI.cpp: In member function ‘void DUtilsCV::GUI::MouseHandler::attachToClicks(const tWinHandler&)’:
....../DLib/src/DUtilsCV/GUI.cpp:240:23: error: ‘CV_EVENT_LBUTTONUP’ was not declared in this scope
   m_valid_events[0] = CV_EVENT_LBUTTONUP;
                       ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp: In member function ‘void DUtilsCV::GUI::MouseHandler::attachToMotions(const tWinHandler&)’:
....../DLib/src/DUtilsCV/GUI.cpp:250:23: error: ‘CV_EVENT_MOUSEMOVE’ was not declared in this scope
   m_valid_events[0] = CV_EVENT_MOUSEMOVE;
                       ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp: In static member function ‘static void DUtilsCV::Drawing::drawKeyPoints(cv::Mat&, const std::vector<cv::KeyPoint>&, bool, bool)’:
....../DLib/src/DUtilsCV/Drawing.cpp:26:3: error: ‘CvScalar’ was not declared in this scope
   CvScalar colors[4] = {
   ^~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp: In member function ‘void DUtilsCV::GUI::MouseHandler::listenToAll()’:
....../DLib/src/DUtilsCV/GUI.cpp:278:23: error: ‘CV_EVENT_LBUTTONDOWN’ was not declared in this scope
   m_valid_events[0] = CV_EVENT_LBUTTONDOWN;
                       ^~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:42:11: error: ‘CvScalar’ does not name a type
     const CvScalar *color;
           ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:44:7: error: ‘color’ was not declared in this scope
       color = &colors[3];
       ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:44:7: note: suggested alternative: ‘cvFloor’
       color = &colors[3];
       ^~~~~
       cvFloor
....../DLib/src/DUtilsCV/Drawing.cpp:44:16: error: ‘colors’ was not declared in this scope
       color = &colors[3];
                ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:44:16: note: suggested alternative: ‘clock’
       color = &colors[3];
                ^~~~~~
                clock
....../DLib/src/DUtilsCV/Drawing.cpp:46:7: error: ‘color’ was not declared in this scope
       color = &colors[it->octave-1];
       ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:46:7: note: suggested alternative: ‘cvFloor’
       color = &colors[it->octave-1];
       ^~~~~
       cvFloor
....../DLib/src/DUtilsCV/Drawing.cpp:46:16: error: ‘colors’ was not declared in this scope
       color = &colors[it->octave-1];
                ^~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:279:23: error: ‘CV_EVENT_LBUTTONUP’ was not declared in this scope
   m_valid_events[1] = CV_EVENT_LBUTTONUP;
                       ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:46:16: note: suggested alternative: ‘clock’
       color = &colors[it->octave-1];
                ^~~~~~
                clock
....../DLib/src/DUtilsCV/Drawing.cpp:51:23: error: ‘cvPoint’ was not declared in this scope
     cv::circle(image, cvPoint(c1, r1), (int)s, *color, 1);
                       ^~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:51:23: note: suggested alternative: ‘cvRound’
     cv::circle(image, cvPoint(c1, r1), (int)s, *color, 1);
                       ^~~~~~~
                       cvRound
....../DLib/src/DUtilsCV/Drawing.cpp:51:49: error: ‘color’ was not declared in this scope
     cv::circle(image, cvPoint(c1, r1), (int)s, *color, 1);
                                                 ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:51:49: note: suggested alternative: ‘cvFloor’
     cv::circle(image, cvPoint(c1, r1), (int)s, *color, 1);
                                                 ^~~~~
                                                 cvFloor
....../DLib/src/DUtilsCV/Drawing.cpp: In static member function ‘static void DUtilsCV::Drawing::drawCorrespondences(cv::Mat&, const cv::Mat&, const cv::Mat&, const std::vector<cv::KeyPoint>&, const std::vector<cv::KeyPoint>&, const std::vector<int>&, const std::vector<int>&)’:
....../DLib/src/DUtilsCV/Drawing.cpp:105:30: error: ‘CV_RGB2GRAY’ was not declared in this scope
     cv::cvtColor(img1, aux1, CV_RGB2GRAY);
                              ^~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:105:30: note: suggested alternative: ‘CV_RGB’
     cv::cvtColor(img1, aux1, CV_RGB2GRAY);
                              ^~~~~~~~~~~
                              CV_RGB
....../DLib/src/DUtilsCV/Drawing.cpp:110:30: error: ‘CV_RGB2GRAY’ was not declared in this scope
     cv::cvtColor(img2, aux2, CV_RGB2GRAY);
                              ^~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:280:23: error: ‘CV_EVENT_LBUTTONDBLCLK’ was not declared in this scope
   m_valid_events[2] = CV_EVENT_LBUTTONDBLCLK;
                       ^~~~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:110:30: note: suggested alternative: ‘CV_RGB’
     cv::cvtColor(img2, aux2, CV_RGB2GRAY);
                              ^~~~~~~~~~~
                              CV_RGB
....../DLib/src/DUtilsCV/Drawing.cpp:118:3: error: ‘IplImage’ was not declared in this scope
   IplImage ipl_im = IplImage(im);
   ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:118:3: note: suggested alternative: ‘image’
   IplImage ipl_im = IplImage(im);
   ^~~~~~~~
   image
....../DLib/src/DUtilsCV/Drawing.cpp:119:13: error: ‘ipl_ret’ was not declared in this scope
   IplImage* ipl_ret = &ipl_im;
             ^~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:119:24: error: ‘ipl_im’ was not declared in this scope
   IplImage* ipl_ret = &ipl_im;
                        ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:121:3: error: ‘CvRect’ was not declared in this scope
   CvRect roi;
   ^~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:281:23: error: ‘CV_EVENT_RBUTTONDOWN’ was not declared in this scope
   m_valid_events[3] = CV_EVENT_RBUTTONDOWN;
                       ^~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:121:3: note: suggested alternative: ‘select’
   CvRect roi;
   ^~~~~~
   select
....../DLib/src/DUtilsCV/Drawing.cpp:122:3: error: ‘roi’ was not declared in this scope
   roi.x = 0;
   ^~~
....../DLib/src/DUtilsCV/Drawing.cpp:122:3: note: suggested alternative: ‘atoi’
   roi.x = 0;
   ^~~
   atoi
....../DLib/src/DUtilsCV/Drawing.cpp:127:3: error: ‘cvSetImageROI’ was not declared in this scope
   cvSetImageROI(ipl_ret, roi);
   ^~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:128:12: error: expected ‘;’ before ‘ipl_aux1’
   IplImage ipl_aux1 = IplImage(aux1);
            ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:129:11: error: ‘ipl_aux1’ was not declared in this scope
   cvCopy(&ipl_aux1, ipl_ret);
           ^~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:282:23: error: ‘CV_EVENT_RBUTTONUP’ was not declared in this scope
   m_valid_events[4] = CV_EVENT_RBUTTONUP;
                       ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:129:11: note: suggested alternative: ‘aux1’
   cvCopy(&ipl_aux1, ipl_ret);
           ^~~~~~~~
           aux1
....../DLib/src/DUtilsCV/Drawing.cpp:129:3: error: ‘cvCopy’ was not declared in this scope
   cvCopy(&ipl_aux1, ipl_ret);
   ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:129:3: note: suggested alternative: ‘cvCeil’
   cvCopy(&ipl_aux1, ipl_ret);
   ^~~~~~
   cvCeil
....../DLib/src/DUtilsCV/Drawing.cpp:137:12: error: expected ‘;’ before ‘ipl_aux2’
   IplImage ipl_aux2 = IplImage(aux2);
            ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:138:11: error: ‘ipl_aux2’ was not declared in this scope
   cvCopy(&ipl_aux2, ipl_ret);
           ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:138:11: note: suggested alternative: ‘aux2’
   cvCopy(&ipl_aux2, ipl_ret);
           ^~~~~~~~
           aux2
....../DLib/src/DUtilsCV/Drawing.cpp:140:2: error: ‘cvResetImageROI’ was not declared in this scope
  cvResetImageROI(ipl_ret);
  ^~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:283:23: error: ‘CV_EVENT_RBUTTONDBLCLK’ was not declared in this scope
   m_valid_events[5] = CV_EVENT_RBUTTONDBLCLK;
                       ^~~~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:143:26: error: ‘CV_GRAY2RGB’ was not declared in this scope
  cv::cvtColor(im, image, CV_GRAY2RGB);
                          ^~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:143:26: note: suggested alternative: ‘CV_RGB’
  cv::cvtColor(im, image, CV_GRAY2RGB);
                          ^~~~~~~~~~~
                          CV_RGB
....../DLib/src/DUtilsCV/Drawing.cpp:154:5: error: ‘CvScalar’ was not declared in this scope
     CvScalar color = cvScalar(
     ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:159:21: error: ‘cvPoint’ was not declared in this scope
     cv::line(image, cvPoint(mx, my), cvPoint(px, py), color, 1);
                     ^~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:284:23: error: ‘CV_EVENT_MBUTTONDOWN’ was not declared in this scope
   m_valid_events[6] = CV_EVENT_MBUTTONDOWN;
                       ^~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:159:21: note: suggested alternative: ‘cvRound’
     cv::line(image, cvPoint(mx, my), cvPoint(px, py), color, 1);
                     ^~~~~~~
                     cvRound
....../DLib/src/DUtilsCV/Drawing.cpp:159:55: error: ‘color’ was not declared in this scope
     cv::line(image, cvPoint(mx, my), cvPoint(px, py), color, 1);
                                                       ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:159:55: note: suggested alternative: ‘cols’
     cv::line(image, cvPoint(mx, my), cvPoint(px, py), color, 1);
                                                       ^~~~~
                                                       cols
....../DLib/src/DUtilsCV/Drawing.cpp: In static member function ‘static void DUtilsCV::Drawing::drawReferenceSystem(cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&, float)’:
....../DLib/src/DUtilsCV/Drawing.cpp:209:3: error: ‘CvScalar’ was not declared in this scope
   CvScalar bluez, greeny, redx;
   ^~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:285:23: error: ‘CV_EVENT_MBUTTONUP’ was not declared in this scope
   m_valid_events[7] = CV_EVENT_MBUTTONUP;
                       ^~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:213:5: error: ‘bluez’ was not declared in this scope
     bluez = cvScalar(255,0,0);
     ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:213:13: error: ‘cvScalar’ was not declared in this scope
     bluez = cvScalar(255,0,0);
             ^~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:214:5: error: ‘greeny’ was not declared in this scope
     greeny = cvScalar(0,255,0);
     ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:214:5: note: suggested alternative: ‘getenv’
     greeny = cvScalar(0,255,0);
     ^~~~~~
     getenv
....../DLib/src/DUtilsCV/Drawing.cpp:215:5: error: ‘redx’ was not declared in this scope
     redx = cvScalar(0,0,255);
     ^~~~
....../DLib/src/DUtilsCV/Drawing.cpp:215:5: note: suggested alternative: ‘rindex’
     redx = cvScalar(0,0,255);
     ^~~~
     rindex
....../DLib/src/DUtilsCV/Drawing.cpp:219:5: error: ‘bluez’ was not declared in this scope
     bluez = cvScalar(18,18,18);
     ^~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:219:13: error: ‘cvScalar’ was not declared in this scope
     bluez = cvScalar(18,18,18);
             ^~~~~~~~
....../DLib/src/DUtilsCV/GUI.cpp:286:23: error: ‘CV_EVENT_MBUTTONDBLCLK’ was not declared in this scope
   m_valid_events[8] = CV_EVENT_MBUTTONDBLCLK;
                       ^~~~~~~~~~~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:220:5: error: ‘greeny’ was not declared in this scope
     greeny = cvScalar(182,182,182);
     ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:220:5: note: suggested alternative: ‘getenv’
     greeny = cvScalar(182,182,182);
     ^~~~~~
     getenv
....../DLib/src/DUtilsCV/Drawing.cpp:221:5: error: ‘redx’ was not declared in this scope
     redx = cvScalar(120,120,120);
     ^~~~
....../DLib/src/DUtilsCV/Drawing.cpp:221:5: note: suggested alternative: ‘rindex’
     redx = cvScalar(120,120,120);
     ^~~~
     rindex
....../DLib/src/DUtilsCV/Drawing.cpp:224:45: error: ‘redx’ was not declared in this scope
   cv::line(image, points2d[0], points2d[1], redx, 2);
                                             ^~~~
....../DLib/src/DVision/FSolver.cpp: In member function ‘cv::Mat DVision::FSolver::findFundamentalMat(const cv::Mat&, const cv::Mat&, double, int, std::vector<unsigned char>*, bool, double, int) const’:
....../DLib/src/DVision/FSolver.cpp:160:32: error: ‘CV_REDUCE_SUM’ was not declared in this scope
       cv::reduce(prod, dot, 0, CV_REDUCE_SUM); // dot is Nx1
                                ^~~~~~~~~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:224:45: note: suggested alternative: ‘rindex’
   cv::line(image, points2d[0], points2d[1], redx, 2);
                                             ^~~~
                                             rindex
....../DLib/src/DUtilsCV/Drawing.cpp:225:45: error: ‘greeny’ was not declared in this scope
   cv::line(image, points2d[0], points2d[2], greeny, 2);
                                             ^~~~~~
....../DLib/src/DUtilsCV/Drawing.cpp:225:45: note: suggested alternative: ‘getenv’
   cv::line(image, points2d[0], points2d[2], greeny, 2);
                                             ^~~~~~
                                             getenv
....../DLib/src/DUtilsCV/Drawing.cpp:226:45: error: ‘bluez’ was not declared in this scope
   cv::line(image, points2d[0], points2d[3], bluez, 2);
                                             ^~~~~
....../DLib/src/DUtilsCV/GUI.cpp:287:23: error: ‘CV_EVENT_MOUSEMOVE’ was not declared in this scope
   m_valid_events[9] = CV_EVENT_MOUSEMOVE;
                       ^~~~~~~~~~~~~~~~~~
CMakeFiles/DLib.dir/build.make:247: recipe for target 'CMakeFiles/DLib.dir/src/DUtilsCV/GUI.cpp.o' failed
make[2]: *** [CMakeFiles/DLib.dir/src/DUtilsCV/GUI.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/DLib.dir/build.make:195: recipe for target 'CMakeFiles/DLib.dir/src/DUtilsCV/Drawing.cpp.o' failed
make[2]: *** [CMakeFiles/DLib.dir/src/DUtilsCV/Drawing.cpp.o] Error 1
CMakeFiles/DLib.dir/build.make:78: recipe for target 'CMakeFiles/DLib.dir/src/DVision/FSolver.cpp.o' failed
make[2]: *** [CMakeFiles/DLib.dir/src/DVision/FSolver.cpp.o] Error 1
make[2]: Leaving directory '....../DLib/build'
CMakeFiles/Makefile2:78: recipe for target 'CMakeFiles/DLib.dir/all' failed
make[1]: *** [CMakeFiles/DLib.dir/all] Error 2
make[1]: Leaving directory '....../DLib/build'
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
@tkircher
Copy link

tkircher commented Apr 9, 2020

The issue is that this library isn't compatible with any version of OpenCV that anyone uses. There are a few fixes you can make though:

Adding namespace cv to files that need it (Drawing.cpp, for one)

Removing most CV_ or cv prefixes from function calls. For CV_GRAY2RGB, this is now COLOR_GRAY2RGB.

IplImage has not been supported for ages. It has to be replaced with Mat. Also the ROI functions are deprecated - you can just use img1 = img2(roi) where roi is a cv::Rect. Also, use dest.copyTo(src) instead of CvCopy(dest, src) or whatever it was.

You have to #include <opencv2/highgui/highgui_c.h> for the obsolete C bindings in DUtilsCV/GUI.cpp

@tkircher
Copy link

I forked the repository to share the necessary changes. I included some from one of the pending push requests as well. See: https://github.com/tkircher/DLib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants