Skip to content

Commit ba3ba9a

Browse files
committed
1.address the 'SURF' problem in OpenCV3.x;2.address X11 conflicts of 'Status'
1 parent c3cce7b commit ba3ba9a

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ This is a computer vision library developed for CoSLAM. Please click [here](http
4949
#### 2. Nvidia Cg toolkit
5050
Please click [here](https://developer.nvidia.com/cg-toolkit-download) to download the nvidia Cg toolkit. Click the .deb file to install the package.
5151

52-
#### 3. GLEW
52+
#### 3. GLEW, xmu
5353
Can be installed from the repository of Ubuntu or Linux Mint by typing
5454

5555
sudo apt-get install libglew-dev
56+
sudo apt-get install libxmu-dev
5657

5758
#### 4. OpenGL, GLU, and GLUT
5859
OpenGL is supported by default after the nvidia graphics card driver being installed. To install GLU,GLUT, run

cmake/Modules/FindGLEW.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ELSE (WIN32)
3838
DOC "GLEW library detected!")
3939
ENDIF (WIN32)
4040

41-
message(status, "libraries:" ${GLEW_LIBRARY})
41+
#message(status, "libraries:" ${GLEW_LIBRARY})
4242

4343
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
4444
SET( GLEW_FOUND TRUE CACHE STRING "GLEW library has been detected!")

src/app/SL_CoSLAM.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void CoSLAM::grabReadFrame() {
122122

123123
pthread_t threads[SLAM_MAX_NUM];
124124
for (int i = 1; i < numCams; i++) {
125-
pthread_create(&threads[i], 0, _parallelReadNextFrame, (void*) i);
125+
pthread_create(&threads[i], 0, _parallelReadNextFrame, reinterpret_cast<void*>(i));
126126
}
127127
slam[0].grabReadFrame();
128128
for (int i = 1; i < numCams; i++) {

src/app/SL_InitMap.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
#include "slam/SL_FeatureMatching.h"
2525
#include "SL_CoSLAMBA.h"
2626
#include "SL_GlobParam.h"
27-
27+
#if CV_MAJOR_VERSION <= 2
2828
#if CV_MINOR_VERSION > 3
2929
#include <opencv2/nonfree/features2d.hpp>
3030
#endif
31+
#elif(CV_MAJOR_VERSION == 3)
32+
#include <opencv2/xfeatures2d.hpp>
33+
#endif
3134

3235
//#define DEBUG_MODE
3336
InitMap::InitMap() :
@@ -41,16 +44,23 @@ void InitMap::detectSurfFeats(int iCam) {
4144
const ImgG* img = m_pImgGray[iCam];
4245
KpVec& keyPts = m_cvSurfPts[iCam];
4346
std::vector<float> desc;
47+
48+
cv::Mat cvImg(img->rows, img->cols, CV_8UC1, img->data);
49+
#if CV_MAJOR_VERSION <= 2
4450
#if CV_MINOR_VERSION > 3
4551
cv::SurfFeatureDetector surf(400, 4, 2, false);
46-
cv::Mat cvImg(img->rows, img->cols, CV_8UC1, img->data);
4752
surf(cvImg, cv::Mat(), keyPts, desc);
4853
int dimDesc = surf.descriptorSize();
4954
#else
5055
cv::SURF surf(400, 4, 2, false);
51-
cv::Mat cvImg(img->rows, img->cols, CV_8UC1, img->data);
5256
surf(cvImg, cv::Mat(), keyPts, desc);
5357
int dimDesc = surf.descriptorSize();
58+
#endif
59+
#elif CV_MAJOR_VERSION == 3
60+
using namespace cv::xfeatures2d;
61+
cv::Ptr<SURF> surf = SURF::create(400, 4, 2, false);
62+
surf->detectAndCompute(cvImg,cv::Mat(), keyPts, desc);
63+
int dimDesc = surf->descriptorSize();
5464
#endif
5565
m_surfDesc[iCam].resize(keyPts.size(), dimDesc);
5666

src/gui/GLImagePane.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
#ifndef GLIMAGEPANE_H_
99
#define GLIMAGEPANE_H_
10+
#include "app/SL_CoSLAM.h"
1011

1112
#include <GL/glew.h> // should be included before "wx/glcanvas.h"
1213
#include "wx/wx.h"
1314
#include "wx/glcanvas.h"
1415

15-
#include "app/SL_CoSLAM.h"
1616
class GLImagePane: public wxGLCanvas {
1717
wxGLContext* m_context;
1818
unsigned char* imgData;

src/gui/GLScenePane.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#ifndef GLSCENEPANE_H_
99
#define GLSCENEPANE_H_
10+
#include "app/SL_CoSLAM.h"
1011
#include "GL/glew.h"
1112
#include "GLTrackballPane.h"
12-
#include "app/SL_CoSLAM.h"
1313

1414
using namespace std;
1515
class GLScenePane: public GLTrackballPane {

src/gui/MyApp.h

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#ifndef MYAPP_H_
99
#define MYAPP_H_
10+
#undef Status
11+
#include <opencv2/opencv.hpp>
1012

1113
#include "app/SL_CoSLAM.h"
1214
#include "app/SL_GlobParam.h"

0 commit comments

Comments
 (0)