Add processor files
This commit is contained in:
parent
81be95db12
commit
a5ce17a987
|
@ -142,6 +142,11 @@ if(WITH_API)
|
|||
src/api/api.cc
|
||||
src/api/synthetic.cc
|
||||
src/api/processor/processor.cc
|
||||
src/api/processor/rectify_processor.cc
|
||||
src/api/processor/disparity_processor.cc
|
||||
src/api/processor/disparity_normalized_processor.cc
|
||||
src/api/processor/depth_processor.cc
|
||||
src/api/processor/points_processor.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -148,6 +148,10 @@ void API::WaitForStreams() {
|
|||
synthetic_->WaitForStreams();
|
||||
}
|
||||
|
||||
void API::EnableStreamData(const Stream &stream) {
|
||||
synthetic_->EnableStreamData(stream);
|
||||
}
|
||||
|
||||
api::StreamData API::GetStreamData(const Stream &stream) {
|
||||
return synthetic_->GetStreamData(stream);
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ class MYNTEYE_API API {
|
|||
|
||||
void WaitForStreams();
|
||||
|
||||
void EnableStreamData(const Stream &stream);
|
||||
api::StreamData GetStreamData(const Stream &stream);
|
||||
std::vector<api::StreamData> GetStreamDatas(const Stream &stream);
|
||||
|
||||
|
|
30
src/api/processor/depth_processor.cc
Normal file
30
src/api/processor/depth_processor.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "api/processor/depth_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
DepthProcessor::DepthProcessor() : Processor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
DepthProcessor::~DepthProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string DepthProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *DepthProcessor::OnCreateOutput() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DepthProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
UNUSED(parent)
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
28
src/api/processor/depth_processor.h
Normal file
28
src/api/processor/depth_processor.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MYNTEYE_DEPTH_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_DEPTH_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class DepthProcessor : public Processor {
|
||||
public:
|
||||
static constexpr auto &&NAME = "DepthProcessor";
|
||||
|
||||
DepthProcessor();
|
||||
virtual ~DepthProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
void OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DEPTH_PROCESSOR_H_ NOLINT
|
30
src/api/processor/disparity_normalized_processor.cc
Normal file
30
src/api/processor/disparity_normalized_processor.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "api/processor/disparity_normalized_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
DisparityNormalizedProcessor::DisparityNormalizedProcessor() : Processor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
DisparityNormalizedProcessor::~DisparityNormalizedProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string DisparityNormalizedProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *DisparityNormalizedProcessor::OnCreateOutput() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DisparityNormalizedProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
UNUSED(parent)
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
28
src/api/processor/disparity_normalized_processor.h
Normal file
28
src/api/processor/disparity_normalized_processor.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class DisparityNormalizedProcessor : public Processor {
|
||||
public:
|
||||
static constexpr auto &&NAME = "DisparityNormalizedProcessor";
|
||||
|
||||
DisparityNormalizedProcessor();
|
||||
virtual ~DisparityNormalizedProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
void OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ NOLINT
|
30
src/api/processor/disparity_processor.cc
Normal file
30
src/api/processor/disparity_processor.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "api/processor/disparity_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
DisparityProcessor::DisparityProcessor() : Processor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
DisparityProcessor::~DisparityProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string DisparityProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *DisparityProcessor::OnCreateOutput() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DisparityProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
UNUSED(parent)
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
28
src/api/processor/disparity_processor.h
Normal file
28
src/api/processor/disparity_processor.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MYNTEYE_DISPARITY_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_DISPARITY_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class DisparityProcessor : public Processor {
|
||||
public:
|
||||
static constexpr auto &&NAME = "DisparityProcessor";
|
||||
|
||||
DisparityProcessor();
|
||||
virtual ~DisparityProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
void OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DISPARITY_PROCESSOR_H_ NOLINT
|
30
src/api/processor/points_processor.cc
Normal file
30
src/api/processor/points_processor.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "api/processor/points_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
PointsProcessor::PointsProcessor() : Processor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
PointsProcessor::~PointsProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string PointsProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *PointsProcessor::OnCreateOutput() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PointsProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
UNUSED(parent)
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
28
src/api/processor/points_processor.h
Normal file
28
src/api/processor/points_processor.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MYNTEYE_POINTS_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_POINTS_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class PointsProcessor : public Processor {
|
||||
public:
|
||||
static constexpr auto &&NAME = "PointsProcessor";
|
||||
|
||||
PointsProcessor();
|
||||
virtual ~PointsProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
void OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_POINTS_PROCESSOR_H_ NOLINT
|
30
src/api/processor/rectify_processor.cc
Normal file
30
src/api/processor/rectify_processor.cc
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "api/processor/rectify_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
RectifyProcessor::RectifyProcessor() : Processor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
RectifyProcessor::~RectifyProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string RectifyProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *RectifyProcessor::OnCreateOutput() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RectifyProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
UNUSED(parent)
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
28
src/api/processor/rectify_processor.h
Normal file
28
src/api/processor/rectify_processor.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MYNTEYE_RECTIFY_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_RECTIFY_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class RectifyProcessor : public Processor {
|
||||
public:
|
||||
static constexpr auto &&NAME = "RectifyProcessor";
|
||||
|
||||
RectifyProcessor();
|
||||
virtual ~RectifyProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
void OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_RECTIFY_PROCESSOR_H_ NOLINT
|
|
@ -2,21 +2,91 @@
|
|||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "api/processor/depth_processor.h"
|
||||
#include "api/processor/disparity_normalized_processor.h"
|
||||
#include "api/processor/disparity_processor.h"
|
||||
#include "api/processor/points_processor.h"
|
||||
#include "api/processor/processor.h"
|
||||
#include "api/processor/rectify_processor.h"
|
||||
#include "device/device.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
Synthetic::Synthetic(API *api) : api_(api) {
|
||||
VLOG(2) << __func__;
|
||||
CHECK_NOTNULL(api_);
|
||||
InitStreamSupports();
|
||||
}
|
||||
|
||||
Synthetic::~Synthetic() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
Synthetic::mode_t Synthetic::GetMode(const Stream &stream) const {
|
||||
try {
|
||||
return stream_supports_mode_.at(stream);
|
||||
} catch (const std::out_of_range &e) {
|
||||
return MODE_LAST;
|
||||
}
|
||||
}
|
||||
|
||||
bool Synthetic::Supports(const Stream &stream) const {
|
||||
return api_->device()->Supports(stream);
|
||||
return GetMode(stream) != MODE_LAST;
|
||||
}
|
||||
|
||||
void Synthetic::EnableStreamData(const Stream &stream) {
|
||||
if (Supports(stream))
|
||||
return;
|
||||
switch (stream) {
|
||||
case Stream::LEFT_RECTIFIED: {
|
||||
if (Supports(Stream::LEFT)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
case Stream::RIGHT_RECTIFIED: {
|
||||
if (Supports(Stream::RIGHT)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
case Stream::DISPARITY: {
|
||||
if (Supports(Stream::LEFT) && Supports(Stream::RIGHT)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
case Stream::DISPARITY_NORMALIZED: {
|
||||
if ((Supports(Stream::LEFT) && Supports(Stream::RIGHT)) ||
|
||||
Supports(Stream::DISPARITY)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
case Stream::DEPTH: {
|
||||
if ((Supports(Stream::LEFT) && Supports(Stream::RIGHT)) ||
|
||||
Supports(Stream::DISPARITY) || Supports(Stream::POINTS)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
case Stream::POINTS: {
|
||||
if ((Supports(Stream::LEFT) && Supports(Stream::RIGHT)) ||
|
||||
Supports(Stream::DISPARITY)) {
|
||||
stream_supports_mode_[stream] = MODE_SYNTHETIC;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOG(WARNING) << "Enable stream data of " << stream << " failed";
|
||||
}
|
||||
|
||||
void Synthetic::DisableStreamData(const Stream &stream) {
|
||||
UNUSED(stream)
|
||||
}
|
||||
|
||||
void Synthetic::SetStreamCallback(
|
||||
|
@ -46,4 +116,14 @@ std::vector<api::StreamData> Synthetic::GetStreamDatas(const Stream &stream) {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Synthetic::InitStreamSupports() {
|
||||
auto &&device = api_->device();
|
||||
for (Stream s = Stream::LEFT; s < Stream::LAST;) {
|
||||
if (device->Supports(s)) {
|
||||
stream_supports_mode_[s] = MODE_NATIVE;
|
||||
}
|
||||
s = static_cast<Stream>(static_cast<std::uint8_t>(s) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define MYNTEYE_SYNTHETIC_H_
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
|
@ -16,11 +17,21 @@ class Synthetic {
|
|||
public:
|
||||
using stream_callback_t = API::stream_callback_t;
|
||||
|
||||
typedef enum Mode {
|
||||
MODE_NATIVE, // Native stream
|
||||
MODE_SYNTHETIC, // Synthetic stream
|
||||
MODE_LAST // Unsupported
|
||||
} mode_t;
|
||||
|
||||
explicit Synthetic(API *api);
|
||||
~Synthetic();
|
||||
|
||||
mode_t GetMode(const Stream &stream) const;
|
||||
bool Supports(const Stream &stream) const;
|
||||
|
||||
void EnableStreamData(const Stream &stream);
|
||||
void DisableStreamData(const Stream &stream);
|
||||
|
||||
void SetStreamCallback(const Stream &stream, stream_callback_t callback);
|
||||
bool HasStreamCallback(const Stream &stream) const;
|
||||
|
||||
|
@ -33,8 +44,12 @@ class Synthetic {
|
|||
std::vector<api::StreamData> GetStreamDatas(const Stream &stream);
|
||||
|
||||
private:
|
||||
void InitStreamSupports();
|
||||
|
||||
API *api_;
|
||||
|
||||
std::map<Stream, mode_t> stream_supports_mode_;
|
||||
|
||||
std::vector<std::shared_ptr<Processor>> processors_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user