Update macros

This commit is contained in:
John Zhao 2018-09-11 10:19:25 +08:00
parent cf9e714626
commit 1b95e376a5
25 changed files with 176 additions and 162 deletions

View File

@ -16,72 +16,70 @@
#pragma once #pragma once
#ifdef _WIN32 #ifdef _WIN32
#define OS_WIN #define MYNTEYE_OS_WIN
#ifdef _WIN64 #ifdef _WIN64
#define OS_WIN64 #define MYNTEYE_OS_WIN64
#else #else
#define OS_WIN32 #define MYNTEYE_OS_WIN32
#endif #endif
#if defined(__MINGW32__) || defined(__MINGW64__) #if defined(__MINGW32__) || defined(__MINGW64__)
#define OS_MINGW #define MYNTEYE_OS_MINGW
#ifdef __MINGW64__ #ifdef __MINGW64__
#define OS_MINGW64 #define MYNTEYE_OS_MINGW64
#else #else
#define OS_MINGW32 #define MYNTEYE_OS_MINGW32
#endif #endif
#elif defined(__CYGWIN__) || defined(__CYGWIN32__) #elif defined(__CYGWIN__) || defined(__CYGWIN32__)
#define OS_CYGWIN #define MYNTEYE_OS_CYGWIN
#endif #endif
#elif __APPLE__ #elif __APPLE__
#include "TargetConditionals.h" #include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR #if TARGET_IPHONE_SIMULATOR
#define OS_IPHONE #define MYNTEYE_OS_IPHONE
#define OS_IPHONE_SIMULATOR #define MYNTEYE_OS_IPHONE_SIMULATOR
#elif TARGET_OS_IPHONE #elif TARGET_OS_IPHONE
#define OS_IPHONE #define MYNTEYE_OS_IPHONE
#elif TARGET_OS_MAC #elif TARGET_OS_MAC
#define OS_MAC #define MYNTEYE_OS_MAC
#else #else
#error "Unknown Apple platform" #error "Unknown Apple platform"
#endif #endif
#elif __ANDROID__ #elif __ANDROID__
#define OS_ANDROID #define MYNTEYE_OS_ANDROID
#elif __linux__ #elif __linux__
#define OS_LINUX #define MYNTEYE_OS_LINUX
#elif __unix__ #elif __unix__
#define OS_UNIX #define MYNTEYE_OS_UNIX
#elif defined(_POSIX_VERSION) #elif defined(_POSIX_VERSION)
#define OS_POSIX #define MYNTEYE_OS_POSIX
#else #else
#error "Unknown compiler" #error "Unknown compiler"
#endif #endif
#ifdef OS_WIN #ifdef MYNTEYE_OS_WIN
#define DECL_EXPORT __declspec(dllexport) #define MYNTEYE_DECL_EXPORT __declspec(dllexport)
#define DECL_IMPORT __declspec(dllimport) #define MYNTEYE_DECL_IMPORT __declspec(dllimport)
#define DECL_HIDDEN #define MYNTEYE_DECL_HIDDEN
#else #else
#define DECL_EXPORT __attribute__((visibility("default"))) #define MYNTEYE_DECL_EXPORT __attribute__((visibility("default")))
#define DECL_IMPORT __attribute__((visibility("default"))) #define MYNTEYE_DECL_IMPORT __attribute__((visibility("default")))
#define DECL_HIDDEN __attribute__((visibility("hidden"))) #define MYNTEYE_DECL_HIDDEN __attribute__((visibility("hidden")))
#endif #endif
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
#define OS_SEP "\\" !defined(MYNTEYE_OS_CYGWIN)
#define MYNTEYE_OS_SEP "\\"
#else #else
#define OS_SEP "/" #define MYNTEYE_OS_SEP "/"
#endif #endif
#define STRINGIFY_HELPER(X) #X #define MYNTEYE_STRINGIFY_HELPER(X) #X
#define STRINGIFY(X) STRINGIFY_HELPER(X) #define MYNTEYE_STRINGIFY(X) MYNTEYE_STRINGIFY_HELPER(X)
#define DISABLE_COPY(Class) \ #define MYNTEYE_DISABLE_COPY(Class) \
Class(const Class &) = delete; \ Class(const Class &) = delete; \
Class &operator=(const Class &) = delete; Class &operator=(const Class &) = delete;
#define UNUSED(x) (void)x; #define MYNTEYE_UNUSED(x) (void)x;
template <typename... T>
void unused(T &&...) {}
#endif // MYNTEYE_GLOBAL_H_ #endif // MYNTEYE_GLOBAL_H_

