Add process return bool

This commit is contained in:
John Zhao 2018-04-28 13:37:25 +08:00
parent c176f55af2
commit c49342f9f7
12 changed files with 27 additions and 14 deletions

View File

@ -20,11 +20,12 @@ Object *DepthProcessor::OnCreateOutput() {
return nullptr; return nullptr;
} }
void DepthProcessor::OnProcess( bool DepthProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(in) UNUSED(in)
UNUSED(out) UNUSED(out)
UNUSED(parent) UNUSED(parent)
return true;
} }
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE

View File

@ -19,7 +19,7 @@ class DepthProcessor : public Processor {
protected: protected:
Object *OnCreateOutput() override; Object *OnCreateOutput() override;
void OnProcess( bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override; Object *const in, Object *const out, Processor *const parent) override;
}; };

View File

@ -22,12 +22,14 @@ Object *DisparityNormalizedProcessor::OnCreateOutput() {
return new ObjMat(); return new ObjMat();
} }
void DisparityNormalizedProcessor::OnProcess( bool DisparityNormalizedProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in); const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1);
// cv::normalize maybe return empty ==
return !output->value.empty();
} }
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE

View File

@ -19,7 +19,7 @@ class DisparityNormalizedProcessor : public Processor {
protected: protected:
Object *OnCreateOutput() override; Object *OnCreateOutput() override;
void OnProcess( bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override; Object *const in, Object *const out, Processor *const parent) override;
}; };

View File

@ -54,7 +54,7 @@ Object *DisparityProcessor::OnCreateOutput() {
return new ObjMat(); return new ObjMat();
} }
void DisparityProcessor::OnProcess( bool DisparityProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in); const ObjMat2 *input = Object::Cast<ObjMat2>(in);
@ -81,6 +81,7 @@ void DisparityProcessor::OnProcess(
sgbm_->compute(input->first, input->second, disparity); sgbm_->compute(input->first, input->second, disparity);
#endif #endif
output->value = disparity / 16 + 1; output->value = disparity / 16 + 1;
return true;
} }
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE

View File

@ -25,7 +25,7 @@ class DisparityProcessor : public Processor {
protected: protected:
Object *OnCreateOutput() override; Object *OnCreateOutput() override;
void OnProcess( bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override; Object *const in, Object *const out, Processor *const parent) override;
private: private:

View File

@ -20,11 +20,12 @@ Object *PointsProcessor::OnCreateOutput() {
return nullptr; return nullptr;
} }
void PointsProcessor::OnProcess( bool PointsProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(in) UNUSED(in)
UNUSED(out) UNUSED(out)
UNUSED(parent) UNUSED(parent)
return true;
} }
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE

View File

@ -19,7 +19,7 @@ class PointsProcessor : public Processor {
protected: protected:
Object *OnCreateOutput() override; Object *OnCreateOutput() override;
void OnProcess( bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override; Object *const in, Object *const out, Processor *const parent) override;
}; };

View File

@ -151,12 +151,19 @@ void Processor::Run() {
if (pre_callback_) { if (pre_callback_) {
pre_callback_(input_.get()); pre_callback_(input_.get());
} }
bool ok = false;
if (callback_) { if (callback_) {
if (!callback_(input_.get(), output_.get(), parent_)) { if (callback_(input_.get(), output_.get(), parent_)) {
OnProcess(input_.get(), output_.get(), parent_); ok = true;
} else {
ok = OnProcess(input_.get(), output_.get(), parent_);
} }
} else { } else {
OnProcess(input_.get(), output_.get(), parent_); ok = OnProcess(input_.get(), output_.get(), parent_);
}
if (!ok) {
VLOG(2) << Name() << " process failed";
continue;
} }
if (post_callback_) { if (post_callback_) {
post_callback_(output_.get()); post_callback_(output_.get());

View File

@ -58,7 +58,7 @@ class Processor /*: public std::enable_shared_from_this<Processor>*/ {
protected: protected:
virtual Object *OnCreateOutput() = 0; virtual Object *OnCreateOutput() = 0;
virtual void OnProcess( virtual bool OnProcess(
Object *const in, Object *const out, Processor *const parent) = 0; Object *const in, Object *const out, Processor *const parent) = 0;
private: private:

View File

@ -29,13 +29,14 @@ Object *RectifyProcessor::OnCreateOutput() {
return new ObjMat2(); return new ObjMat2();
} }
void RectifyProcessor::OnProcess( bool RectifyProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in); const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat2 *output = Object::Cast<ObjMat2>(out); ObjMat2 *output = Object::Cast<ObjMat2>(out);
cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR); cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR);
cv::remap(input->second, output->second, map21, map22, cv::INTER_LINEAR); cv::remap(input->second, output->second, map21, map22, cv::INTER_LINEAR);
return true;
} }
void RectifyProcessor::InitParams( void RectifyProcessor::InitParams(

View File

@ -25,7 +25,7 @@ class RectifyProcessor : public Processor {
protected: protected:
Object *OnCreateOutput() override; Object *OnCreateOutput() override;
void OnProcess( bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override; Object *const in, Object *const out, Processor *const parent) override;
private: private: