fix(api): update rectify params after config stream request
This commit is contained in:
parent
1652d976bf
commit
a38e6a782a
|
@ -210,7 +210,7 @@ std::vector<std::string> get_plugin_paths() {
|
||||||
|
|
||||||
API::API(std::shared_ptr<Device> device) : device_(device) {
|
API::API(std::shared_ptr<Device> device) : device_(device) {
|
||||||
VLOG(2) << __func__;
|
VLOG(2) << __func__;
|
||||||
std::dynamic_pointer_cast<StandardDevice>(device_);
|
// std::dynamic_pointer_cast<StandardDevice>(device_);
|
||||||
synthetic_.reset(new Synthetic(this));
|
synthetic_.reset(new Synthetic(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +266,7 @@ const std::vector<StreamRequest> &API::GetStreamRequests(
|
||||||
void API::ConfigStreamRequest(
|
void API::ConfigStreamRequest(
|
||||||
const Capabilities &capability, const StreamRequest &request) {
|
const Capabilities &capability, const StreamRequest &request) {
|
||||||
device_->ConfigStreamRequest(capability, request);
|
device_->ConfigStreamRequest(capability, request);
|
||||||
|
synthetic_->NotifyImageParamsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const StreamRequest &API::GetStreamRequest(
|
const StreamRequest &API::GetStreamRequest(
|
||||||
|
@ -279,6 +280,7 @@ const std::vector<StreamRequest> &API::GetStreamRequests() const {
|
||||||
|
|
||||||
void API::ConfigStreamRequest(const StreamRequest &request) {
|
void API::ConfigStreamRequest(const StreamRequest &request) {
|
||||||
device_->ConfigStreamRequest(request);
|
device_->ConfigStreamRequest(request);
|
||||||
|
synthetic_->NotifyImageParamsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
const StreamRequest &API::GetStreamRequest() const {
|
const StreamRequest &API::GetStreamRequest() const {
|
||||||
|
|
|
@ -27,11 +27,9 @@ const char RectifyProcessor::NAME[] = "RectifyProcessor";
|
||||||
|
|
||||||
RectifyProcessor::RectifyProcessor(
|
RectifyProcessor::RectifyProcessor(
|
||||||
std::shared_ptr<Device> device, std::int32_t proc_period)
|
std::shared_ptr<Device> device, std::int32_t proc_period)
|
||||||
: Processor(std::move(proc_period)) {
|
: Processor(std::move(proc_period)), device_(device) {
|
||||||
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
||||||
InitParams(
|
NotifyImageParamsChanged();
|
||||||
device->GetIntrinsics(Stream::LEFT), device->GetIntrinsics(Stream::RIGHT),
|
|
||||||
device->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RectifyProcessor::~RectifyProcessor() {
|
RectifyProcessor::~RectifyProcessor() {
|
||||||
|
@ -42,6 +40,13 @@ std::string RectifyProcessor::Name() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RectifyProcessor::NotifyImageParamsChanged() {
|
||||||
|
InitParams(
|
||||||
|
device_->GetIntrinsics(Stream::LEFT),
|
||||||
|
device_->GetIntrinsics(Stream::RIGHT),
|
||||||
|
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
|
||||||
|
}
|
||||||
|
|
||||||
Object *RectifyProcessor::OnCreateOutput() {
|
Object *RectifyProcessor::OnCreateOutput() {
|
||||||
return new ObjMat2();
|
return new ObjMat2();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ class RectifyProcessor : public Processor {
|
||||||
|
|
||||||
std::string Name() override;
|
std::string Name() override;
|
||||||
|
|
||||||
|
void NotifyImageParamsChanged();
|
||||||
|
|
||||||
cv::Mat R1, P1, R2, P2, Q;
|
cv::Mat R1, P1, R2, P2, Q;
|
||||||
cv::Mat map11, map12, map21, map22;
|
cv::Mat map11, map12, map21, map22;
|
||||||
|
|
||||||
|
@ -48,6 +50,8 @@ class RectifyProcessor : public Processor {
|
||||||
private:
|
private:
|
||||||
void InitParams(
|
void InitParams(
|
||||||
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left);
|
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left);
|
||||||
|
|
||||||
|
std::shared_ptr<Device> device_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MYNTEYE_END_NAMESPACE
|
MYNTEYE_END_NAMESPACE
|
||||||
|
|
|
@ -83,6 +83,11 @@ Synthetic::~Synthetic() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Synthetic::NotifyImageParamsChanged() {
|
||||||
|
auto &&processor = find_processor<RectifyProcessor>(processor_);
|
||||||
|
if (processor) processor->NotifyImageParamsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
bool Synthetic::Supports(const Stream &stream) const {
|
bool Synthetic::Supports(const Stream &stream) const {
|
||||||
return stream_supports_mode_.find(stream) != stream_supports_mode_.end();
|
return stream_supports_mode_.find(stream) != stream_supports_mode_.end();
|
||||||
}
|
}
|
||||||
|
@ -311,42 +316,35 @@ void Synthetic::EnableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||||
break;
|
break;
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
CHECK(ActivateProcessor<RectifyProcessor>());
|
CHECK(ActivateProcessor<RectifyProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
case Stream::RIGHT_RECTIFIED: {
|
case Stream::RIGHT_RECTIFIED: {
|
||||||
if (!IsStreamDataEnabled(Stream::RIGHT))
|
if (!IsStreamDataEnabled(Stream::RIGHT))
|
||||||
break;
|
break;
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
CHECK(ActivateProcessor<RectifyProcessor>());
|
CHECK(ActivateProcessor<RectifyProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
case Stream::DISPARITY: {
|
case Stream::DISPARITY: {
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
EnableStreamData(Stream::LEFT_RECTIFIED, depth + 1);
|
EnableStreamData(Stream::LEFT_RECTIFIED, depth + 1);
|
||||||
EnableStreamData(Stream::RIGHT_RECTIFIED, depth + 1);
|
EnableStreamData(Stream::RIGHT_RECTIFIED, depth + 1);
|
||||||
CHECK(ActivateProcessor<DisparityProcessor>());
|
CHECK(ActivateProcessor<DisparityProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
case Stream::DISPARITY_NORMALIZED: {
|
case Stream::DISPARITY_NORMALIZED: {
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
EnableStreamData(Stream::DISPARITY, depth + 1);
|
EnableStreamData(Stream::DISPARITY, depth + 1);
|
||||||
CHECK(ActivateProcessor<DisparityNormalizedProcessor>());
|
CHECK(ActivateProcessor<DisparityNormalizedProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
case Stream::POINTS: {
|
case Stream::POINTS: {
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
EnableStreamData(Stream::DISPARITY, depth + 1);
|
EnableStreamData(Stream::DISPARITY, depth + 1);
|
||||||
CHECK(ActivateProcessor<PointsProcessor>());
|
CHECK(ActivateProcessor<PointsProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
|
||||||
case Stream::DEPTH: {
|
case Stream::DEPTH: {
|
||||||
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
stream_enabled_mode_[stream] = MODE_SYNTHETIC;
|
||||||
EnableStreamData(Stream::POINTS, depth + 1);
|
EnableStreamData(Stream::POINTS, depth + 1);
|
||||||
CHECK(ActivateProcessor<DepthProcessor>());
|
CHECK(ActivateProcessor<DepthProcessor>());
|
||||||
}
|
} return;
|
||||||
return;
|
default: break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (depth == 0) {
|
if (depth == 0) {
|
||||||
LOG(WARNING) << "Enable stream data of " << stream << " failed";
|
LOG(WARNING) << "Enable stream data of " << stream << " failed";
|
||||||
|
@ -399,8 +397,7 @@ void Synthetic::DisableStreamData(const Stream &stream, std::uint32_t depth) {
|
||||||
case Stream::DEPTH: {
|
case Stream::DEPTH: {
|
||||||
DeactivateProcessor<DepthProcessor>();
|
DeactivateProcessor<DepthProcessor>();
|
||||||
} break;
|
} break;
|
||||||
default:
|
default: return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (depth > 0) {
|
if (depth > 0) {
|
||||||
LOG(WARNING) << "Disable synthetic stream data of " << stream << " too";
|
LOG(WARNING) << "Disable synthetic stream data of " << stream << " too";
|
||||||
|
|
|
@ -43,6 +43,8 @@ class Synthetic {
|
||||||
explicit Synthetic(API *api);
|
explicit Synthetic(API *api);
|
||||||
~Synthetic();
|
~Synthetic();
|
||||||
|
|
||||||
|
void NotifyImageParamsChanged();
|
||||||
|
|
||||||
bool Supports(const Stream &stream) const;
|
bool Supports(const Stream &stream) const;
|
||||||
mode_t SupportsMode(const Stream &stream) const;
|
mode_t SupportsMode(const Stream &stream) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user