refactor(synthetic): GetStreamData

This commit is contained in:
TinyOh 2019-01-22 17:29:57 +08:00
parent cdc5db724d
commit 4011880148

View File

@ -345,108 +345,46 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
auto &&device = api_->device(); auto &&device = api_->device();
return data2api(device->GetStreamData(stream)); return data2api(device->GetStreamData(stream));
} else if (mode == MODE_SYNTHETIC) { } else if (mode == MODE_SYNTHETIC) {
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) { auto processor = getProcessorWithStream(stream);
static std::shared_ptr<ObjMat2> output = nullptr; auto sum = processor->getStreamsSum();
std::shared_ptr<Processor> processor = nullptr; auto &&out = processor->GetOutput();
if (calib_model_ == CalibrationModel::PINHOLE) { static std::shared_ptr<ObjMat2> output = nullptr;
processor = find_processor<RectifyProcessorOCV>(processor_); std::cout << processor->Name() << stream <<std::endl;
#ifdef WITH_CAM_MODELS if (sum == 1) {
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) { if (out != nullptr) {
processor = find_processor<RectifyProcessor>(processor_); auto &&output = Object::Cast<ObjMat>(out);
#endif if (output != nullptr) {
} else { return {output->data, output->value, nullptr, output->id};
LOG(ERROR) << "Unknow calib model type in device: " }
<< calib_model_ << ", use default pinhole model"; VLOG(2) << "Rectify not ready now";
processor = find_processor<RectifyProcessorOCV>(processor_); }
} } else if (sum == 2) {
auto &&out = processor->GetOutput();
if (out != nullptr) { if (out != nullptr) {
// Obtain the output, out will be nullptr if get again immediately.
output = Object::Cast<ObjMat2>(out); output = Object::Cast<ObjMat2>(out);
} }
auto streams = processor->getTargetStreams();
if (output != nullptr) { if (output != nullptr) {
if (stream == Stream::LEFT_RECTIFIED) { int num = 0;
return {output->first_data, output->first, nullptr, output->first_id}; for (auto it : streams) {
} else { if (it.stream == stream) {
return {output->second_data, output->second, nullptr, if (num == 0) {
return {output->first_data,
output->first,
nullptr,
output->first_id};
} else {
return {output->second_data,
output->second,
nullptr,
output->second_id}; output->second_id};
}
}
num++;
} }
} }
VLOG(2) << "Rectify not ready now"; VLOG(2) << "Rectify not ready now";
return {}; } else {
} LOG(ERROR) << "error: invalid sum!";
switch (stream) {
case Stream::DISPARITY: {
auto &&processor = find_processor<DisparityProcessor>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Disparity not ready now";
} break;
case Stream::DISPARITY_NORMALIZED: {
auto &&processor =
find_processor<DisparityNormalizedProcessor>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Disparity normalized not ready now";
} break;
case Stream::POINTS: {
if (calib_model_ == CalibrationModel::PINHOLE) {
auto &&processor = find_processor<PointsProcessorOCV>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Points not ready now";
#ifdef WITH_CAM_MODELS
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
auto &&processor = find_processor<PointsProcessor>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Points not ready now";
#endif
} else {
// UNKNOW
LOG(ERROR) << "Unknow calib model type in device: "
<< calib_model_;
}
} break;
case Stream::DEPTH: {
if (calib_model_ == CalibrationModel::PINHOLE) {
auto &&processor = find_processor<DepthProcessorOCV>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Depth not ready now";
#ifdef WITH_CAM_MODELS
} else if (calib_model_ == CalibrationModel::KANNALA_BRANDT) {
auto &&processor = find_processor<DepthProcessor>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
auto &&output = Object::Cast<ObjMat>(out);
return {output->data, output->value, nullptr, output->id};
}
VLOG(2) << "Depth not ready now";
#endif
} else {
// UNKNOW
LOG(ERROR) << "Unknow calib model type in device: "
<< calib_model_;
}
} break;
default:
break;
} }
return {}; // frame.empty() == true return {}; // frame.empty() == true
} else { } else {