-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mono/bino SinusShiftGrayCodePattern.cpp): gui support shift Gray…
… code pattern. 1. support mono/bino camera to use shift Gray code pattern(include stripes create and restruction method change).
- Loading branch information
1 parent
109b678
commit 753967e
Showing
17 changed files
with
464 additions
and
17 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
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
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
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
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
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
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
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
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,60 @@ | ||
#include <benchmark/benchmark.h> | ||
|
||
#include <slmaster.h> | ||
|
||
using namespace slmaster; | ||
using namespace slmaster::algorithm; | ||
using namespace std; | ||
using namespace cv; | ||
|
||
class ShiftGrayCodePatternSuit : public benchmark::Fixture { | ||
public: | ||
void SetUp(const benchmark::State &) override{ | ||
|
||
} | ||
}; | ||
|
||
BENCHMARK_DEFINE_F(ShiftGrayCodePatternSuit, testGenerate)(benchmark::State& state) { | ||
auto params = SinusShiftGrayCodePattern::Params(); | ||
params.shiftTime = 4; | ||
params.height = 1080; | ||
params.width = 1920; | ||
params.horizontal = false; | ||
params.nbrOfPeriods = 32; | ||
|
||
auto pattern = SinusShiftGrayCodePattern::create(params); | ||
|
||
vector<Mat> imgs; | ||
|
||
for (auto _ : state) { | ||
pattern->generate(imgs); | ||
} | ||
} | ||
|
||
BENCHMARK_DEFINE_F(ShiftGrayCodePatternSuit, testUnwrap)(benchmark::State& state) { | ||
auto params = SinusShiftGrayCodePattern::Params(); | ||
params.shiftTime = 4; | ||
params.height = 1080; | ||
params.width = 1920; | ||
params.horizontal = false; | ||
params.nbrOfPeriods = 32; | ||
|
||
auto pattern = SinusShiftGrayCodePattern::create(params); | ||
|
||
vector<Mat> imgs; | ||
pattern->generate(imgs); | ||
|
||
Mat wrapPhaseMap, floorMap, confidenceMap, unwrapPhaseMap; | ||
|
||
for (auto _ : state) { | ||
pattern->computePhaseMap(imgs, wrapPhaseMap); | ||
pattern->computeConfidenceMap(imgs, confidenceMap); | ||
pattern->computeFloorMap(imgs, confidenceMap, wrapPhaseMap, floorMap); | ||
pattern->unwrapPhaseMap(wrapPhaseMap, floorMap, unwrapPhaseMap); | ||
} | ||
} | ||
|
||
BENCHMARK_REGISTER_F(ShiftGrayCodePatternSuit, testGenerate)->MeasureProcessCPUTime()->UseRealTime()->Unit(benchmark::TimeUnit::kMillisecond); | ||
BENCHMARK_REGISTER_F(ShiftGrayCodePatternSuit, testUnwrap)->MeasureProcessCPUTime()->UseRealTime()->Unit(benchmark::TimeUnit::kMillisecond); | ||
|
||
BENCHMARK_MAIN(); |
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
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,82 @@ | ||
#include "binosSinusShiftGrayCodePattern.h" | ||
|
||
#include "../algorithm/algorithm.h" | ||
|
||
using namespace cv; | ||
|
||
namespace slmaster { | ||
namespace cameras { | ||
|
||
static BinoSinusShiftGrayCodePattern::Params params__; | ||
|
||
BinoSinusShiftGrayCodePattern::BinoSinusShiftGrayCodePattern() {} | ||
|
||
bool BinoSinusShiftGrayCodePattern::generate( | ||
std::vector<cv::Mat> &imgs) const { | ||
algorithm::SinusShiftGrayCodePattern::Params params; | ||
params.width = params__.width_; | ||
params.height = params__.height_; | ||
params.nbrOfPeriods = params__.cycles_; | ||
params.horizontal = params__.horizontal_; | ||
params.maxCost = params__.maxCost_; | ||
params.minDisparity = params__.minDisparity_; | ||
params.maxDisparity = params__.maxDisparity_; | ||
params.confidenceThreshold = params__.confidenceThreshold_; | ||
params.shiftTime = params__.shiftTime_; | ||
|
||
return algorithm::SinusShiftGrayCodePattern::create(params) | ||
->generate(imgs); | ||
} | ||
|
||
std::shared_ptr<Pattern> BinoSinusShiftGrayCodePattern::create(const Params& params) { | ||
params__ = params; | ||
|
||
return std::make_shared<BinoSinusShiftGrayCodePattern>(); | ||
} | ||
|
||
bool BinoSinusShiftGrayCodePattern::decode( | ||
const std::vector<std::vector<cv::Mat>> &patternImages, | ||
cv::Mat &disparityMap, const bool isGpu) const { | ||
CV_Assert(patternImages.size() >= 2); | ||
|
||
#ifdef OPENCV_WITH_CUDA_MODULE | ||
if (isGpu) { | ||
/* | ||
algorithm::SinusCompleGrayCodePatternGPU::Params params; | ||
params.shiftTime = params__.shiftTime_; | ||
params.confidenceThreshold = params__.confidenceThreshold_; | ||
params.costMinDiff = params__.costMinDiff_; | ||
params.maxCost = params__.maxCost_; | ||
params.height = params__.height_; | ||
params.width = params__.width_; | ||
params.nbrOfPeriods = params__.cycles_; | ||
params.horizontal = params__.horizontal_; | ||
params.minDisparity = params__.minDisparity_; | ||
params.maxDisparity = params__.maxDisparity_; | ||
auto pattern = algorithm::SinusCompleGrayCodePatternGPU::create(params); | ||
return pattern->decode(patternImages, disparityMap, | ||
algorithm::SINUSOIDAL_COMPLEMENTARY_GRAY_CODE_GPU); | ||
*/ | ||
return false; | ||
} | ||
#endif | ||
|
||
algorithm::SinusShiftGrayCodePattern::Params params; | ||
params.shiftTime = params__.shiftTime_; | ||
params.width = params__.width_; | ||
params.height = params__.height_; | ||
params.nbrOfPeriods = params__.cycles_; | ||
params.horizontal = params__.horizontal_; | ||
params.maxCost = params__.maxCost_; | ||
params.minDisparity = params__.minDisparity_; | ||
params.maxDisparity = params__.maxDisparity_; | ||
params.confidenceThreshold = params__.confidenceThreshold_; | ||
|
||
auto pattern = algorithm::SinusShiftGrayCodePattern::create(params); | ||
return pattern->decode( | ||
patternImages, disparityMap, cv::noArray(), cv::noArray(), | ||
algorithm::SINUSOIDAL_COMPLEMENTARY_GRAY_CODE); | ||
} | ||
} // namespace cameras | ||
} // namespace slmaster |
Oops, something went wrong.