refactor(calib models): add new calib model processer

This commit is contained in:
TinyOh
2019-01-09 10:53:05 +08:00
parent 6e3afaec29
commit 3978264c50
6 changed files with 336 additions and 27 deletions

View File

@@ -0,0 +1,54 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "mynteye/api/processor/depth_processor_ocv.h"
#include <utility>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
const char DepthProcessorOCV::NAME[] = "DepthProcessorOCV";
DepthProcessorOCV::DepthProcessorOCV(std::int32_t proc_period)
: Processor(std::move(proc_period)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
}
DepthProcessorOCV::~DepthProcessorOCV() {
VLOG(2) << __func__;
}
std::string DepthProcessorOCV::Name() {
return NAME;
}
Object *DepthProcessorOCV::OnCreateOutput() {
return new ObjMat();
}
bool DepthProcessorOCV::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
cv::Mat channels[3 /*input->value.channels()*/];
cv::split(input->value, channels);
channels[2].convertTo(output->value, CV_16UC1);
output->id = input->id;
output->data = input->data;
return true;
}
MYNTEYE_END_NAMESPACE

View File

@@ -0,0 +1,41 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_
#define MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_
#pragma once
#include <string>
#include "mynteye/api/processor.h"
MYNTEYE_BEGIN_NAMESPACE
class DepthProcessorOCV : public Processor {
public:
static const char NAME[];
explicit DepthProcessorOCV(std::int32_t proc_period = 0);
virtual ~DepthProcessorOCV();
std::string Name() override;
protected:
Object *OnCreateOutput() override;
bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override;
};
MYNTEYE_END_NAMESPACE
#endif // MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_OCV_H_

View File

@@ -0,0 +1,54 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "mynteye/api/processor/points_processor_ocv.h"
#include <utility>
#include <opencv2/calib3d/calib3d.hpp>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
const char PointsProcessorOCV::NAME[] = "PointsProcessorOCV";
PointsProcessorOCV::PointsProcessorOCV(cv::Mat Q, std::int32_t proc_period)
: Processor(std::move(proc_period)), Q_(std::move(Q)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
}
PointsProcessorOCV::~PointsProcessorOCV() {
VLOG(2) << __func__;
}
std::string PointsProcessorOCV::Name() {
return NAME;
}
Object *PointsProcessorOCV::OnCreateOutput() {
return new ObjMat();
}
bool PointsProcessorOCV::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
cv::reprojectImageTo3D(input->value, output->value, Q_, true);
output->id = input->id;
output->data = input->data;
return true;
}
MYNTEYE_END_NAMESPACE

View File

@@ -0,0 +1,46 @@
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_
#define MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_
#pragma once
#include <string>
#include <opencv2/core/core.hpp>
#include "mynteye/api/processor.h"
MYNTEYE_BEGIN_NAMESPACE
class PointsProcessorOCV : public Processor {
public:
static const char NAME[];
explicit PointsProcessorOCV(cv::Mat Q, std::int32_t proc_period = 0);
virtual ~PointsProcessorOCV();
std::string Name() override;
protected:
Object *OnCreateOutput() override;
bool OnProcess(
Object *const in, Object *const out, Processor *const parent) override;
private:
cv::Mat Q_;
};
MYNTEYE_END_NAMESPACE
#endif // MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_OCV_H_