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

Update to OpenCV4 and fix some build errors #790

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3.0 QUIET)
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
Expand Down
2 changes: 2 additions & 0 deletions Examples/Monocular/mono_euroc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include<algorithm>
#include<fstream>
#include<chrono>
#include<unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include<System.h>

Expand Down
2 changes: 2 additions & 0 deletions Examples/Monocular/mono_kitti.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#include<fstream>
#include<chrono>
#include<iomanip>
#include<unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include"System.h"

Expand Down
2 changes: 2 additions & 0 deletions Examples/Monocular/mono_tum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include<algorithm>
#include<fstream>
#include<chrono>
#include<unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include<System.h>

Expand Down
2 changes: 2 additions & 0 deletions Examples/RGB-D/rgbd_tum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include<algorithm>
#include<fstream>
#include<chrono>
#include <unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include<System.h>

Expand Down
2 changes: 1 addition & 1 deletion Examples/ROS/ORB_SLAM2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../../cmake_modules)

find_package(OpenCV 3.0 QUIET)
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
Expand Down
2 changes: 2 additions & 0 deletions Examples/Stereo/stereo_euroc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#include<fstream>
#include<iomanip>
#include<chrono>
#include<unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include<System.h>

Expand Down
2 changes: 2 additions & 0 deletions Examples/Stereo/stereo_kitti.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#include<fstream>
#include<iomanip>
#include<chrono>
#include<unistd.h>

#include<opencv2/core/core.hpp>
#include<opencv2/imgcodecs/legacy/constants_c.h>

#include<System.h>

Expand Down
2 changes: 1 addition & 1 deletion Thirdparty/DBoW2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(SRCS_DUTILS
DUtils/Random.cpp
DUtils/Timestamp.cpp)

find_package(OpenCV 3.0 QUIET)
find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
Expand Down
16 changes: 16 additions & 0 deletions gen_imp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dir="`pwd`"

echo '['

pushd /usr/include/eigen3/Eigen &> /dev/null
for i in *; do echo " { include: ['@<Eigen/src/$i/.*>', 'private', '<Eigen/$i>', 'public'] },"; done | sed s/\'/\"/g
popd &>/dev/null

echo

pushd /usr/include/opencv4/opencv2 &>/dev/null
for i in *.hpp; do echo " { include: ['@<opencv2/${i%.hpp}/.*.hpp>', 'private', '<opencv2/$i>', 'public'] },"; done | sed s/\'/\"/g
popd &> /dev/null

echo ' { include: ["<this is a dummy that does not exist>", "private", "<blah>", "public"] }'
echo ']'
6 changes: 5 additions & 1 deletion include/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@

#include<vector>

#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <cstddef>

#include "MapPoint.h"
#include "Thirdparty/DBoW2/DBoW2/BowVector.h"
#include "Thirdparty/DBoW2/DBoW2/FeatureVector.h"
#include "ORBVocabulary.h"
#include "KeyFrame.h"
#include "ORBextractor.h"

#include <opencv2/opencv.hpp>
namespace ORB_SLAM2 { class ORBextractor; }