View File

@ -74,7 +74,7 @@ struct glog_init {
} }
}; };
#define MAX_LOG_LEVEL google::INFO #define MYNTEYE_MAX_LOG_LEVEL google::INFO
#include "mynteye/miniglog.h" #include "mynteye/miniglog.h"

View File

@ -91,14 +91,6 @@
#ifndef MYNTEYE_MINIGLOG_H_ #ifndef MYNTEYE_MINIGLOG_H_
#define MYNTEYE_MINIGLOG_H_ #define MYNTEYE_MINIGLOG_H_
#ifdef ANDROID
# include <android/log.h>
#else
#include <pthread.h>
#include <sys/time.h>
#include <unistd.h>
#endif // ANDROID
#include <algorithm> #include <algorithm>
#include <ctime> #include <ctime>
#include <fstream> #include <fstream>
@ -108,6 +100,18 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "mynteye/global.h"
#if defined(MYNTEYE_OS_ANDROID)
#include <android/log.h>
#elif defined(MYNTEYE_OS_WIN)
#include <Windows.h>
#else
#include <pthread.h>
#include <sys/time.h>
#include <unistd.h>
#endif // ANDROID
// For appropriate definition of CERES_EXPORT macro. // For appropriate definition of CERES_EXPORT macro.
// Modified from ceres miniglog version [begin] ------------------------------- // Modified from ceres miniglog version [begin] -------------------------------
//#include "ceres/internal/port.h" //#include "ceres/internal/port.h"
@ -187,7 +191,7 @@ class CERES_EXPORT MessageLogger {
~MessageLogger() { ~MessageLogger() {
stream_ << "\n"; stream_ << "\n";
#ifdef ANDROID #if defined(MYNTEYE_OS_ANDROID)
static const int android_log_levels[] = { static const int android_log_levels[] = {
ANDROID_LOG_FATAL, // LOG(FATAL) ANDROID_LOG_FATAL, // LOG(FATAL)
ANDROID_LOG_ERROR, // LOG(ERROR) ANDROID_LOG_ERROR, // LOG(ERROR)
@ -362,11 +366,11 @@ class CERES_EXPORT LoggerVoidify {
// LG is a convenient shortcut for LOG(INFO). Its use is in new // LG is a convenient shortcut for LOG(INFO). Its use is in new
// google3 code is discouraged and the following shortcut exists for // google3 code is discouraged and the following shortcut exists for
// backward compatibility with existing code. // backward compatibility with existing code.
#ifdef MAX_LOG_LEVEL #ifdef MYNTEYE_MAX_LOG_LEVEL
# define LOG(n) LOG_IF(n, n <= MAX_LOG_LEVEL) # define LOG(n) LOG_IF(n, n <= MYNTEYE_MAX_LOG_LEVEL)
# define VLOG(n) LOG_IF(n, n <= MAX_LOG_LEVEL) # define VLOG(n) LOG_IF(n, n <= MYNTEYE_MAX_LOG_LEVEL)
# define LG LOG_IF(INFO, INFO <= MAX_LOG_LEVEL) # define LG LOG_IF(INFO, INFO <= MYNTEYE_MAX_LOG_LEVEL)
# define VLOG_IF(n, condition) LOG_IF(n, (n <= MAX_LOG_LEVEL) && condition) # define VLOG_IF(n, condition) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL) && condition)
#else #else
# define LOG(n) MessageLogger((char *)__FILE__, __LINE__, "native", n).stream() // NOLINT # define LOG(n) MessageLogger((char *)__FILE__, __LINE__, "native", n).stream() // NOLINT
# define VLOG(n) MessageLogger((char *)__FILE__, __LINE__, "native", n).stream() // NOLINT # define VLOG(n) MessageLogger((char *)__FILE__, __LINE__, "native", n).stream() // NOLINT
@ -374,11 +378,11 @@ class CERES_EXPORT LoggerVoidify {
# define VLOG_IF(n, condition) LOG_IF(n, condition) # define VLOG_IF(n, condition) LOG_IF(n, condition)
#endif #endif
// Currently, VLOG is always on for levels below MAX_LOG_LEVEL. // Currently, VLOG is always on for levels below MYNTEYE_MAX_LOG_LEVEL.
#ifndef MAX_LOG_LEVEL #ifndef MYNTEYE_MAX_LOG_LEVEL
# define VLOG_IS_ON(x) (1) # define VLOG_IS_ON(x) (1)
#else #else
# define VLOG_IS_ON(x) (x <= MAX_LOG_LEVEL) # define VLOG_IS_ON(x) (x <= MYNTEYE_MAX_LOG_LEVEL)
#endif #endif
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -21,9 +21,9 @@
# define MYNTEYE_API # define MYNTEYE_API
#else #else
# ifdef MYNTEYE_EXPORTS # ifdef MYNTEYE_EXPORTS
# define MYNTEYE_API DECL_EXPORT # define MYNTEYE_API MYNTEYE_DECL_EXPORT
# else # else
# define MYNTEYE_API DECL_IMPORT # define MYNTEYE_API MYNTEYE_DECL_IMPORT
# endif # endif
#endif #endif
@ -61,4 +61,11 @@ MYNTEYE_API_VERSION_CHECK( \
const char MYNTEYE_SDK_ROOT_DIR[] = "@MYNTEYE_SDK_ROOT_DIR@"; const char MYNTEYE_SDK_ROOT_DIR[] = "@MYNTEYE_SDK_ROOT_DIR@";
const char MYNTEYE_SDK_INSTALL_DIR[] = "@MYNTEYE_SDK_INSTALL_DIR@"; const char MYNTEYE_SDK_INSTALL_DIR[] = "@MYNTEYE_SDK_INSTALL_DIR@";
MYNTEYE_BEGIN_NAMESPACE
template <typename... T>
void UNUSED(T &&...) {}
MYNTEYE_END_NAMESPACE
#endif // MYNTEYE_MYNTEYE_H_ #endif // MYNTEYE_MYNTEYE_H_

View File

@ -29,7 +29,7 @@ class DepthRegion {
* *
*/ */
void OnMouse(const int &event, const int &x, const int &y, const int &flags) { void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
UNUSED(flags) MYNTEYE_UNUSED(flags)
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) { if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
return; return;
} }
@ -161,7 +161,7 @@ int main(int argc, char *argv[]) {
DepthRegion depth_region(3); DepthRegion depth_region(3);
auto depth_info = []( auto depth_info = [](
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) { const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
UNUSED(depth) MYNTEYE_UNUSED(depth)
std::ostringstream os; std::ostringstream os;
os << "depth pos: [" << point.y << ", " << point.x << "]" os << "depth pos: [" << point.y << ", " << point.x << "]"
<< "±" << n << ", unit: mm"; << "±" << n << ", unit: mm";

View File

@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
api->SetStreamCallback( api->SetStreamCallback(
Stream::DEPTH, Stream::DEPTH,
[&depth_count, &depth, &depth_mtx](const api::StreamData &data) { [&depth_count, &depth, &depth_mtx](const api::StreamData &data) {
UNUSED(data) MYNTEYE_UNUSED(data)
++depth_count; ++depth_count;
{ {
std::lock_guard<std::mutex> _(depth_mtx); std::lock_guard<std::mutex> _(depth_mtx);

View File

@ -32,7 +32,7 @@ class DepthRegion {
* *
*/ */
void OnMouse(const int &event, const int &x, const int &y, const int &flags) { void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
UNUSED(flags) MYNTEYE_UNUSED(flags)
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) { if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
return; return;
} }
@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
DepthRegion depth_region(3); DepthRegion depth_region(3);
auto depth_info = []( auto depth_info = [](
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) { const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
UNUSED(depth) MYNTEYE_UNUSED(depth)
std::ostringstream os; std::ostringstream os;
os << "depth pos: [" << point.y << ", " << point.x << "]" os << "depth pos: [" << point.y << ", " << point.x << "]"
<< "±" << n << ", unit: mm"; << "±" << n << ", unit: mm";

View File

@ -157,7 +157,7 @@ int main(int argc, char *argv[]) {
t = static_cast<double>(cv::getTickCount() - t); t = static_cast<double>(cv::getTickCount() - t);
fps = cv::getTickFrequency() / t; fps = cv::getTickFrequency() / t;
} }
UNUSED(fps) MYNTEYE_UNUSED(fps)
uvc::stop_streaming(*device); uvc::stop_streaming(*device);
// cv::destroyAllWindows(); // cv::destroyAllWindows();

View File

@ -31,7 +31,7 @@
#include "internal/dl.h" #include "internal/dl.h"
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM) #if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
#if defined(OS_WIN) #if defined(MYNTEYE_OS_WIN)
#include <windows.h> #include <windows.h>
#endif #endif
#endif #endif
@ -68,7 +68,7 @@ bool dir_exists(const fs::path &p) {
#elif defined(WITH_NATIVE_FILESYSTEM) #elif defined(WITH_NATIVE_FILESYSTEM)
#if defined(OS_WIN) #if defined(MYNTEYE_OS_WIN)
bool file_exists(const std::string &p) { bool file_exists(const std::string &p) {
DWORD attrs = GetFileAttributes(p.c_str()); DWORD attrs = GetFileAttributes(p.c_str());
@ -90,7 +90,7 @@ bool dir_exists(const std::string &p) {
std::vector<std::string> get_plugin_paths() { std::vector<std::string> get_plugin_paths() {
std::string info_path(MYNTEYE_SDK_INSTALL_DIR); std::string info_path(MYNTEYE_SDK_INSTALL_DIR);
info_path.append(OS_SEP "share" OS_SEP "mynteye" OS_SEP "build.info"); info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info");
cv::FileStorage fs(info_path, cv::FileStorage::READ); cv::FileStorage fs(info_path, cv::FileStorage::READ);
if (!fs.isOpened()) { if (!fs.isOpened()) {
@ -187,13 +187,13 @@ std::vector<std::string> get_plugin_paths() {
std::vector<std::string> dirs{MYNTEYE_SDK_ROOT_DIR, MYNTEYE_SDK_INSTALL_DIR}; std::vector<std::string> dirs{MYNTEYE_SDK_ROOT_DIR, MYNTEYE_SDK_INSTALL_DIR};
for (auto &&plat : plats) { for (auto &&plat : plats) {
for (auto &&dir : dirs) { for (auto &&dir : dirs) {
auto &&plat_dir = dir + OS_SEP "plugins" + OS_SEP + plat; auto &&plat_dir = dir + MYNTEYE_OS_SEP "plugins" + MYNTEYE_OS_SEP + plat;
// VLOG(2) << "plat_dir: " << plat_dir; // VLOG(2) << "plat_dir: " << plat_dir;
if (!dir_exists(plat_dir)) if (!dir_exists(plat_dir))
continue; continue;
for (auto &&name : names) { for (auto &&name : names) {
// VLOG(2) << " name: " << name; // VLOG(2) << " name: " << name;
auto &&path = plat_dir + OS_SEP + name; auto &&path = plat_dir + MYNTEYE_OS_SEP + name;
if (!file_exists(path)) if (!file_exists(path))
continue; continue;
paths.push_back(path); paths.push_back(path);

View File

@ -53,8 +53,8 @@ class MYNTEYE_API Plugin {
* @return `true` if you process rectify. * @return `true` if you process rectify.
*/ */
virtual bool OnRectifyProcess(Object *const in, Object *const out) { virtual bool OnRectifyProcess(Object *const in, Object *const out) {
UNUSED(in) MYNTEYE_UNUSED(in)
UNUSED(out) MYNTEYE_UNUSED(out)
return false; return false;
} }
@ -65,8 +65,8 @@ class MYNTEYE_API Plugin {
* @return `true` if you process disparity. * @return `true` if you process disparity.
*/ */
virtual bool OnDisparityProcess(Object *const in, Object *const out) { virtual bool OnDisparityProcess(Object *const in, Object *const out) {
UNUSED(in) MYNTEYE_UNUSED(in)
UNUSED(out) MYNTEYE_UNUSED(out)
return false; return false;
} }
@ -78,8 +78,8 @@ class MYNTEYE_API Plugin {
*/ */
virtual bool OnDisparityNormalizedProcess( virtual bool OnDisparityNormalizedProcess(
Object *const in, Object *const out) { Object *const in, Object *const out) {
UNUSED(in) MYNTEYE_UNUSED(in)
UNUSED(out) MYNTEYE_UNUSED(out)
return false; return false;
} }
@ -90,8 +90,8 @@ class MYNTEYE_API Plugin {
* @return `true` if you process points. * @return `true` if you process points.
*/ */
virtual bool OnPointsProcess(Object *const in, Object *const out) { virtual bool OnPointsProcess(Object *const in, Object *const out) {
UNUSED(in) MYNTEYE_UNUSED(in)
UNUSED(out) MYNTEYE_UNUSED(out)
return false; return false;
} }
@ -102,8 +102,8 @@ class MYNTEYE_API Plugin {
* @return `true` if you process depth. * @return `true` if you process depth.
*/ */
virtual bool OnDepthProcess(Object *const in, Object *const out) { virtual bool OnDepthProcess(Object *const in, Object *const out) {
UNUSED(in) MYNTEYE_UNUSED(in)
UNUSED(out) MYNTEYE_UNUSED(out)
return false; return false;
} }

View File

@ -40,7 +40,7 @@ Object *DepthProcessor::OnCreateOutput() {
bool DepthProcessor::OnProcess( bool DepthProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in); const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
cv::Mat channels[3 /*input->value.channels()*/]; cv::Mat channels[3 /*input->value.channels()*/];

View File

@ -44,7 +44,7 @@ Object *DisparityNormalizedProcessor::OnCreateOutput() {
bool DisparityNormalizedProcessor::OnProcess( bool DisparityNormalizedProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in); const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1); cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1);

View File

@ -74,7 +74,7 @@ Object *DisparityProcessor::OnCreateOutput() {
bool DisparityProcessor::OnProcess( bool DisparityProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in); const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);

View File

@ -42,7 +42,7 @@ Object *PointsProcessor::OnCreateOutput() {
bool PointsProcessor::OnProcess( bool PointsProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in); const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
cv::reprojectImageTo3D(input->value, output->value, Q_, true); cv::reprojectImageTo3D(input->value, output->value, Q_, true);

View File

@ -49,7 +49,7 @@ Object *RectifyProcessor::OnCreateOutput() {
bool RectifyProcessor::OnProcess( bool RectifyProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in); const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat2 *output = Object::Cast<ObjMat2>(out); ObjMat2 *output = Object::Cast<ObjMat2>(out);
cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR); cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR);

View File

@ -498,7 +498,7 @@ void Synthetic::ProcessNativeStream(
bool Synthetic::OnRectifyProcess( bool Synthetic::OnRectifyProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnRectifyProcess(in, out)) { if (plugin_ && plugin_->OnRectifyProcess(in, out)) {
return true; return true;
} }
@ -508,7 +508,7 @@ bool Synthetic::OnRectifyProcess(
bool Synthetic::OnDisparityProcess( bool Synthetic::OnDisparityProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDisparityProcess(in, out)) { if (plugin_ && plugin_->OnDisparityProcess(in, out)) {
return true; return true;
} }
@ -517,7 +517,7 @@ bool Synthetic::OnDisparityProcess(
bool Synthetic::OnDisparityNormalizedProcess( bool Synthetic::OnDisparityNormalizedProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDisparityNormalizedProcess(in, out)) { if (plugin_ && plugin_->OnDisparityNormalizedProcess(in, out)) {
return true; return true;
} }
@ -526,7 +526,7 @@ bool Synthetic::OnDisparityNormalizedProcess(
bool Synthetic::OnPointsProcess( bool Synthetic::OnPointsProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnPointsProcess(in, out)) { if (plugin_ && plugin_->OnPointsProcess(in, out)) {
return true; return true;
} }
@ -535,7 +535,7 @@ bool Synthetic::OnPointsProcess(
bool Synthetic::OnDepthProcess( bool Synthetic::OnDepthProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent) MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDepthProcess(in, out)) { if (plugin_ && plugin_->OnDepthProcess(in, out)) {
return true; return true;
} }

View File

@ -453,7 +453,7 @@ std::size_t from_data(
} }
i += 40; i += 40;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }
@ -484,7 +484,7 @@ std::size_t from_data(
} }
i += 24; i += 24;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }
@ -505,7 +505,7 @@ std::size_t from_data(
} }
i += 24; i += 24;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }
@ -684,7 +684,7 @@ std::size_t to_data(
_to_data(info->nominal_baseline, data + i); _to_data(info->nominal_baseline, data + i);
i += 2; i += 2;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
// others // others
std::size_t size = i - 3; std::size_t size = i - 3;
@ -725,7 +725,7 @@ std::size_t to_data(
} }
i += 40; i += 40;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }
@ -756,7 +756,7 @@ std::size_t to_data(
} }
i += 24; i += 24;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }
@ -777,7 +777,7 @@ std::size_t to_data(
} }
i += 24; i += 24;
UNUSED(spec_version) MYNTEYE_UNUSED(spec_version)
return i; return i;
} }

View File

@ -17,7 +17,8 @@
MYNTEYE_BEGIN_NAMESPACE MYNTEYE_BEGIN_NAMESPACE
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
!defined(MYNTEYE_OS_CYGWIN)
namespace { namespace {
@ -62,7 +63,8 @@ bool DL::Open(const char *filename) {
// Close(); // Close();
return false; return false;
} }
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
!defined(MYNTEYE_OS_CYGWIN)
handle = LoadLibraryEx(filename, nullptr, 0); handle = LoadLibraryEx(filename, nullptr, 0);
#else #else
handle = dlopen(filename, RTLD_LAZY); handle = dlopen(filename, RTLD_LAZY);
@ -84,7 +86,7 @@ void *DL::Sym(const char *symbol) {
VLOG(2) << "Not opened, do nothing"; VLOG(2) << "Not opened, do nothing";
return nullptr; return nullptr;
} }
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && !defined(MYNTEYE_OS_CYGWIN)
void *f = GetProcAddress(handle, symbol); void *f = GetProcAddress(handle, symbol);
if (f == nullptr) { if (f == nullptr) {
VLOG(2) << "Load symbol failed: " << symbol; VLOG(2) << "Load symbol failed: " << symbol;
@ -106,7 +108,7 @@ int DL::Close() {
if (handle == nullptr) { if (handle == nullptr) {
VLOG(2) << "Not opened, do nothing"; VLOG(2) << "Not opened, do nothing";
} else { } else {
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && !defined(MYNTEYE_OS_CYGWIN)
ret = FreeLibrary(handle) ? 0 : 1; ret = FreeLibrary(handle) ? 0 : 1;
#else #else
ret = dlclose(handle); ret = dlclose(handle);
@ -117,7 +119,7 @@ int DL::Close() {
} }
const char *DL::Error() { const char *DL::Error() {
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && !defined(MYNTEYE_OS_CYGWIN)
return GetLastErrorAsString().c_str(); return GetLastErrorAsString().c_str();
#else #else
return dlerror(); return dlerror();

View File

@ -17,7 +17,8 @@
#include "mynteye/mynteye.h" #include "mynteye/mynteye.h"
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
!defined(MYNTEYE_OS_CYGWIN)
#include <Windows.h> #include <Windows.h>
#else #else
#include <dlfcn.h> #include <dlfcn.h>
@ -25,7 +26,8 @@
MYNTEYE_BEGIN_NAMESPACE MYNTEYE_BEGIN_NAMESPACE
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
!defined(MYNTEYE_OS_CYGWIN)
using DLLIB = HMODULE; using DLLIB = HMODULE;
#else #else
using DLLIB = void *; using DLLIB = void *;

View File

@ -15,7 +15,8 @@
#include "mynteye/logger.h" #include "mynteye/logger.h"
#if defined(OS_WIN) && !defined(OS_MINGW) && !defined(OS_CYGWIN) #if defined(MYNTEYE_OS_WIN) && !defined(MYNTEYE_OS_MINGW) && \
!defined(MYNTEYE_OS_CYGWIN)
#include <direct.h> #include <direct.h>
#else #else
#include <sys/stat.h> #include <sys/stat.h>
@ -28,9 +29,9 @@ MYNTEYE_BEGIN_NAMESPACE
namespace files { namespace files {
bool _mkdir(const std::string &path) { bool _mkdir(const std::string &path) {
#if defined(OS_MINGW) || defined(OS_CYGWIN) #if defined(MYNTEYE_OS_MINGW) || defined(MYNTEYE_OS_CYGWIN)
const int status = ::mkdir(path.c_str()); const int status = ::mkdir(path.c_str());
#elif defined(OS_WIN) #elif defined(MYNTEYE_OS_WIN)
const int status = ::_mkdir(path.c_str()); const int status = ::_mkdir(path.c_str());
#else #else
const int status = const int status =
@ -51,7 +52,7 @@ bool _mkdir(const std::string &path) {
} }
bool mkdir(const std::string &path) { bool mkdir(const std::string &path) {
auto &&dirs = strings::split(path, OS_SEP); auto &&dirs = strings::split(path, MYNTEYE_OS_SEP);
auto &&size = dirs.size(); auto &&size = dirs.size();
if (size <= 0) if (size <= 0)
return false; return false;
@ -59,7 +60,7 @@ bool mkdir(const std::string &path) {
if (!_mkdir(p)) if (!_mkdir(p))
return false; return false;
for (std::size_t i = 1; i < size; i++) { for (std::size_t i = 1; i < size; i++) {
p.append(OS_SEP).append(dirs[i]); p.append(MYNTEYE_OS_SEP).append(dirs[i]);
if (!_mkdir(p)) if (!_mkdir(p))
return false; return false;
} }

View File

@ -186,7 +186,7 @@ inline std::string to_string(
const system_clock::time_point &t, const std::tm *tm, const system_clock::time_point &t, const std::tm *tm,
const char *fmt = "%F %T", std::int32_t precision = 6) { const char *fmt = "%F %T", std::int32_t precision = 6) {
std::stringstream ss; std::stringstream ss;
#if defined(OS_ANDROID) || defined(OS_LINUX) #if defined(MYNTEYE_OS_ANDROID) || defined(MYNTEYE_OS_LINUX)
char foo[20]; char foo[20];
strftime(foo, sizeof(foo), fmt, tm); strftime(foo, sizeof(foo), fmt, tm);
ss << foo; ss << foo;

View File

@ -113,13 +113,13 @@ int get_product_id(const device &device) {
std::string get_name(const device &device) { std::string get_name(const device &device) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
return ""; return "";
} }
std::string get_video_name(const device &device) { std::string get_video_name(const device &device) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
return ""; return "";
} }
@ -127,21 +127,21 @@ bool pu_control_range(
const device &device, Option option, int32_t *min, int32_t *max, const device &device, Option option, int32_t *min, int32_t *max,
int32_t *def) { int32_t *def) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(option) MYNTEYE_UNUSED(option)
UNUSED(min) MYNTEYE_UNUSED(min)
UNUSED(max) MYNTEYE_UNUSED(max)
UNUSED(def) MYNTEYE_UNUSED(def)
return false; return false;
} }
bool pu_control_query( bool pu_control_query(
const device &device, Option option, pu_query query, int32_t *value) { const device &device, Option option, pu_query query, int32_t *value) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(option) MYNTEYE_UNUSED(option)
UNUSED(query) MYNTEYE_UNUSED(query)
UNUSED(value) MYNTEYE_UNUSED(value)
return false; return false;
} }
@ -149,13 +149,13 @@ bool xu_control_range(
const device &device, const xu &xu, uint8_t selector, uint8_t id, int32_t *min, const device &device, const xu &xu, uint8_t selector, uint8_t id, int32_t *min,
int32_t *max, int32_t *def) { int32_t *max, int32_t *def) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(xu) MYNTEYE_UNUSED(xu)
UNUSED(selector) MYNTEYE_UNUSED(selector)
UNUSED(id) MYNTEYE_UNUSED(id)
UNUSED(min) MYNTEYE_UNUSED(min)
UNUSED(max) MYNTEYE_UNUSED(max)
UNUSED(def) MYNTEYE_UNUSED(def)
return false; return false;
} }
@ -163,12 +163,12 @@ bool xu_control_query(
const device &device, const xu &xu, uint8_t selector, xu_query query, const device &device, const xu &xu, uint8_t selector, xu_query query,
uint16_t size, uint8_t *data) { uint16_t size, uint8_t *data) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(xu) MYNTEYE_UNUSED(xu)
UNUSED(selector) MYNTEYE_UNUSED(selector)
UNUSED(query) MYNTEYE_UNUSED(query)
UNUSED(size) MYNTEYE_UNUSED(size)
UNUSED(data) MYNTEYE_UNUSED(data)
return false; return false;
} }
@ -176,23 +176,23 @@ void set_device_mode(
device &device, int width, int height, int fourcc, int fps, // NOLINT device &device, int width, int height, int fourcc, int fps, // NOLINT
video_channel_callback callback) { video_channel_callback callback) {
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(width) MYNTEYE_UNUSED(width)
UNUSED(height) MYNTEYE_UNUSED(height)
UNUSED(fourcc) MYNTEYE_UNUSED(fourcc)
UNUSED(fps) MYNTEYE_UNUSED(fps)
UNUSED(callback) MYNTEYE_UNUSED(callback)
} }
void start_streaming(device &device, int num_transfer_bufs) { // NOLINT void start_streaming(device &device, int num_transfer_bufs) { // NOLINT
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
UNUSED(num_transfer_bufs) MYNTEYE_UNUSED(num_transfer_bufs)
} }
void stop_streaming(device &device) { // NOLINT void stop_streaming(device &device) { // NOLINT
// TODO(JohnZhao) // TODO(JohnZhao)
UNUSED(device) MYNTEYE_UNUSED(device)
} }
} // namespace uvc } // namespace uvc

View File

@ -66,7 +66,7 @@ void Dataset::SaveStreamData(
<< std::endl; << std::endl;
if (data.frame) { if (data.frame) {
std::stringstream ss; std::stringstream ss;
ss << writer->outdir << OS_SEP << std::dec ss << writer->outdir << MYNTEYE_OS_SEP << std::dec
<< std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png"; << std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png";
cv::Mat img( cv::Mat img(
data.frame->height(), data.frame->width(), CV_8UC1, data.frame->data()); data.frame->height(), data.frame->width(), CV_8UC1, data.frame->data());
@ -94,15 +94,15 @@ Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) {
writer_t writer = std::make_shared<Writer>(); writer_t writer = std::make_shared<Writer>();
switch (stream) { switch (stream) {
case Stream::LEFT: { case Stream::LEFT: {
writer->outdir = outdir_ + OS_SEP "left"; writer->outdir = outdir_ + MYNTEYE_OS_SEP "left";
} break; } break;
case Stream::RIGHT: { case Stream::RIGHT: {
writer->outdir = outdir_ + OS_SEP "right"; writer->outdir = outdir_ + MYNTEYE_OS_SEP "right";
} break; } break;
default: default:
LOG(FATAL) << "Unsupported stream: " << stream; LOG(FATAL) << "Unsupported stream: " << stream;
} }
writer->outfile = writer->outdir + OS_SEP "stream.txt"; writer->outfile = writer->outdir + MYNTEYE_OS_SEP "stream.txt";
files::mkdir(writer->outdir); files::mkdir(writer->outdir);
writer->ofs.open(writer->outfile, std::ofstream::out); writer->ofs.open(writer->outfile, std::ofstream::out);
@ -119,7 +119,7 @@ Dataset::writer_t Dataset::GetMotionWriter() {
if (motion_writer_ == nullptr) { if (motion_writer_ == nullptr) {
writer_t writer = std::make_shared<Writer>(); writer_t writer = std::make_shared<Writer>();
writer->outdir = outdir_; writer->outdir = outdir_;
writer->outfile = writer->outdir + OS_SEP "motion.txt"; writer->outfile = writer->outdir + MYNTEYE_OS_SEP "motion.txt";
files::mkdir(writer->outdir); files::mkdir(writer->outdir);
writer->ofs.open(writer->outfile, std::ofstream::out); writer->ofs.open(writer->outfile, std::ofstream::out);

View File

@ -208,19 +208,19 @@ void DeviceWriter::SaveAllInfos(const std::string &dir) {
if (!files::mkdir(dir)) { if (!files::mkdir(dir)) {
LOG(FATAL) << "Create directory failed: " << dir; LOG(FATAL) << "Create directory failed: " << dir;
} }
SaveDeviceInfo(*device_->GetInfo(), dir + OS_SEP "device.info"); SaveDeviceInfo(*device_->GetInfo(), dir + MYNTEYE_OS_SEP "device.info");
SaveImgParams( SaveImgParams(
{false, device_->GetIntrinsics(Stream::LEFT), {false, device_->GetIntrinsics(Stream::LEFT),
device_->GetIntrinsics(Stream::RIGHT), device_->GetIntrinsics(Stream::RIGHT),
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT)}, device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT)},
dir + OS_SEP "img.params"); dir + MYNTEYE_OS_SEP "img.params");
auto &&m_in = device_->GetMotionIntrinsics(); auto &&m_in = device_->GetMotionIntrinsics();
SaveImuParams( SaveImuParams(
{ {
false, m_in.accel, m_in.gyro, false, m_in.accel, m_in.gyro,
device_->GetMotionExtrinsics(Stream::LEFT), device_->GetMotionExtrinsics(Stream::LEFT),
}, },
dir + OS_SEP "imu.params"); dir + MYNTEYE_OS_SEP "imu.params");
} }
namespace { namespace {

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
if (!device) if (!device)
return 1; return 1;
dir.append(OS_SEP "SN").append(device->GetInfo()->serial_number); dir.append(MYNTEYE_OS_SEP "SN").append(device->GetInfo()->serial_number);
tools::DeviceWriter writer(device); tools::DeviceWriter writer(device);
writer.SaveAllInfos(dir); writer.SaveAllInfos(dir);