Skip to content

Commit

Permalink
Merge pull request #6 from dorian3d/update/version
Browse files Browse the repository at this point in the history
Compatibility with OpenCV 3.1
  • Loading branch information
dorian3d committed May 1, 2016
2 parents 330bdc1 + 3b66445 commit 3a4a207
Show file tree
Hide file tree
Showing 44 changed files with 189 additions and 357 deletions.
33 changes: 30 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ option(BUILD_DUtils "Build DUtils (basic c++ functions)." ON)
option(BUILD_DUtilsCV "Build DUtilsCV (OpenCV functions, requires DUtils)." ON)
option(BUILD_DVision "Build DVision (computer vision functions, requires DUtilsCV)." ON)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
endif()

if(BUILD_DUtils)
set(HDRS include/DUtils/
include/DUtils/BinaryFile.h include/DUtils/DUtils.h include/DUtils/FileModes.h include/DUtils/Math.hpp
Expand Down Expand Up @@ -34,26 +50,37 @@ endif(BUILD_DUtilsCV)

if(BUILD_DVision)
set(HDRS
include/DVision/BRIEF.h include/DVision/DVision.h include/DVision/HSolver.h include/DVision/Matches.h
include/DVision/DVision.h include/DVision/HSolver.h include/DVision/Matches.h
include/DVision/PMVSCamera.h include/DVision/PixelPointFile.h
include/DVision/BundleCamera.h include/DVision/FSolver.h include/DVision/ImageFunctions.h include/DVision/PLYFile.h
include/DVision/PatchFile.h include/DVision/SurfSet.h
${HDRS})
set(SRCS
src/DVision/BRIEF.cpp src/DVision/FSolver.cpp src/DVision/ImageFunctions.cpp src/DVision/PLYFile.cpp
src/DVision/FSolver.cpp src/DVision/ImageFunctions.cpp src/DVision/PLYFile.cpp
src/DVision/PatchFile.cpp src/DVision/SurfSet.cpp
src/DVision/BundleCamera.cpp src/DVision/HSolver.cpp src/DVision/Matches.cpp src/DVision/PMVSCamera.cpp
src/DVision/PixelPointFile.cpp
${SRCS})

find_package(Boost QUIET) # For dynamic_bitset
if (Boost_FOUND)
set(HDRS include/DVision/BRIEF.h ${HDRS})
set(SRCS src/DVision/BRIEF.cpp ${SRCS})
endif(Boost_FOUND)
endif(BUILD_DVision)


if(BUILD_DUtilsCV OR BUILD_DVision)
find_package(OpenCV REQUIRED)
endif(BUILD_DUtilsCV OR BUILD_DVision)

set(LIB_SHARED "SHARED")
if(WIN32)
set(LIB_SHARED "STATIC")
endif(WIN32)

include_directories(include/DUtils include/DUtilsCV include/DVision ${OpenCV_INCLUDE_DIRS})
add_library(${PROJECT_NAME} SHARED ${SRCS})
add_library(${PROJECT_NAME} ${LIB_SHARED} ${SRCS})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})

