Skip to content
Snippets Groups Projects
Commit 9cd7f948 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Merge master

parents 3d79c67f ce70496f
No related branches found
No related tags found
No related merge requests found
Pipeline #10810 passed
windows job: # Gitlab waits until all jobs for a stage are completed before moving to next
tags: # stage, so using stages for Windows/Linux builds would wait until the other is
- win # finished before continuing.
script: #
- 'call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat"' # Perhaps relevant in future https://gitlab.com/gitlab-org/gitlab-ce/issues/47063
- mkdir build
- cd build stages:
- 'cmake -DWITH_PCL=FALSE -DCMAKE_GENERATOR_PLATFORM=x64 -DEigen3_DIR="C:/Program Files (x86)/Eigen3/share/eigen3/cmake" -DOpenCV_DIR="D:/opencv-4.0.1/build/install" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1" ..' - all
- devenv ftl.utu.fi.sln /build Release # - build
# - test
# - deploy
linux job: #cache:
# paths:
# - build/
docker:
stage: all
tags: tags:
- docker - docker
image: ubuntu:18.04 image: ubuntu:18.04
before_script: before_script:
- export DEBIAN_FRONTEND=noninteractive - export DEBIAN_FRONTEND=noninteractive
- apt-get update -qq && apt-get install -y -qq g++ cmake git - apt-get update -qq && apt-get install -y -qq g++ cmake git
...@@ -24,3 +29,20 @@ linux job: ...@@ -24,3 +29,20 @@ linux job:
- cmake .. - cmake ..
- make - make
- ctest --output-on-failure - ctest --output-on-failure
windows:
stage: all
variables:
CMAKE_ARGS: '-DWITH_PCL=FALSE -DCMAKE_GENERATOR_PLATFORM=x64 -DEigen3_DIR="C:/Program Files (x86)/Eigen3/share/eigen3/cmake" -DOpenCV_DIR="D:/opencv-4.0.1/build/install" -DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1"'
DEPLOY_DIR: 'D:/Shared/AutoDeploy'
tags:
- win
script:
- 'call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat"'
- mkdir build
- cd build
- cmake %CMAKE_ARGS% ..
- devenv ftl.utu.fi.sln /build Release
- rmdir /q /s "%DEPLOY_DIR%/%CI_COMMIT_REF_SLUG%"
- mkdir "%DEPLOY_DIR%/%CI_COMMIT_REF_SLUG%"
- 'copy "applications\vision\Release\ftl-vision.exe" "%DEPLOY_DIR%\%CI_COMMIT_REF_SLUG%"'
\ No newline at end of file
...@@ -58,7 +58,7 @@ static void run(const string &file) { ...@@ -58,7 +58,7 @@ static void run(const string &file) {
Universe net(config["net"]); Universe net(config["net"]);
LOG(INFO) << "Net started."; LOG(INFO) << "Net started.";
RGBDSource *source = nullptr; StereoVideoSource *source = nullptr;
source = new StereoVideoSource(config, file); source = new StereoVideoSource(config, file);
// Allow remote users to access camera calibration matrix // Allow remote users to access camera calibration matrix
...@@ -143,6 +143,7 @@ static void run(const string &file) { ...@@ -143,6 +143,7 @@ static void run(const string &file) {
// Send RGB+Depth images for local rendering // Send RGB+Depth images for local rendering
if (prgb.rows > 0) display.render(prgb, pdepth, source->getParameters()); if (prgb.rows > 0) display.render(prgb, pdepth, source->getParameters());
if (config["display"]["right"]) cv::imshow("Right: ", source->getRight());
display.wait(1); display.wait(1);
// Wait for both pipelines to complete // Wait for both pipelines to complete
...@@ -160,12 +161,14 @@ static void run(const string &file) { ...@@ -160,12 +161,14 @@ static void run(const string &file) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
std::cout << "FTL Vision Node " << FTL_VERSION_LONG << std::endl;
auto paths = ftl::configure(argc, argv, "vision"); auto paths = ftl::configure(argc, argv, "vision");
config["paths"] = paths; config["paths"] = paths;
// Choose normal or middlebury modes // Choose normal or middlebury modes
if (config["middlebury"]["dataset"] == "") { if (config["middlebury"]["dataset"] == "") {
std::cout << "Loading..." << std::endl;
run((paths.size() > 0) ? paths[0] : ""); run((paths.size() > 0) ? paths[0] : "");
} else { } else {
ftl::middlebury::test(config); ftl::middlebury::test(config);
......
...@@ -235,6 +235,8 @@ void Universe::_run() { ...@@ -235,6 +235,8 @@ void Universe::_run() {
continue; continue;
} }
unique_lock<mutex> lk(net_mutex_);
//If connection request is waiting //If connection request is waiting
for (auto l : listeners_) { for (auto l : listeners_) {
if (l && l->isListening()) { if (l && l->isListening()) {
......
...@@ -29,6 +29,8 @@ class StereoVideoSource : public RGBDSource { ...@@ -29,6 +29,8 @@ class StereoVideoSource : public RGBDSource {
void getRGBD(cv::Mat &rgb, cv::Mat &depth); void getRGBD(cv::Mat &rgb, cv::Mat &depth);
bool isReady(); bool isReady();
const cv::Mat &getRight() const { return right_; }
static inline RGBDSource *create(nlohmann::json &config, ftl::net::Universe *net) { static inline RGBDSource *create(nlohmann::json &config, ftl::net::Universe *net) {
return new StereoVideoSource(config, net); return new StereoVideoSource(config, net);
} }
......
...@@ -274,9 +274,15 @@ bool Calibrate::_loadCalibration() { ...@@ -274,9 +274,15 @@ bool Calibrate::_loadCalibration() {
map1_[1], map2_[1]); map1_[1], map2_[1]);
// Re-distort // Re-distort
initUndistortRectifyMap(M1, Mat(), R1.t(), P1, Mat P1_cam = (cv::Mat_<double>(3,3) << P1.at<double>(0, 0), P1.at<double>(0, 1) , P1.at<double>(0, 2),
P1.at<double>(1, 0), P1.at<double>(1, 1), P1.at<double>(1, 2),
P1.at<double>(2, 0), P1.at<double>(2, 1), P1.at<double>(2, 2));
Mat M1_trans = (cv::Mat_<double>(3, 4) << M1.at<double>(0, 0), M1.at<double>(0, 1), M1.at<double>(0, 2), -P1.at<double>(0, 3),
M1.at<double>(1, 0), M1.at<double>(1, 1), M1.at<double>(1, 2), -P1.at<double>(1, 3),
M1.at<double>(2, 0), M1.at<double>(2, 1), M1.at<double>(2, 2), -P1.at<double>(2, 3));
initUndistortRectifyMap(P1_cam, Mat(), R1.t(), P1,
img_size, CV_16SC2, imap1_, imap2_); img_size, CV_16SC2, imap1_, imap2_);
r1_ = R1.t(); r1_ = P1;
return true; return true;
} }
......
...@@ -108,6 +108,7 @@ class Calibrate { ...@@ -108,6 +108,7 @@ class Calibrate {
* a 3D point cloud. * a 3D point cloud.
*/ */
const cv::Mat &getQ() const { return Q_; } const cv::Mat &getQ() const { return Q_; }
const cv::Mat &getCameraMatrix() const { return r1_; }
private: private:
bool _recalibrate(std::vector<std::vector<cv::Point2f>> *imagePoints, bool _recalibrate(std::vector<std::vector<cv::Point2f>> *imagePoints,
......
...@@ -46,12 +46,13 @@ StereoVideoSource::StereoVideoSource(nlohmann::json &config, const string &file) ...@@ -46,12 +46,13 @@ StereoVideoSource::StereoVideoSource(nlohmann::json &config, const string &file)
else LOG(INFO) << "Calibration initiated."; else LOG(INFO) << "Calibration initiated.";
// Generate camera parameters from Q matrix // Generate camera parameters from Q matrix
cv::Mat q = calib_->getQ(); cv::Mat q = calib_->getCameraMatrix();
params_ = { params_ = {
q.at<double>(2,3), // FX // TODO(Nick) Add fx and fy
q.at<double>(2,3), // FY q.at<double>(0,0), // Fx
q.at<double>(0,3), // Cx q.at<double>(1,1), // Fy
q.at<double>(1,3), // Cy q.at<double>(0,2), // Cx
q.at<double>(1,2), // Cy
(unsigned int)left_.cols, // TODO (Nick) (unsigned int)left_.cols, // TODO (Nick)
(unsigned int)left_.rows, (unsigned int)left_.rows,
0.0f, // 0m min 0.0f, // 0m min
...@@ -107,5 +108,5 @@ void StereoVideoSource::getRGBD(cv::Mat &rgb, cv::Mat &depth) { ...@@ -107,5 +108,5 @@ void StereoVideoSource::getRGBD(cv::Mat &rgb, cv::Mat &depth) {
disp_->compute(left_, right_, disp); disp_->compute(left_, right_, disp);
rgb = left_; rgb = left_;
disparityToDepth(disp, depth, calib_->getQ()); disparityToDepth(disp, depth, calib_->getQ());
calib_->distort(rgb,depth); //calib_->distort(rgb,depth);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment