Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julian Mueller
committed
Nov 19, 2018
0 parents
commit 86f5ab6
Showing
21 changed files
with
2,329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin | ||
build | ||
lib | ||
*.*user | ||
*.*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
project(driveu_dataset) | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) | ||
|
||
find_package(OpenCV 2.4) | ||
IF(OpenCV_FOUND) | ||
message("ocv found") | ||
add_definitions("-DOpenCV_FOUND") | ||
ENDIF() | ||
SET(CMAKE_CXX_FLAGS "-std=c++0x") | ||
add_definitions ("-Wall") | ||
|
||
INCLUDE_DIRECTORIES(include) | ||
|
||
# lib | ||
SET(SOURCES src/driveu_dataset.cpp src/driveu_test.cpp src/compand.cpp) | ||
SET(HEADERS include/driveu_dataset.h include/compand.h) | ||
|
||
ADD_EXECUTABLE(driveu_test ${HEADERS} ${SOURCES}) | ||
add_library(driveu_dataset SHARED ${HEADERS} ${SOURCES}) | ||
target_link_libraries(driveu_dataset ${OpenCV_LIBS}) | ||
target_link_libraries(driveu_test ${OpenCV_LIBS}) | ||
|
||
install (TARGETS driveu_dataset ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) | ||
install (FILES ${HEADERS} DESTINATION "include/driveu_dataset") | ||
INSTALL(TARGETS driveu_test RUNTIME DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef COMPAND_H_ | ||
#define COMPAND_H_ | ||
|
||
// 2015-07-04 A.Fregin | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <map> | ||
#include <iostream> | ||
#include <fstream> | ||
#include <cmath> | ||
|
||
|
||
class Compand { | ||
public: | ||
Compand(const std::map<int,std::vector<int> > &kneepoints, bool verbose=false); | ||
virtual ~Compand(); | ||
|
||
void processPixel(const ushort &src, ushort &dst); | ||
bool saveLut(const std::string &file); | ||
bool loadLut(const std::string &file); | ||
|
||
private: | ||
std::vector<int> compandLUT; | ||
|
||
}; | ||
|
||
|
||
class Decompand { | ||
public: | ||
Decompand(); | ||
Decompand(const std::map<int,std::vector<int> > &kneepoints); | ||
Decompand(const std::string &file); | ||
|
||
virtual ~Decompand(); | ||
|
||
void processPixel(const ushort &src, ushort &dst); | ||
void processPixel(const ushort &src, unsigned char &dst); | ||
bool saveLut(const std::string &file); | ||
bool loadKneepoints(const std::string &file, std::map<int, std::vector<int> > &kneepoints); | ||
|
||
private: | ||
void lutFromKneepoints(const std::map<int,std::vector<int> > &kneepoints); | ||
std::vector<int> decompandLUT; | ||
|
||
}; | ||
|
||
#endif // COMPAND_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <sstream> | ||
#include <vector> | ||
#include "compand.h" | ||
|
||
|
||
#ifdef OpenCV_FOUND | ||
#include <opencv2/opencv.hpp> | ||
#endif | ||
|
||
|
||
|
||
class DriveuObject { | ||
|
||
public: | ||
|
||
DriveuObject(); | ||
~DriveuObject(); | ||
|
||
int x_; | ||
int y_; | ||
int width_; | ||
int height_; | ||
int class_id_; | ||
int unique_id_; | ||
std::string track_id_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Rect getRect(); | ||
cv::Scalar colorFromClassId(); | ||
#endif | ||
|
||
}; | ||
|
||
class VehicleData { | ||
|
||
public: | ||
|
||
VehicleData(); | ||
~VehicleData(); | ||
|
||
double velocity_; | ||
double yaw_rate_; | ||
double longitude_; | ||
double latitude_; | ||
}; | ||
|
||
|
||
class IntrinsicCalibration { | ||
|
||
public: | ||
|
||
float fx_; | ||
float fy_; | ||
float cx_; | ||
float cy_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat cv_intrinsic_matrix_; | ||
#endif | ||
|
||
std::vector<std::vector<float> > intrinsic_matrix_; | ||
|
||
}; | ||
|
||
class DistortionCalibration { | ||
|
||
public: | ||
|
||
float k1_; | ||
float k2_; | ||
float k3_; | ||
float p1_; | ||
float p2_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat cv_distortion_matrix_; | ||
#endif | ||
|
||
std::vector<std::vector<float> > distortion_matrix_; | ||
|
||
|
||
}; | ||
|
||
class ProjectionMatrix { | ||
|
||
public: | ||
|
||
float fx_; | ||
float fy_; | ||
float cx_; | ||
float cy_; | ||
float tx_; | ||
float ty_; | ||
float baseline_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat cv_projection_matrix_; | ||
#endif | ||
|
||
std::vector<std::vector<float> > projection_matrix_; | ||
|
||
}; | ||
|
||
class RectificationMatrix { | ||
|
||
public: | ||
|
||
float r_11_; | ||
float r_12_; | ||
float r_13_; | ||
float r_21_; | ||
float r_22_; | ||
float r_23_; | ||
float r_31_; | ||
float r_32_; | ||
float r_33_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat cv_rectification_matrix_; | ||
#endif | ||
|
||
std::vector<std::vector<float> > rectification_matrix_; | ||
|
||
|
||
}; | ||
|
||
class ExtrinsicMatrix { | ||
|
||
public: | ||
|
||
float r_11_; | ||
float r_12_; | ||
float r_13_; | ||
float r_21_; | ||
float r_22_; | ||
float r_23_; | ||
float r_31_; | ||
float r_32_; | ||
float r_33_; | ||
|
||
float tx_; | ||
float ty_; | ||
float tz_; | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat cv_extrinsic_matrix_; | ||
#endif | ||
|
||
std::vector<std::vector<float> > extrinsic_matrix_; | ||
|
||
}; | ||
|
||
class CalibrationData { | ||
|
||
public: | ||
|
||
CalibrationData(); | ||
~CalibrationData(); | ||
|
||
IntrinsicCalibration intrinsic_matrix; | ||
DistortionCalibration distortion_matrix; | ||
ProjectionMatrix projection_matrix; | ||
RectificationMatrix rectification_matrix; | ||
ExtrinsicMatrix extrinsic_matrix; | ||
|
||
|
||
bool loadIntrinsicMatrix(const std::string &path); | ||
bool loadProjectionMatrix(const std::string &path); | ||
bool loadDistortionMatrix(const std::string &path); | ||
bool loadRectificationMatrix(const std::string &path); | ||
bool loadExtrinsicMatrix(const std::string &path); | ||
|
||
#ifdef OpenCV_FOUND | ||
cv::Mat getCvIntrinsicMatrix(); | ||
cv::Mat getCvExtrinsicMatrix(); | ||
cv::Mat getCvProjectionMatrix(); | ||
cv::Mat getCvDistortionMatrix(); | ||
cv::Mat getCvRectificationMatrix(); | ||
#endif | ||
|
||
std::vector<std::vector<float> > getIntrinsicMatrix(); | ||
std::vector<std::vector<float> > getExtrinsicMatrix(); | ||
std::vector<std::vector<float> > getProjectionMatrix(); | ||
std::vector<std::vector<float> > getDistortionMatrix(); | ||
std::vector<std::vector<float> > getRectificationMatrix(); | ||
|
||
private: | ||
|
||
bool loadYmlMatrix(const std::string &path, int &rows, int &cols, std::vector<float> &data_vec); | ||
#ifdef OpenCV_FOUND | ||
bool fillCvMat(cv::Mat &mat, std::vector<float> &vec, const int &rows, const int &cols); | ||
#endif | ||
bool fillMat(std::vector<std::vector<float> > &mat, std::vector<float> &vec, const int &rows, const int &cols); | ||
|
||
}; | ||
|
||
class DriveuImage { | ||
|
||
public: | ||
|
||
DriveuImage(); | ||
~DriveuImage(); | ||
|
||
std::string file_path_; | ||
std::string disp_file_path_; | ||
|
||
double timestamp_; | ||
VehicleData vehicle_data; | ||
|
||
std::vector<DriveuObject> objects; | ||
|
||
Decompand* decomp_; | ||
|
||
|
||
#ifdef OpenCV_FOUND | ||
bool getImage(cv::Mat &imageMat); | ||
cv::Mat getImage16Bit(); | ||
bool getDisparityImage(cv::Mat &dispMat); | ||
bool getLabeledImage(cv::Mat &imageMat); | ||
void visualizeDisparityImage(cv::Mat &dispMat); | ||
std::vector<cv::Rect> mapLabelsToDisparityImage(CalibrationData &calib); | ||
#endif | ||
}; | ||
|
||
class DriveuDatabase { | ||
|
||
public: | ||
|
||
DriveuDatabase(); | ||
~DriveuDatabase(); | ||
|
||
std::vector<DriveuImage> images; | ||
bool open(const std::string &path); | ||
|
||
}; | ||
|
||
|
||
|
||
|
Oops, something went wrong.