Make build on win

This commit is contained in:
John Zhao 2018-04-23 23:11:11 +08:00
parent 145046249d
commit 9cf58f6e70
21 changed files with 317 additions and 45 deletions

View File

@ -2,12 +2,19 @@ cmake_minimum_required(VERSION 3.0)
project(mynteye VERSION 2.0.0 LANGUAGES C CXX)
include(cmake/Common.cmake)
# options
# flags
if(OS_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
include(cmake/DetectCXX11.cmake)
@ -41,7 +48,7 @@ configure_file(
# targets
include(cmake/Common.cmake)
add_definitions(-DMYNTEYE_EXPORTS)
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
set_outdir(

View File

@ -79,7 +79,15 @@ test: install
install: build
@$(call echo,Make $@)
ifeq ($(HOST_OS),Win)
ifneq ($(HOST_NAME),MinGW)
@cd ./_build; msbuild.exe INSTALL.vcxproj /property:Configuration=Release
else
@cd ./_build; make install
endif
else
@cd ./_build; make install
endif
.PHONY: install
@ -103,7 +111,11 @@ tools: install
ros: install
@$(call echo,Make $@)
ifeq ($(HOST_OS),Win)
$(error "Can't make ros on win")
else
@cd ./wrappers/ros && catkin_make
endif
.PHONY: ros

View File

@ -793,6 +793,7 @@ WARN_LOGFILE =
INPUT = mainpage.md \
guides.md \
guide_build_linux.md \
guide_build_win.md \
guide_samples.md \
guide_tools.md \
guide_log.md \

View File

@ -1,5 +1,7 @@
# 编译 on Linux {#guide_build_linux}
> Ubuntu 16.04, Ubuntu 14.04
## 获取代码
```bash

View File

@ -0,0 +1,103 @@
# 编译 on Windows {#guide_build_win}
> Windows 10
## 前提条件
* [Git](https://git-scm.com/downloads),用于获取代码。
* [CMake](https://cmake.org/download/),用于构建编译。
* [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html),用于生成文档。
最终命令提示符Command Prompt, cmd里可找到如下命令
```cmd
>cmake --version
cmake version 3.10.1
>git --version
git version 2.11.1.windows.1
>doxygen --version
1.8.13
```
* [Visual Studio](https://www.visualstudio.com/)
* [Visual Studio 2015](https://my.visualstudio.com/Downloads?q=Visual Studio 2015)
* [Visual Studio 2017](https://my.visualstudio.com/Downloads?q=Visual Studio 2017)
* [Windows 10 SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk)
以 Visual Studio 2015 举例,请在系统环境变量 `PATH` 里添加上如下路径:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
C:\Program Files (x86)\MSBuild\14.0\Bin
最终命令提示符Command Prompt, cmd里可找到如下命令
```cmd
>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
>link
Microsoft (R) Incremental Linker Version 14.00.24215.1
>lib
Microsoft (R) Library Manager Version 14.00.24215.1
>msbuild
Microsoft (R) 生成引擎版本 14.0.25420.1
```
* [MSYS2](http://www.msys2.org/)
* [国内镜像](https://lug.ustc.edu.cn/wiki/mirrors/help/msys2)
* [pacman](https://wiki.archlinux.org/index.php/pacman)
打开 MSYS2 MSYS ,然后执行:
```msys
$ pacman -Syu
$ pacman -S make
```
并在系统环境变量 `PATH` 里添加上如下路径:
C:\msys64\usr\bin
最终命令提示符Command Prompt, cmd里可找到如下命令
```cmd
>make --version
GNU Make 4.2.1
```
## 获取代码
```cmd
>git clone https://github.com/slightech/MYNT-EYE-SDK-2.git
```
## 准备依赖
```cmd
>cd mynt-eye-sdk-2
>make init
Make init
Init deps
Install cmd: pacman -S
Install deps: git clang-format
pacman -S clang-format (not exists)
error: target not found: clang-format
pip install --upgrade autopep8 cpplint pylint requests
...
Init git hooks
ERROR: clang-format-diff is not installed!
Expect cmake version >= 3.0
cmake version 3.10.1
How to upgrade cmake in Ubuntu
https://askubuntu.com/questions/829310/how-to-upgrade-cmake-in-ubuntu
```
## 编译代码
```cmd
>make install
```

View File

@ -12,6 +12,12 @@
* [OpenCV](https://opencv.org/),用于显示图像。
<!--
```cmd
>set OpenCV_DIR=C:\opencv
```
-->
## 编译
```bash

View File

@ -1,6 +1,7 @@
# SDK 指导 {#guides}
* @subpage guide_build_linux
* @subpage guide_build_win
* @subpage guide_samples
* @subpage guide_tools
* @subpage guide_log

View File

@ -16,7 +16,7 @@ MYNTEYE_BEGIN_NAMESPACE
namespace device {
class Frame {
class MYNTEYE_API Frame {
public:
using data_t = std::vector<std::uint8_t>;

View File

@ -166,7 +166,7 @@ enum class Source : std::uint8_t {
};
#define MYNTEYE_ENUM_HELPERS(TYPE) \
const char *to_string(const TYPE &value); \
MYNTEYE_API const char *to_string(const TYPE &value); \
inline bool is_valid(const TYPE &value) { \
using utype = std::underlying_type<TYPE>::type; \
utype val = static_cast<utype>(value); \
@ -209,13 +209,13 @@ enum class Format : std::uint32_t {
#undef MYNTEYE_FOURCC
const char *to_string(const Format &value);
MYNTEYE_API const char *to_string(const Format &value);
inline std::ostream &operator<<(std::ostream &os, const Format &value) {
return os << to_string(value);
}
std::size_t bytes_per_pixel(const Format &value);
MYNTEYE_API std::size_t bytes_per_pixel(const Format &value);
/**
* Stream request.
@ -239,6 +239,7 @@ struct MYNTEYE_API StreamRequest {
}
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
/**
@ -269,6 +270,7 @@ struct MYNTEYE_API Intrinsics {
double coeffs[5];
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const Intrinsics &in);
/**
@ -291,6 +293,7 @@ struct MYNTEYE_API ImuIntrinsics {
double bias[3];
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
/**
@ -302,6 +305,7 @@ struct MYNTEYE_API MotionIntrinsics {
ImuIntrinsics gyro;
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in);
/**
@ -313,6 +317,7 @@ struct MYNTEYE_API Extrinsics {
double translation[3]; /**< translation vector */
};
MYNTEYE_API
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
/**

View File

@ -13,7 +13,7 @@ class Device;
namespace device {
/** Detecting MYNT EYE devices and prompt user to select one */
std::shared_ptr<Device> select();
MYNTEYE_API std::shared_ptr<Device> select();
} // namespace device

View File

@ -4,10 +4,17 @@ project(mynteye_samples VERSION 2.0.0 LANGUAGES C CXX)
get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
include(${PRO_DIR}/cmake/Common.cmake)
# flags
if(OS_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
include(${PRO_DIR}/cmake/DetectCXX11.cmake)
@ -36,8 +43,6 @@ message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
# targets
include(${PRO_DIR}/cmake/Common.cmake)
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
# samples above device layer

View File

@ -17,7 +17,7 @@ struct context;
class Device;
class Context {
class MYNTEYE_API Context {
public:
Context();
~Context();

View File

@ -33,7 +33,7 @@ class Channels;
class Motions;
class Streams;
class Device {
class MYNTEYE_API Device {
public:
using stream_callback_t = device::StreamCallback;
using motion_callback_t = device::MotionCallback;

View File

@ -21,7 +21,7 @@ struct xu;
} // namespace uvc
class Channels {
class MYNTEYE_API Channels {
public:
typedef enum Channel {
CHANNEL_CAM_CTRL = 0x0100,

View File

@ -10,7 +10,7 @@ MYNTEYE_BEGIN_NAMESPACE
namespace files {
bool mkdir(const std::string &path);
MYNTEYE_API bool mkdir(const std::string &path);
} // namespace files

View File

@ -11,7 +11,7 @@
MYNTEYE_BEGIN_NAMESPACE
class strings_error : public std::runtime_error {
class MYNTEYE_API strings_error : public std::runtime_error {
public:
explicit strings_error(const std::string &what_arg) noexcept
: std::runtime_error(std::move(what_arg)) {}
@ -21,17 +21,21 @@ class strings_error : public std::runtime_error {
namespace strings {
MYNTEYE_API
int hex2int(const std::string &text);
MYNTEYE_API
bool starts_with(const std::string &text, const std::string &prefix);
MYNTEYE_API
std::vector<std::string> split(
const std::string &text, const std::string &delimiters);
void ltrim(std::string &s); // NOLINT
void rtrim(std::string &s); // NOLINT
void trim(std::string &s); // NOLINT
MYNTEYE_API void ltrim(std::string &s); // NOLINT
MYNTEYE_API void rtrim(std::string &s); // NOLINT
MYNTEYE_API void trim(std::string &s); // NOLINT
MYNTEYE_API
std::string trim_copy(const std::string &text);
} // namespace strings

View File

@ -28,7 +28,7 @@ MYNTEYE_BEGIN_NAMESPACE
/**
* Version.
*/
class Version {
class MYNTEYE_API Version {
public:
using size_t = std::size_t;
using value_t = std::uint8_t;
@ -77,7 +77,7 @@ class Version {
/**
* Hardware version.
*/
class HardwareVersion : public Version {
class MYNTEYE_API HardwareVersion : public Version {
public:
using flag_t = std::bitset<8>;
@ -93,7 +93,7 @@ class HardwareVersion : public Version {
/**
* Type.
*/
class Type {
class MYNTEYE_API Type {
public:
using size_t = std::size_t;
using value_t = std::uint16_t;
@ -115,7 +115,7 @@ class Type {
* @ingroup datatypes
* Device infomation.
*/
struct DeviceInfo {
struct MYNTEYE_API DeviceInfo {
std::string name;
std::string serial_number;
Version firmware_version;

116
src/uvc/uvc-wmf.cc Normal file
View File

@ -0,0 +1,116 @@
#include "uvc/uvc.h" // NOLINT
#include <glog/logging.h>
MYNTEYE_BEGIN_NAMESPACE
namespace uvc {
struct context {
context() {
VLOG(2) << __func__;
}
~context() {
VLOG(2) << __func__;
}
};
struct device {
const std::shared_ptr<context> parent;
int vid, pid;
device(std::shared_ptr<context> parent) : parent(parent) {
VLOG(2) << __func__;
}
~device() {
VLOG(2) << __func__;
}
};
std::shared_ptr<context> create_context() {
return std::make_shared<context>();
}
std::vector<std::shared_ptr<device>> query_devices(
std::shared_ptr<context> context) {
std::vector<std::shared_ptr<device>> devices;
UNUSED(context)
return devices;
}
int get_vendor_id(const device &device) {
return device.vid;
}
int get_product_id(const device &device) {
return device.pid;
}
std::string get_name(const device &device) {
UNUSED(device)
return "";
}
std::string get_video_name(const device &device) {
UNUSED(device)
return "";
}
bool pu_control_range(
const device &device, Option option, int32_t *min, int32_t *max,
int32_t *def) {
UNUSED(device)
UNUSED(option)
UNUSED(min)
UNUSED(max)
UNUSED(def)
return false;
}
bool pu_control_query(
const device &device, Option option, pu_query query, int32_t *value) {
UNUSED(device)
UNUSED(option)
UNUSED(query)
UNUSED(value)
return false;
}
bool xu_control_query(
const device &device, const xu &xu, uint8_t selector, xu_query query,
uint16_t size, uint8_t *data) {
UNUSED(device)
UNUSED(xu)
UNUSED(selector)
UNUSED(query)
UNUSED(size)
UNUSED(data)
return false;
}
void set_device_mode(
device &device, int width, int height, int fourcc, int fps, // NOLINT
video_channel_callback callback) {
UNUSED(device)
UNUSED(width)
UNUSED(height)
UNUSED(fourcc)
UNUSED(fps)
UNUSED(callback)
}
void start_streaming(device &device, int num_transfer_bufs) { // NOLINT
UNUSED(device)
UNUSED(num_transfer_bufs)
}
void stop_streaming(device &device) { // NOLINT
UNUSED(device)
}
} // namespace uvc
MYNTEYE_END_NAMESPACE

View File

@ -24,7 +24,7 @@ typedef enum pu_query {
} pu_query;
// Extension Unit
struct xu {
struct MYNTEYE_API xu {
uint8_t unit;
};
@ -42,40 +42,40 @@ struct context; // Opaque type representing access to the underlying UVC
struct device; // Opaque type representing access to a specific UVC device
// Enumerate devices
std::shared_ptr<context> create_context();
std::vector<std::shared_ptr<device>> query_devices(
MYNTEYE_API std::shared_ptr<context> create_context();
MYNTEYE_API std::vector<std::shared_ptr<device>> query_devices(
std::shared_ptr<context> context);
// Static device properties
std::string get_name(const device &device);
int get_vendor_id(const device &device);
int get_product_id(const device &device);
MYNTEYE_API std::string get_name(const device &device);
MYNTEYE_API int get_vendor_id(const device &device);
MYNTEYE_API int get_product_id(const device &device);
std::string get_video_name(const device &device);
MYNTEYE_API std::string get_video_name(const device &device);
// Access PU (Processing Unit) controls
inline bool is_pu_control(Option option) {
return option >= Option::GAIN && option <= Option::CONTRAST;
}
bool pu_control_range(
MYNTEYE_API bool pu_control_range(
const device &device, Option option, int32_t *min, int32_t *max,
int32_t *def);
bool pu_control_query(
MYNTEYE_API bool pu_control_query(
const device &device, Option option, pu_query query, int32_t *value);
// Access XU (Extension Unit) controls
bool xu_control_query(
MYNTEYE_API bool xu_control_query(
const device &device, const xu &xu, uint8_t selector, xu_query query,
uint16_t size, uint8_t *data);
// Control streaming
typedef std::function<void(const void *frame)> video_channel_callback;
void set_device_mode(
MYNTEYE_API void set_device_mode(
device &device, int width, int height, int fourcc, int fps, // NOLINT
video_channel_callback callback);
void start_streaming(device &device, int num_transfer_bufs); // NOLINT
void stop_streaming(device &device); // NOLINT
MYNTEYE_API void start_streaming(device &device, int num_transfer_bufs); // NOLINT
MYNTEYE_API void stop_streaming(device &device); // NOLINT
} // namespace uvc

View File

@ -4,10 +4,17 @@ project(mynteye_test VERSION 2.0.0 LANGUAGES C CXX)
get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
include(${PRO_DIR}/cmake/Common.cmake)
# flags
if(OS_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
include(${PRO_DIR}/cmake/DetectCXX11.cmake)
@ -51,8 +58,6 @@ message(STATUS "Found gtest libs: ${GTEST_LIBS}")
# targets
include(${PRO_DIR}/cmake/Common.cmake)
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
set_outdir(

View File

@ -4,10 +4,17 @@ project(mynteye_tools VERSION 2.0.0 LANGUAGES C CXX)
get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
include(${PRO_DIR}/cmake/Common.cmake)
# flags
if(OS_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
endif()
include(${PRO_DIR}/cmake/DetectCXX11.cmake)
@ -41,8 +48,6 @@ endif()
# targets
include(${PRO_DIR}/cmake/Common.cmake)
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
include_directories(