From 82ca84952e58d42e591cc53368e244c929161b24 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 29 Jul 2020 13:55:21 +0300 Subject: [PATCH] Windows AVX2 and pylon buffer latency --- CMakeLists.txt | 2 +- .../rgbd-sources/src/sources/stereovideo/pylon.cpp | 10 ++++++---- .../rgbd-sources/src/sources/stereovideo/pylon.hpp | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 359261168..ced2238cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,7 +371,7 @@ include(ftl_paths) if (WIN32) # TODO(nick) Should do based upon compiler (VS) add_definitions(-DWIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX512 /MP4 /std:c++17 /wd4996") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 /MP4 /std:c++17 /wd4996") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /DFTL_DEBUG /Wall") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") set(OS_LIBS "") diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp index 98e86714b..1a8f90600 100644 --- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp @@ -112,6 +112,8 @@ PylonDevice::PylonDevice(nlohmann::json &config) rcam_->ExposureTime.SetValue(value("exposure", 24000.0f)); // Exposure time in microseconds } }); + + on("buffer_size", buffer_size_, 1); } PylonDevice::~PylonDevice() { @@ -250,20 +252,20 @@ bool PylonDevice::get(ftl::rgbd::Frame &frame, cv::cuda::GpuMat &l_out, cv::cuda rcam_->RetrieveResult(0, tmp_result, Pylon::TimeoutHandling_Return); }*/ - if (rcount == 0 || lcount == 0) { + if (rcount < buffer_size_ || lcount < buffer_size_) { LOG(WARNING) << "Retrieve failed for L+R"; return false; } - if (rcount > 1 && lcount > 1) { + if (rcount > buffer_size_ && lcount > buffer_size_) { LOG(WARNING) << "Pylon buffer latency problem : " << lcount << " vs " << rcount << " frames"; Pylon::CGrabResultPtr tmp_result; //lcam_->RetrieveResult(0, tmp_result, Pylon::TimeoutHandling_Return); //rcam_->RetrieveResult(0, tmp_result, Pylon::TimeoutHandling_Return); _retrieveFrames(tmp_result, lcam_); _retrieveFrames(tmp_result, rcam_); - } else if (rcount > 1) LOG(ERROR) << "Buffers (R) out of sync by " << rcount; - else if (lcount > 1) LOG(ERROR) << "Buffers (L) out of sync by " << lcount; + } else if (rcount > buffer_size_) LOG(ERROR) << "Buffers (R) out of sync by " << rcount; + else if (lcount > buffer_size_) LOG(ERROR) << "Buffers (L) out of sync by " << lcount; } else { if (lcam_->NumReadyBuffers.GetValue() == 0) { LOG(INFO) << "Retrieve failed for L"; diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.hpp b/components/rgbd-sources/src/sources/stereovideo/pylon.hpp index 70c82a3da..3f1982a36 100644 --- a/components/rgbd-sources/src/sources/stereovideo/pylon.hpp +++ b/components/rgbd-sources/src/sources/stereovideo/pylon.hpp @@ -51,6 +51,7 @@ class PylonDevice : public ftl::rgbd::detail::Device { std::string serial_; int left_fail_=0; int right_fail_=0; + int buffer_size_=1; cv::cuda::HostMem left_hm_; cv::cuda::HostMem right_hm_; -- GitLab