2018-05-10 09:46:34 +03:00
|
|
|
// 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.
|
2018-10-27 16:24:04 +03:00
|
|
|
#ifndef MYNTEYE_API_OBJECT_H_
|
|
|
|
#define MYNTEYE_API_OBJECT_H_
|
2018-04-26 09:44:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-13 13:00:31 +03:00
|
|
|
#include <memory>
|
|
|
|
|
2018-10-27 16:24:04 +03:00
|
|
|
#include <opencv2/core/core.hpp>
|
|
|
|
|
2018-04-26 09:44:47 +03:00
|
|
|
#include "mynteye/mynteye.h"
|
|
|
|
|
|
|
|
MYNTEYE_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Input & output object.
|
|
|
|
*/
|
2018-05-08 06:12:45 +03:00
|
|
|
struct MYNTEYE_API Object {
|
2018-04-26 09:44:47 +03:00
|
|
|
Object() = default;
|
|
|
|
virtual ~Object() = default;
|
|
|
|
|
|
|
|
virtual Object *Clone() const = 0;
|
2018-07-10 21:05:44 +03:00
|
|
|
virtual bool DecValidity() const = 0;
|
2018-04-26 09:44:47 +03:00
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/** Cast the obj to T pointer */
|
2018-04-26 09:44:47 +03:00
|
|
|
template <typename T>
|
|
|
|
static T *Cast(Object *obj) {
|
|
|
|
return dynamic_cast<T *>(obj);
|
|
|
|
}
|
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/** Cast the obj to const T pointer */
|
2018-04-26 09:44:47 +03:00
|
|
|
template <typename T>
|
|
|
|
static const T *Cast(const Object *obj) {
|
|
|
|
return dynamic_cast<const T *>(obj);
|
|
|
|
}
|
2018-06-13 13:00:31 +03:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static std::shared_ptr<T> Cast(const std::shared_ptr<Object> &obj) {
|
|
|
|
return std::dynamic_pointer_cast<T>(obj);
|
|
|
|
}
|
2018-04-26 09:44:47 +03:00
|
|
|
};
|
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/**
|
|
|
|
* Input & output object of one cv::Mat.
|
|
|
|
*/
|
2018-05-08 06:12:45 +03:00
|
|
|
struct MYNTEYE_API ObjMat : public Object {
|
2018-04-26 09:44:47 +03:00
|
|
|
ObjMat() = default;
|
2018-10-26 10:39:34 +03:00
|
|
|
ObjMat(const cv::Mat &value, std::uint16_t id)
|
|
|
|
: value(value), id(id) {}
|
2018-04-26 09:44:47 +03:00
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/** The value */
|
2018-04-26 09:44:47 +03:00
|
|
|
cv::Mat value;
|
2018-10-26 10:39:34 +03:00
|
|
|
/** The id **/
|
|
|
|
std::uint16_t id;
|
2018-04-26 09:44:47 +03:00
|
|
|
|
|
|
|
Object *Clone() const {
|
|
|
|
ObjMat *mat = new ObjMat;
|
|
|
|
mat->value = value.clone();
|
2018-10-26 10:39:34 +03:00
|
|
|
mat->id = id;
|
2018-04-26 09:44:47 +03:00
|
|
|
return mat;
|
|
|
|
}
|
2018-07-10 21:05:44 +03:00
|
|
|
|
|
|
|
bool DecValidity() const {
|
|
|
|
return !value.empty();
|
|
|
|
}
|
2018-04-26 09:44:47 +03:00
|
|
|
};
|
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/**
|
|
|
|
* Input & output object of two cv::Mat.
|
|
|
|
*/
|
2018-05-08 06:12:45 +03:00
|
|
|
struct MYNTEYE_API ObjMat2 : public Object {
|
2018-04-26 09:44:47 +03:00
|
|
|
ObjMat2() = default;
|
2018-10-26 10:39:34 +03:00
|
|
|
ObjMat2(const cv::Mat &first, std::uint16_t first_id,
|
|
|
|
const cv::Mat &second, std::uint16_t second_id)
|
|
|
|
: first(first), first_id(first_id),
|
|
|
|
second(second), second_id(second_id) {}
|
2018-04-26 09:44:47 +03:00
|
|
|
|
2018-05-16 05:31:31 +03:00
|
|
|
/** The first value */
|
2018-04-26 09:44:47 +03:00
|
|
|
cv::Mat first;
|
2018-10-26 10:39:34 +03:00
|
|
|
/** The first id **/
|
|
|
|
std::uint16_t first_id;
|
2018-05-16 05:31:31 +03:00
|
|
|
|
|
|
|
/** The second value */
|
2018-04-26 09:44:47 +03:00
|
|
|
cv::Mat second;
|
2018-10-26 10:39:34 +03:00
|
|
|
/** The second id **/
|
|
|
|
std::uint16_t second_id;
|
2018-04-26 09:44:47 +03:00
|
|
|
|
|
|
|
Object *Clone() const {
|
|
|
|
ObjMat2 *mat2 = new ObjMat2;
|
|
|
|
mat2->first = first.clone();
|
2018-10-26 10:39:34 +03:00
|
|
|
mat2->first_id = first_id;
|
2018-04-26 09:44:47 +03:00
|
|
|
mat2->second = second.clone();
|
2018-10-26 10:39:34 +03:00
|
|
|
mat2->second_id = second_id;
|
2018-04-26 09:44:47 +03:00
|
|
|
return mat2;
|
|
|
|
}
|
2018-07-10 21:05:44 +03:00
|
|
|
|
|
|
|
bool DecValidity() const {
|
|
|
|
return !first.empty() && !second.empty();
|
|
|
|
}
|
2018-04-26 09:44:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
MYNTEYE_END_NAMESPACE
|
|
|
|
|
2018-10-27 16:24:04 +03:00
|
|
|
#endif // MYNTEYE_API_OBJECT_H_
|