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

View File

@ -91,14 +91,6 @@
#ifndef 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 <ctime>
#include <fstream>
@ -108,6 +100,18 @@
#include <string>
#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.
// Modified from ceres miniglog version [begin] -------------------------------
//#include "ceres/internal/port.h"
@ -187,7 +191,7 @@ class CERES_EXPORT MessageLogger {
~MessageLogger() {
stream_ << "\n";
#ifdef ANDROID
#if defined(MYNTEYE_OS_ANDROID)
static const int android_log_levels[] = {
ANDROID_LOG_FATAL, // LOG(FATAL)
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
// google3 code is discouraged and the following shortcut exists for
// backward compatibility with existing code.
#ifdef MAX_LOG_LEVEL
# define LOG(n) LOG_IF(n, n <= MAX_LOG_LEVEL)
# define VLOG(n) LOG_IF(n, n <= MAX_LOG_LEVEL)
# define LG LOG_IF(INFO, INFO <= MAX_LOG_LEVEL)
# define VLOG_IF(n, condition) LOG_IF(n, (n <= MAX_LOG_LEVEL) && condition)
#ifdef MYNTEYE_MAX_LOG_LEVEL
# define LOG(n) LOG_IF(n, n <= MYNTEYE_MAX_LOG_LEVEL)
# define VLOG(n) LOG_IF(n, n <= MYNTEYE_MAX_LOG_LEVEL)
# define LG LOG_IF(INFO, INFO <= MYNTEYE_MAX_LOG_LEVEL)
# define VLOG_IF(n, condition) LOG_IF(n, (n <= MYNTEYE_MAX_LOG_LEVEL) && condition)
#else
# define LOG(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)
#endif
// Currently, VLOG is always on for levels below MAX_LOG_LEVEL.
#ifndef MAX_LOG_LEVEL
// Currently, VLOG is always on for levels below MYNTEYE_MAX_LOG_LEVEL.
#ifndef MYNTEYE_MAX_LOG_LEVEL
# define VLOG_IS_ON(x) (1)
#else
# define VLOG_IS_ON(x) (x <= MAX_LOG_LEVEL)
# define VLOG_IS_ON(x) (x <= MYNTEYE_MAX_LOG_LEVEL)
#endif
#ifndef NDEBUG

View File

@ -21,9 +21,9 @@
# define MYNTEYE_API
#else
# ifdef MYNTEYE_EXPORTS
# define MYNTEYE_API DECL_EXPORT
# define MYNTEYE_API MYNTEYE_DECL_EXPORT
# else
# define MYNTEYE_API DECL_IMPORT
# define MYNTEYE_API MYNTEYE_DECL_IMPORT
# endif
#endif
@ -61,4 +61,11 @@ MYNTEYE_API_VERSION_CHECK( \
const char MYNTEYE_SDK_ROOT_DIR[] = "@MYNTEYE_SDK_ROOT_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_

View File

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

View File

@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
api->SetStreamCallback(
Stream::DEPTH,
[&depth_count, &depth, &depth_mtx](const api::StreamData &data) {
UNUSED(data)
MYNTEYE_UNUSED(data)
++depth_count;
{
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) {
UNUSED(flags)
MYNTEYE_UNUSED(flags)
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
return;
}
@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
DepthRegion depth_region(3);
auto depth_info = [](
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
UNUSED(depth)
MYNTEYE_UNUSED(depth)
std::ostringstream os;
os << "depth pos: [" << point.y << ", " << point.x << "]"
<< "±" << n << ", unit: mm";

View File

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

View File

@ -31,7 +31,7 @@
#include "internal/dl.h"
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
#if defined(OS_WIN)
#if defined(MYNTEYE_OS_WIN)
#include <windows.h>
#endif
#endif
@ -68,7 +68,7 @@ bool dir_exists(const fs::path &p) {
#elif defined(WITH_NATIVE_FILESYSTEM)
#if defined(OS_WIN)
#if defined(MYNTEYE_OS_WIN)
bool file_exists(const std::string &p) {
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::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);
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};
for (auto &&plat : plats) {
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;
if (!dir_exists(plat_dir))
continue;
for (auto &&name : names) {
// VLOG(2) << " name: " << name;
auto &&path = plat_dir + OS_SEP + name;
auto &&path = plat_dir + MYNTEYE_OS_SEP + name;
if (!file_exists(path))
continue;
paths.push_back(path);

View File

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

View File

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

View File

@ -44,7 +44,7 @@ Object *DisparityNormalizedProcessor::OnCreateOutput() {
bool DisparityNormalizedProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
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(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat *output = Object::Cast<ObjMat>(out);

View File

@ -42,7 +42,7 @@ Object *PointsProcessor::OnCreateOutput() {
bool PointsProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(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);

View File

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

View File

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

View File

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

View File

@ -17,7 +17,8 @@
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 {
@ -62,7 +63,8 @@ bool DL::Open(const char *filename) {
// Close();
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);
#else
handle = dlopen(filename, RTLD_LAZY);
@ -84,7 +86,7 @@ void *DL::Sym(const char *symbol) {
VLOG(2) << "Not opened, do nothing";
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);
if (f == nullptr) {
VLOG(2) << "Load symbol failed: " << symbol;
@ -106,7 +108,7 @@ int DL::Close() {
if (handle == nullptr) {
VLOG(2) << "Not opened, do nothing";
} 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;
#else
ret = dlclose(handle);
@ -117,7 +119,7 @@ int DL::Close() {
}
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();
#else
return dlerror();

View File

@ -17,7 +17,8 @@
#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>
#else
#include <dlfcn.h>
@ -25,7 +26,8 @@
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;
#else
using DLLIB = void *;

View File

@ -15,7 +15,8 @@
#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>
#else
#include <sys/stat.h>
@ -28,9 +29,9 @@ MYNTEYE_BEGIN_NAMESPACE
namespace files {
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());
#elif defined(OS_WIN)
#elif defined(MYNTEYE_OS_WIN)
const int status = ::_mkdir(path.c_str());
#else
const int status =
@ -51,7 +52,7 @@ 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();
if (size <= 0)
return false;
@ -59,7 +60,7 @@ bool mkdir(const std::string &path) {
if (!_mkdir(p))
return false;
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))
return false;
}

View File

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

View File

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

View File

@ -66,7 +66,7 @@ void Dataset::SaveStreamData(
<< std::endl;
if (data.frame) {
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";
cv::Mat img(
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>();
switch (stream) {
case Stream::LEFT: {
writer->outdir = outdir_ + OS_SEP "left";
writer->outdir = outdir_ + MYNTEYE_OS_SEP "left";
} break;
case Stream::RIGHT: {
writer->outdir = outdir_ + OS_SEP "right";
writer->outdir = outdir_ + MYNTEYE_OS_SEP "right";
} break;
default:
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);
writer->ofs.open(writer->outfile, std::ofstream::out);
@ -119,7 +119,7 @@ Dataset::writer_t Dataset::GetMotionWriter() {
if (motion_writer_ == nullptr) {
writer_t writer = std::make_shared<Writer>();
writer->outdir = outdir_;
writer->outfile = writer->outdir + OS_SEP "motion.txt";
writer->outfile = writer->outdir + MYNTEYE_OS_SEP "motion.txt";
files::mkdir(writer->outdir);
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)) {
LOG(FATAL) << "Create directory failed: " << dir;
}
SaveDeviceInfo(*device_->GetInfo(), dir + OS_SEP "device.info");
SaveDeviceInfo(*device_->GetInfo(), dir + MYNTEYE_OS_SEP "device.info");
SaveImgParams(
{false, device_->GetIntrinsics(Stream::LEFT),
device_->GetIntrinsics(Stream::RIGHT),
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT)},
dir + OS_SEP "img.params");
dir + MYNTEYE_OS_SEP "img.params");
auto &&m_in = device_->GetMotionIntrinsics();
SaveImuParams(
{
false, m_in.accel, m_in.gyro,
device_->GetMotionExtrinsics(Stream::LEFT),
},
dir + OS_SEP "imu.params");
dir + MYNTEYE_OS_SEP "imu.params");
}
namespace {

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
if (!device)
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);
writer.SaveAllInfos(dir);