configure_file(src/DLib.cmake.in
Expand Down
11 changes: 5 additions & 6 deletions include/DUtils/BinaryFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "DException.h"
#include "FileModes.h"
#include <fstream>
using namespace std;

namespace DUtils {

Expand Down Expand Up @@ -49,7 +48,7 @@ class BinaryFile
* @param mode: READ or WRITE
* @throws DException if cannot open the file
*/
BinaryFile(const string &filename, const FILE_MODES mode);
BinaryFile(const std::string &filename, const FILE_MODES mode);

/**
* Opens a file for reading. It closes any other opened file
Expand All @@ -63,7 +62,7 @@ class BinaryFile
* @param filename
* @throws DException if cannot open the file
*/
inline void OpenForReading(const string &filename)
inline void OpenForReading(const std::string &filename)
{
OpenForReading(filename.c_str());
}
Expand All @@ -80,7 +79,7 @@ class BinaryFile
* @param filename
* @throws DException if cannot create the file
*/
inline void OpenForWriting(const string &filename)
inline void OpenForWriting(const std::string &filename)
{
OpenForWriting(filename.c_str());
}
Expand All @@ -97,7 +96,7 @@ class BinaryFile
* @param filename
* @throws DException if cannot open the file
*/
inline void OpenForAppending(const string &filename)
inline void OpenForAppending(const std::string &filename)
{
OpenForAppending(filename.c_str());
}
Expand Down Expand Up @@ -241,7 +240,7 @@ class BinaryFile
/// Opening mode
FILE_MODES m_mode; // opening mode
/// File stream
fstream m_f; // fstream
std::fstream m_f; // fstream
/// Auxiliar buffer
char m_aux[8]; // auxiliar buffer

Expand Down
8 changes: 4 additions & 4 deletions include/DUtils/ConfigFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ConfigFile
* @param used the names of the tokens that cannot be replaced because of
* circular dependencies
*/
void resolveVar(std::string &value, const std::set<string> &used);
void resolveVar(std::string &value, const std::set<std::string> &used);

protected:

Expand All @@ -221,7 +221,7 @@ template<class T>
T ConfigFile::getAnonymous(int n) const
{
const char U = '?';
stringstream ss;
std::stringstream ss;
ss << U << n;
return get<T>(ss.str().c_str());
}
Expand Down Expand Up @@ -255,11 +255,11 @@ void ConfigFile::put(const std::string &name, const T &data)
template<class T>
void ConfigFile::put(const char *name, const T &data)
{
pair<std::map<std::string, std::string>::iterator, bool> status;
std::pair<std::map<std::string, std::string>::iterator, bool> status;

std::string value = StringFunctions::toString<T>(data);

status = m_data.insert(make_pair(name, value));
status = m_data.insert(std::make_pair(name, value));

if(!status.second)
{
Expand Down
7 changes: 3 additions & 4 deletions include/DUtils/DException.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@

#include <stdexcept>
#include <string>
using namespace std;

namespace DUtils {

/// General exception
class DException :
public exception
public std::exception
{
public:
/**
Expand All @@ -39,7 +38,7 @@ class DException :
* Creates an exception with a custom error message
* @param msg: message
*/
DException(const string &msg) throw(): m_message(msg){}
DException(const std::string &msg) throw(): m_message(msg){}

/**
* Destructor
Expand All @@ -56,7 +55,7 @@ class DException :

protected:
/// Error message
string m_message;
std::string m_message;
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/DUtils/DUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Written by Dorian Galvez-Lopez,
* University of Zaragoza
*
* Check my website to obtain updates: http://webdiis.unizar.es/~dorian
* Check my website to obtain updates: http://doriangalvez.com
*
* \section license License
* This program is free software: you can redistribute it and/or modify
Expand Down
23 changes: 11 additions & 12 deletions include/DUtils/LineFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "FileModes.h"
#include <vector>
#include <fstream>
using namespace std;

namespace DUtils {

Expand Down Expand Up @@ -48,7 +47,7 @@ class LineFile
* @param mode: READ or WRITE
* @throws DException if cannot open the file
*/
LineFile(const string &filename, const FILE_MODES mode);
LineFile(const std::string &filename, const FILE_MODES mode);

/**
* Opens a file for reading. It closes any other opened file
Expand All @@ -62,7 +61,7 @@ class LineFile
* @param filename
* @throws DException if cannot create the file
*/
inline void OpenForReading(const string &filename)
inline void OpenForReading(const std::string &filename)
{
OpenForReading(filename.c_str());
}
Expand All @@ -79,7 +78,7 @@ class LineFile
* @param filename
* @throws DException if cannot create the file
*/
inline void OpenForWriting(const string &filename)
inline void OpenForWriting(const std::string &filename)
{
OpenForWriting(filename.c_str());
}
Expand All @@ -96,7 +95,7 @@ class LineFile
* @param filename
* @throws DException if cannot open the file
*/
inline void OpenForAppending(const string &filename)
inline void OpenForAppending(const std::string &filename)
{
OpenForAppending(filename.c_str());
}
Expand Down Expand Up @@ -125,7 +124,7 @@ class LineFile
* Writes a line
* @throws DException if wrong access mode
*/
inline LineFile& operator<< (const string &s)
inline LineFile& operator<< (const std::string &s)
{
return this->operator <<(s.c_str());
}
Expand All @@ -135,28 +134,28 @@ class LineFile
* @param s: string to write on
* @throws DException if wrong access mode
*/
LineFile& operator>> (string &s);
LineFile& operator>> (std::string &s);

/**
* Reads all the remaining lines in the file
* @param v vector to store the lines in
* @throws DException if wrong access mode
*/
LineFile& operator>> (vector<string> &v);
LineFile& operator>> (std::vector<std::string> &v);

/**
* Writes several lines at a time
* @param v: vector of line strings
* @throws DException if wrong access mode
*/
void Dump(const vector<string> &v);
void Dump(const std::vector<std::string> &v);

/**
* Writes several lines at a time
* @param v: vector of line strings
* @throws DException if wrong access mode
*/
inline LineFile& operator<< (const vector<string> &v)
inline LineFile& operator<< (const std::vector<std::string> &v)
{
Dump(v);
return *this;
Expand Down Expand Up @@ -186,9 +185,9 @@ class LineFile
/// Opening mode
FILE_MODES m_mode; // opening mode
/// File stream
fstream m_f; // fstream
std::fstream m_f; // fstream
/// Next line to read
string m_next_line; // next line to read
std::string m_next_line; // next line to read
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/DUtils/Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Profiler
*/
void showStatistics(const std::string &name = "",
const std::string &suffix = "s", double scale = 1.,
ostream &out = std::cout) const;
std::ostream &out = std::cout) const;

protected:

Expand Down
2 changes: 1 addition & 1 deletion include/DUtils/STL.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void STL::print(const std::vector<T> &v, const std::string &name,
f << *vit << " ";
}
f << "]";
f << endl;
f << std::endl;
}

// ---------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions include/DUtils/Timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define __D_TIMESTAMP__

#include <iostream>
using namespace std;

namespace DUtils {

Expand Down Expand Up @@ -78,7 +77,7 @@ class Timestamp
* Sets the timestamp from a string with the time in seconds
* @param stime: string such as "1235603336.036609"
*/
void setTime(const string &stime);
void setTime(const std::string &stime);

/**
* Sets the timestamp from a number of seconds from the epoch
Expand All @@ -94,7 +93,7 @@ class Timestamp
/**
* Returns this timestamp as the number of seconds in fixed length string format
*/
string getStringTime() const;
std::string getStringTime() const;

/**
* Returns the difference in seconds between this timestamp (greater) and t (smaller)
Expand Down Expand Up @@ -181,14 +180,14 @@ class Timestamp
* @note This has not been tested under Windows
* @note The timestamp is truncated to seconds
*/
string Format(bool machine_friendly = false) const;
std::string Format(bool machine_friendly = false) const;

/**
* Returns a string version of the elapsed time in seconds, with the format
* xd hh:mm:ss, hh:mm:ss, mm:ss or s.us
* @param s: elapsed seconds (given by getFloatTime) to format
*/
static string Format(double s);
static std::string Format(double s);


protected:
Expand Down
27 changes: 0 additions & 27 deletions include/DUtilsCV/CvVersion.h

This file was deleted.

5 changes: 1 addition & 4 deletions include/DUtilsCV/DUtilsCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Written by Dorian Galvez-Lopez,
* University of Zaragoza
*
* Check my website to obtain updates: http://webdiis.unizar.es/~dorian
* Check my website to obtain updates: http://doriangalvez.com
*
* \section requirements Requirements
* This library requires the DUtils library and the OpenCV library.
Expand Down Expand Up @@ -56,8 +56,5 @@ namespace DUtilsCV
#include "Transformations.h"
#include "Geometry.h"

// CV version
#include "CvVersion.h"

#endif

Loading

0 comments on commit 3a4a207

Please sign in to comment.