namespace ORB_SLAM2
{
Expand Down
9 changes: 7 additions & 2 deletions include/KeyFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
#ifndef KEYFRAME_H
#define KEYFRAME_H

#include <stddef.h>
#include <opencv2/core.hpp>
#include <mutex>
#include <map>
#include <set>
#include <vector>

#include "MapPoint.h"
#include "Thirdparty/DBoW2/DBoW2/BowVector.h"
#include "Thirdparty/DBoW2/DBoW2/FeatureVector.h"
Expand All @@ -29,8 +36,6 @@
#include "Frame.h"
#include "KeyFrameDatabase.h"

#include <mutex>


namespace ORB_SLAM2
{
Expand Down
8 changes: 6 additions & 2 deletions include/LocalMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@
#ifndef LOCALMAPPING_H
#define LOCALMAPPING_H

#include <opencv2/core.hpp>
#include <mutex>
#include <list>

#include "KeyFrame.h"
#include "Map.h"
#include "LoopClosing.h"
#include "Tracking.h"
#include "KeyFrameDatabase.h"

#include <mutex>


namespace ORB_SLAM2
{

class Tracking;
class LoopClosing;
class Map;
class KeyFrame;
class MapPoint;

class LocalMapping
{
Expand Down
21 changes: 16 additions & 5 deletions include/LoopClosing.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,35 @@
#ifndef LOOPCLOSING_H
#define LOOPCLOSING_H

#include <opencv2/core.hpp>
#include <thread>
#include <mutex>
#include <Eigen/Core>
#include <functional>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <vector>

#include "KeyFrame.h"
#include "LocalMapping.h"
#include "Map.h"
#include "ORBVocabulary.h"
#include "Tracking.h"

#include "KeyFrameDatabase.h"

#include <thread>
#include <mutex>
#include "Thirdparty/g2o/g2o/types/types_seven_dof_expmap.h"
#include "Thirdparty/g2o/g2o/types/sim3.h"

namespace ORB_SLAM2
{

class Tracking;
class LocalMapping;
class KeyFrameDatabase;
class KeyFrame;
class Map;
class MapPoint;


class LoopClosing
Expand All @@ -47,7 +58,7 @@ class LoopClosing

typedef pair<set<KeyFrame*>,int> ConsistentGroup;
typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;

public:

Expand Down
7 changes: 4 additions & 3 deletions include/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
#ifndef MAP_H
#define MAP_H

#include "MapPoint.h"
#include "KeyFrame.h"
#include <set>

#include <mutex>
#include <vector>

#include "MapPoint.h"
#include "KeyFrame.h"



Expand Down
2 changes: 1 addition & 1 deletion include/ORBextractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include <vector>
#include <list>
#include <opencv/cv.h>
#include <opencv2/core.hpp>


namespace ORB_SLAM2
Expand Down
12 changes: 11 additions & 1 deletion include/Optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@
#ifndef OPTIMIZER_H
#define OPTIMIZER_H

#include <stddef.h>
#include <map>
#include <set>
#include <vector>

#include "Map.h"
#include "MapPoint.h"
#include "KeyFrame.h"
#include "LoopClosing.h"
#include "Frame.h"

#include "Thirdparty/g2o/g2o/types/types_seven_dof_expmap.h"

namespace g2o { struct Sim3; }

namespace ORB_SLAM2
{

class LoopClosing;
class Frame;
class KeyFrame;
class Map;
class MapPoint;

class Optimizer
{
Expand Down
7 changes: 7 additions & 0 deletions include/PnPsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@
#define PNPSOLVER_H

#include <opencv2/core/core.hpp>
#include <opencv2/core/core_c.h>
#include <stddef.h>
#include <opencv2/core.hpp>
#include <vector>

#include "MapPoint.h"
#include "Frame.h"

namespace ORB_SLAM2
{
class Frame;
class MapPoint;

class PnPsolver {
public:
Expand Down
4 changes: 4 additions & 0 deletions include/Sim3Solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define SIM3SOLVER_H

#include <opencv2/opencv.hpp>
#include <stddef.h>
#include <opencv2/core.hpp>
#include <vector>

#include "KeyFrame.h"
Expand All @@ -31,6 +33,8 @@

namespace ORB_SLAM2
{
class KeyFrame;
class MapPoint;

class Sim3Solver
{
Expand Down
13 changes: 9 additions & 4 deletions include/Tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define TRACKING_H

#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc_c.h>
#include<opencv2/features2d/features2d.hpp>

#include"Viewer.h"
Expand Down Expand Up @@ -105,10 +106,14 @@ class Tracking

// Lists used to recover the full camera trajectory at the end of the execution.
// Basically we store the reference keyframe for each frame and its relative transformation
list<cv::Mat> mlRelativeFramePoses;
list<KeyFrame*> mlpReferences;
list<double> mlFrameTimes;
list<bool> mlbLost;
struct TrackedFrame
{
cv::Mat relative_frame_pose;
KeyFrame* reference_keyframe;
double time;
bool lost;
};
list<TrackedFrame> tracked_frames;

// True if local mapping is deactivated and we are performing only localization
bool mbOnlyTracking;
Expand Down
5 changes: 3 additions & 2 deletions include/Viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
#ifndef VIEWER_H
#define VIEWER_H

#include <mutex>
#include <string>

#include "FrameDrawer.h"
#include "MapDrawer.h"
#include "Tracking.h"
#include "System.h"

#include <mutex>

namespace ORB_SLAM2
{

Expand Down
Loading