diff --git a/.gitignore b/.gitignore index 7be8236..396e1d4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,11 @@ _output/ /plugins/ +/3rdparty/opencv/ +/pkginfo.sh +/*.nsi +/*.exe + # ros /wrappers/ros/build diff --git a/.gitmodules b/.gitmodules index d40f165..3a8bfae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "test/gtest"] path = test/gtest url = https://github.com/google/googletest.git -[submodule "third_party/glog"] - path = third_party/glog - url = https://github.com/google/glog.git [submodule "tools/linter"] path = tools/linter url = https://github.com/slightech/linter.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 62c59a4..2172b5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,14 @@ cmake_minimum_required(VERSION 3.0) -project(mynteye VERSION 2.0.1 LANGUAGES C CXX) +project(mynteye VERSION 2.2.2 LANGUAGES C CXX) include(cmake/Common.cmake) +if(NOT CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX d) +endif() + # options include(cmake/Option.cmake) @@ -44,9 +48,16 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}") # packages -LIST(APPEND CMAKE_PREFIX_PATH third_party/glog/_build) -find_package(glog REQUIRED) -message(STATUS "Found glog: ${glog_VERSION}") +find_package(Threads QUIET) + +macro(target_link_threads NAME) + if(THREADS_HAVE_PTHREAD_ARG) + target_compile_options(PUBLIC ${NAME} "-pthread") + endif() + if(CMAKE_THREAD_LIBS_INIT) + target_link_libraries(${NAME} "${CMAKE_THREAD_LIBS_INIT}") + endif() +endmacro() LIST(APPEND CMAKE_MODULE_PATH cmake) @@ -72,6 +83,17 @@ configure_file( include/mynteye/mynteye.h @ONLY ) +configure_file( + cmake/templates/pkginfo.sh.in + ${CMAKE_CURRENT_SOURCE_DIR}/pkginfo.sh @ONLY +) +if(OS_WIN) + configure_file( + scripts/win/nsis/winpack.nsi.in + ${CMAKE_CURRENT_SOURCE_DIR}/winpack.nsi @ONLY + ) +endif() + # targets add_definitions(-DMYNTEYE_EXPORTS) @@ -83,101 +105,88 @@ set_outdir( "${OUT_DIR}/bin" ) -set(MYNTEYE_CMAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include") -set(MYNTEYE_CMAKE_BINDIR "${CMAKE_INSTALL_PREFIX}/bin") -set(MYNTEYE_CMAKE_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") -set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}") - ## main -add_executable(main src/main.cc) -target_link_libraries(main glog::glog) -target_include_directories(main PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_BINARY_DIR}/include -) - -## libmynteye - -set(MYNTEYE_PUBLIC_H - ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/callbacks.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/global.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/glog_init.h - ${CMAKE_CURRENT_BINARY_DIR}/include/mynteye/mynteye.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/types.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/utils.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/device/context.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/device/device.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/files.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/strings.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/internal/times.h -) -if(WITH_API) - list(APPEND MYNTEYE_PUBLIC_H - ${CMAKE_CURRENT_SOURCE_DIR}/src/api/api.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/api/plugin.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/api/processor/object.h +if(WITH_GLOG) + add_executable(main src/main.cc) + target_link_libraries(main glog::glog) + target_include_directories(main PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/include ) endif() +## libmynteye + +if(NOT WITH_GLOG AND NOT OS_WIN) + set(__MINIGLOG_FLAGS "-Wno-unused-parameter -Wno-format -Wno-return-type") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${__MINIGLOG_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__MINIGLOG_FLAGS}") + unset(__MINIGLOG_FLAGS) +endif() + if(OS_WIN) - set(UVC_SRC src/uvc/uvc-wmf.cc) + set(UVC_SRC src/mynteye/uvc/win/uvc-wmf.cc) elseif(OS_MAC) - set(UVC_SRC src/uvc/uvc-libuvc.cc) + set(UVC_SRC src/mynteye/uvc/macosx/uvc-libuvc.cc) find_package(libuvc REQUIRED) set(UVC_LIB ${libuvc_LIBRARIES}) include_directories(${libuvc_INCLUDE_DIRS}) elseif(OS_LINUX) - set(UVC_SRC src/uvc/uvc-v4l2.cc) + set(UVC_SRC src/mynteye/uvc/linux/uvc-v4l2.cc) else() message(FATAL_ERROR "Unsupported OS.") endif() set(MYNTEYE_SRCS ${UVC_SRC} - src/internal/channels.cc - src/internal/config.cc - src/internal/dl.cc - src/internal/files.cc - src/internal/motions.cc - src/internal/streams.cc - src/internal/strings.cc - src/internal/types.cc - src/public/types.cc - src/public/utils.cc - src/device/context.cc - src/device/device.cc - src/device/device_s.cc + src/mynteye/types.cc + src/mynteye/util/files.cc + src/mynteye/util/strings.cc + src/mynteye/device/channels.cc + src/mynteye/device/config.cc + src/mynteye/device/context.cc + src/mynteye/device/device.cc + src/mynteye/device/device_s.cc + src/mynteye/device/motions.cc + src/mynteye/device/streams.cc + src/mynteye/device/types.cc + src/mynteye/device/utils.cc ) if(WITH_API) list(APPEND MYNTEYE_SRCS - 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 + src/mynteye/api/api.cc + src/mynteye/api/dl.cc + src/mynteye/api/processor.cc + src/mynteye/api/synthetic.cc + src/mynteye/api/processor/rectify_processor.cc + src/mynteye/api/processor/disparity_processor.cc + src/mynteye/api/processor/disparity_normalized_processor.cc + src/mynteye/api/processor/depth_processor.cc + src/mynteye/api/processor/points_processor.cc ) endif() +if(NOT WITH_GLOG) + list(APPEND MYNTEYE_SRCS src/mynteye/miniglog.cc) +endif() -set(MYNTEYE_LINKLIBS - glog::glog - ${UVC_LIB} -) +set(MYNTEYE_LINKLIBS ${UVC_LIB}) if(WITH_API) list(APPEND MYNTEYE_LINKLIBS ${OpenCV_LIBS}) endif() if(WITH_BOOST_FILESYSTEM) list(APPEND MYNTEYE_LINKLIBS ${Boost_LIBRARIES}) endif() +if(WITH_GLOG) + list(APPEND MYNTEYE_LINKLIBS glog::glog) +endif() #message(STATUS "MYNTEYE_LINKLIBS: ${MYNTEYE_LINKLIBS}") add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS}) target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS}) +target_link_threads(${MYNTEYE_NAME}) if(OS_WIN) target_compile_definitions(${MYNTEYE_NAME} @@ -189,27 +198,78 @@ target_include_directories(${MYNTEYE_NAME} PUBLIC "$" "$" "$" - "$" + "$" ) set_target_properties(${MYNTEYE_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) -set_target_properties(${MYNTEYE_NAME} PROPERTIES - PUBLIC_HEADER "${MYNTEYE_PUBLIC_H}" -) # install -#message(STATUS "MYNTEYE_CMAKE_INCLUDE_DIR: ${MYNTEYE_CMAKE_INCLUDE_DIR}") -#message(STATUS "MYNTEYE_CMAKE_BINDIR: ${MYNTEYE_CMAKE_BINDIR}") -#message(STATUS "MYNTEYE_CMAKE_LIBDIR: ${MYNTEYE_CMAKE_LIBDIR}") -#message(STATUS "MYNTEYE_CMAKE_INSTALLDIR: ${MYNTEYE_CMAKE_INSTALLDIR}") +set(MYNTEYE_CMAKE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${MYNTEYE_NAME}") +set(MYNTEYE_CMAKE_BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +set(MYNTEYE_CMAKE_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") +set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}") + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/include/mynteye/mynteye.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/global.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/logger.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/types.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR} +) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/callbacks.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/context.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/device.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/device/utils.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/device +) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/files.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/strings.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/util/times.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/util +) +if(WITH_API) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/api.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/plugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/api/object.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/api + ) +endif() +if(NOT WITH_GLOG) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/miniglog.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR} + ) +endif() + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/callbacks.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/context.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/device.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/files.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/glog_init.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/strings.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/times.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/utils.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR} +) +if(WITH_API) + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/api.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/plugin.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/deprecated/mynteye/object.h + DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR} + ) +endif() install(TARGETS ${MYNTEYE_NAME} EXPORT ${MYNTEYE_NAME}-targets - PUBLIC_HEADER DESTINATION ${MYNTEYE_CMAKE_INCLUDE_DIR}/${MYNTEYE_NAME} RUNTIME DESTINATION ${MYNTEYE_CMAKE_BINDIR} LIBRARY DESTINATION ${MYNTEYE_CMAKE_LIBDIR} ARCHIVE DESTINATION ${MYNTEYE_CMAKE_LIBDIR} diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..95cd94f --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,2 @@ +set noparent +filter=-build/c++11 diff --git a/CommonDefs.mk b/CommonDefs.mk index 378b7ff..1df3a94 100644 --- a/CommonDefs.mk +++ b/CommonDefs.mk @@ -26,6 +26,16 @@ SINGLE_QUOTE := ' OPEN_PAREN := ( CLOSE_PAREN := ) +# Options +# +# VS_CODE: ignore to auto detect, otherwise specify the version +# 15|2017, 14|2015, 12|2013, 11|2012, 10|2010, 9|2008, 8|2005 +# BUILD_TYPE: Debug|Release +# +# e.g. make [TARGET] VS_CODE=2017 BUILD_TYPE=Debug + +BUILD_TYPE ?= Release + # Host detection ifeq ($(OS),Windows_NT) @@ -124,7 +134,7 @@ ifeq ($(HOST_OS),Win) CC := cl CXX := cl MAKE := make - BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release + BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=$(BUILD_TYPE) endif else # mac & linux @@ -144,8 +154,7 @@ endif # CMake CMAKE := cmake -# CMAKE := $(CMAKE) -DCMAKE_BUILD_TYPE=Debug -CMAKE := $(CMAKE) -DCMAKE_BUILD_TYPE=Release +CMAKE := $(CMAKE) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ifneq ($(CC),) CMAKE := $(CMAKE) -DCMAKE_C_COMPILER=$(CC) endif @@ -202,6 +211,15 @@ endif endif +# Package + +PKGVERSION := $(shell ./scripts/version.sh) +PKGNAME := mynteye-s-$(PKGVERSION)-$(HOST_OS)-$(HOST_ARCH) +ifeq ($(HOST_OS),Linux) + PKGNAME := $(PKGNAME)-gcc$(shell gcc -dumpversion | cut -c 1-1) +endif +PKGNAME := $(call lower,$(PKGNAME)) + # Shell # `sh` is not possible to export a function diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..619ee8e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,103 @@ +pipeline { + agent { + // docker { image 'ros:kinetic-ros-base-xenial' } + docker { image 'joinaero/kinetic-ros-opencv-xenial' } + } + + /* + environment { + // FindOpenCV.cmake + OpenCV_DIR = '/opt/ros/kinetic/share/OpenCV-3.3.1-dev' + } + */ + + stages { + stage('Prepare') { + steps { + echo "WORKSPACE: ${env.WORKSPACE}" + echo 'apt-get ..' + sh 'apt-get update' + } + } + stage('Init') { + steps { + echo 'make init ..' + sh 'make init INIT_OPTIONS=-y' + // echo 'skip get submodules and make test' + // sh './scripts/init.sh -y' + } + } + stage('Build') { + steps { + echo 'make build ..' + sh '. /opt/ros/kinetic/setup.sh; make build' + } + } + stage('Install') { + steps { + echo 'make install ..' + sh '. /opt/ros/kinetic/setup.sh; make install SUDO=' + } + } + stage('Test') { + steps { + echo 'make test ..' + sh '. /opt/ros/kinetic/setup.sh; make test SUDO=' + } + } + stage('Samples') { + steps { + echo 'make samples ..' + sh '. /opt/ros/kinetic/setup.sh; make samples SUDO=' + } + } + stage('Tools') { + steps { + echo 'make tools ..' + sh '. /opt/ros/kinetic/setup.sh; make tools SUDO=' + } + } + stage('ROS') { + steps { + echo 'make ros ..' + sh ''' + . /opt/ros/kinetic/setup.sh + rosdep install --from-paths wrappers/ros/src --ignore-src --rosdistro kinetic -y + make ros SUDO= + ''' + } + } + /* + stage('Clean') { + steps { + echo 'clean ..' + sh ''' + rm -rf /var/lib/apt/lists/* + ''' + } + } + */ + } + + post { + always { + echo 'This will always run' + } + success { + echo 'This will run only if successful' + } + failure { + echo 'This will run only if failed' + mail to: 'mynteye-ci@slightech.com', + subject: "Failed Pipeline: ${currentBuild.fullDisplayName}", + body: "Something is wrong with ${env.BUILD_URL}" + } + unstable { + echo 'This will run only if the run was marked as unstable' + } + changed { + echo 'This will run only if the state of the Pipeline has changed' + echo 'For example, if the Pipeline was previously failing but is now successful' + } + } +} diff --git a/Makefile b/Makefile index 4f9da2a..9ce54af 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,15 @@ include CommonDefs.mk MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) -.DEFAULT_GOAL := help +# CMAKE_INSTALL_PREFIX: +# https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html +# +# UNIX: /usr/local +# Windows: c:/Program Files/${PROJECT_NAME} + +SUDO ?= sudo + +.DEFAULT_GOAL := all help: @echo "Usage:" @@ -25,17 +33,18 @@ help: @echo " make opendoc open api doc (html)" @echo " make init init project" @echo " make build build project" - @echo " make test build test and run" @echo " make install install project" + @echo " make test build test and run" @echo " make samples build samples" @echo " make tools build tools" + @echo " make pkg package sdk" @echo " make ros build ros wrapper" @echo " make py build python wrapper" @echo " make clean|cleanall clean generated or useless things" .PHONY: help -all: test tools samples +all: init samples tools ros .PHONY: all @@ -43,7 +52,8 @@ all: test tools samples apidoc: @$(call echo,Make $@) - @[ -e ./_install/include ] || $(MAKE) install + @# @[ -e ./_install/include ] || $(MAKE) install + @[ -e /usr/local/include/mynteye ] || $(MAKE) install @$(SH) ./doc/build.sh opendoc: apidoc @@ -64,32 +74,31 @@ cleandoc: submodules: @git submodule update --init -third_party: submodules - @$(call echo,Make $@) - @$(call echo,Make glog,33) - @$(call cmake_build,./third_party/glog/_build) - -.PHONY: submodules third_party +.PHONY: submodules # init -init: submodules +init: @$(call echo,Make $@) - @$(SH) ./scripts/init.sh + @$(SH) ./scripts/init.sh $(INIT_OPTIONS) .PHONY: init # build -build: third_party +build: @$(call echo,Make $@) +ifeq ($(HOST_OS),Win) @$(call cmake_build,./_build,..,-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/_install) +else + @$(call cmake_build,./_build,..) +endif .PHONY: build # test -test: install +test: submodules install @$(call echo,Make $@) @$(call echo,Make gtest,33) ifeq ($(HOST_OS),Win) @@ -117,12 +126,27 @@ ifneq ($(HOST_NAME),MinGW) else @cd ./_build; make install endif +else +ifeq ($(HOST_OS),Linux) + @cd ./_build; $(SUDO) make install else @cd ./_build; make install endif +endif .PHONY: install +uninstall: + @$(call echo,Make $@) +ifeq ($(HOST_OS),Linux) + $(SUDO) rm -rf /usr/local/lib/libmynteye* + $(SUDO) rm -rf /usr/local/include/mynteye/ + $(SUDO) rm -rf /usr/local/lib/cmake/mynteye/ + $(SUDO) rm -rf /usr/local/share/mynteye/ +endif + +.PHONY: uninstall + # samples samples: install @@ -139,14 +163,30 @@ tools: install .PHONY: tools +# pkg + +pkg: clean + @$(call echo,Make $@) +ifeq ($(HOST_OS),Win) + @$(SH) ./scripts/win/winpack.sh "$(PKGNAME)" +else + $(error "Can't make pkg on $(HOST_OS)") +endif + +cleanpkg: + @$(call echo,Make $@) + @$(call rm_f,$(PKGNAME)*) + +.PHONY: pkg cleanpkg + # ros ros: install @$(call echo,Make $@) -ifeq ($(HOST_OS),Win) - $(error "Can't make ros on win") +ifeq ($(HOST_OS),Linux) + @cd ./wrappers/ros && catkin_make -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) else - @cd ./wrappers/ros && catkin_make + $(error "Can't make ros on $(HOST_OS)") endif .PHONY: ros @@ -255,6 +295,7 @@ host: @echo BUILD: $(BUILD) @echo LDD: $(LDD) @echo CMAKE: $(CMAKE) + @echo PKGNAME: $(PKGNAME) .PHONY: host diff --git a/README.md b/README.md index b2f564e..f478950 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# MYNT® EYE SDK +# MYNT® EYE S SDK -[![](https://img.shields.io/badge/MYNT%20EYE%20SDK-2.0.1--rc0-brightgreen.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2) +[![](https://img.shields.io/badge/MYNT%20EYE%20S%20SDK-2.2.2--rc0-brightgreen.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK) ## Overview -MYNT® EYE SDK 2.0 is a cross-platform library for MYNT® EYE cameras. +MYNT® EYE S SDK is a cross-platform library for MYNT® EYE Standard cameras. The following platforms have been tested: @@ -16,21 +16,20 @@ Please follow the guide doc to install the SDK on different platforms. ## Documentations -* [API Doc](https://github.com/slightech/MYNT-EYE-SDK-2/releases): API reference, some guides and data spec. - * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203869/mynt-eye-sdk-apidoc-2.0.1-rc0-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203870/mynt-eye-sdk-apidoc-2.0.1-rc0-html-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-SDK-2/) - * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203872/mynt-eye-sdk-apidoc-2.0.1-rc0-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203874/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/api/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans/index.html) -* [Guide Doc](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/releases): How to install and start using the SDK. - * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203877/mynt-eye-sdk-guide-2.0.1-rc0-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203879/mynt-eye-sdk-guide-2.0.1-rc0-html-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-SDK-2-Guide/) - * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203880/mynt-eye-sdk-guide-2.0.1-rc0-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203881/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/sdk/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans/index.html ) +* [API Doc](https://github.com/slightech/MYNT-EYE-S-SDK/releases): API reference, some guides and data spec. + * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2562294/mynt-eye-s-sdk-apidoc-2.2.2-rc0-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2562296/mynt-eye-s-sdk-apidoc-2.2.2-rc0-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK/) + * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2562297/mynt-eye-s-sdk-apidoc-2.2.2-rc0-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK/files/2562298/mynt-eye-s-sdk-apidoc-2.2.2-rc0-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/api/mynt-eye-s-sdk-apidoc-2.2.2-rc0-zh-Hans/mynt-eye-s-sdk-apidoc-2.2.2-rc0-zh-Hans/index.html) +* [Guide Doc](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/releases): How to install and start using the SDK. + * en: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2598115/mynt-eye-s-sdk-guide-2.2.2-rc0-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2598116/mynt-eye-s-sdk-guide-2.2.2-rc0-en.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](https://slightech.github.io/MYNT-EYE-S-SDK-Guide/) + * zh-Hans: [![](https://img.shields.io/badge/Download-PDF-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2598117/mynt-eye-s-sdk-guide-2.2.2-rc0-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2598119/mynt-eye-s-sdk-guide-2.2.2-rc0-zh-Hans.zip) [![](https://img.shields.io/badge/Online-HTML-blue.svg?style=flat)](http://doc.myntai.com/resource/sdk/mynt-eye-s-sdk-guide-2.2.2-rc0-zh-Hans/mynt-eye-s-sdk-guide-2.2.2-rc0-zh-Hans/index.html) > Supported languages: `en`, `zh-Hans`. ## Firmwares -[Google Drive]: https://drive.google.com/drive/folders/1tdFCcTBMNcImEGZ39tdOZmlX2SHKCr2f -[百度网盘]: https://pan.baidu.com/s/1yPQDp2r0x4jvNwn2UjlMUQ +[MYNTEYE_BOX]: http://doc.myntai.com/mynteye/s/download -Get firmwares from our online disks: [Google Drive][], [百度网盘][]. The latest version is `2.0.1-rc0`. +Get firmwares from our online disks: [MYNTEYE_BOX][]. The latest version is `2.2.2`. ## Usage @@ -62,8 +61,8 @@ make samples ## Mirrors -国内镜像:[码云](https://gitee.com/mynt/MYNT-EYE-SDK-2)。 +国内镜像:[码云](https://gitee.com/mynt/MYNT-EYE-S-SDK)。 ## License -This project is licensed under the Apache License, Version 2.0. Copyright 2018 Slightech Co., Ltd. +This project is licensed under the [Apache License, Version 2.0](LICENSE). Copyright 2018 Slightech Co., Ltd. diff --git a/cmake/Common.cmake b/cmake/Common.cmake index ab14b08..8526d9a 100755 --- a/cmake/Common.cmake +++ b/cmake/Common.cmake @@ -70,7 +70,9 @@ macro(set_outdir ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPU endforeach() endmacro() -set(__exe2bat_relative_path false) +if(NOT __exe2bat_relative_path) + set(__exe2bat_relative_path false) +endif() macro(exe2bat exe_name exe_dir dll_search_paths) message(STATUS "Generating ${exe_name}.bat") diff --git a/cmake/DetectGLog.cmake b/cmake/DetectGLog.cmake new file mode 100644 index 0000000..daf42d7 --- /dev/null +++ b/cmake/DetectGLog.cmake @@ -0,0 +1,26 @@ +# 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. + +include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake) +cmake_include_guard() + +get_filename_component(__pro_dir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) +LIST(APPEND CMAKE_PREFIX_PATH ${__pro_dir}/third_party/glog/_build) + +find_package(glog REQUIRED) +if(glog_FOUND) + add_definitions(-DWITH_GLOG) +endif() + +unset(__pro_dir) diff --git a/cmake/DetectOpenCV.cmake b/cmake/DetectOpenCV.cmake index 4673876..e82e546 100644 --- a/cmake/DetectOpenCV.cmake +++ b/cmake/DetectOpenCV.cmake @@ -15,14 +15,25 @@ include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake) cmake_include_guard() -find_package(OpenCV REQUIRED) -message(STATUS "Found OpenCV: ${OpenCV_VERSION}") -if(OpenCV_VERSION VERSION_LESS 3.0) - add_definitions(-DUSE_OPENCV2) -elseif(OpenCV_VERSION VERSION_LESS 4.0) - add_definitions(-DUSE_OPENCV3) +if(OpenCV_FIND_QUIET) + find_package(OpenCV QUIET) else() - add_definitions(-DUSE_OPENCV4) + find_package(OpenCV REQUIRED) +endif() + +if(OpenCV_FOUND) + +#message(STATUS "Found OpenCV: ${OpenCV_VERSION}") + +set(WITH_OPENCV TRUE) +add_definitions(-DWITH_OPENCV) + +if(OpenCV_VERSION VERSION_LESS 3.0) + add_definitions(-DWITH_OPENCV2) +elseif(OpenCV_VERSION VERSION_LESS 4.0) + add_definitions(-DWITH_OPENCV3) +else() + add_definitions(-DWITH_OPENCV4) endif() list(FIND OpenCV_LIBS "opencv_world" __index) @@ -35,3 +46,9 @@ if(MSVC OR MSYS OR MINGW) else() set(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}") endif() + +else() + +set(WITH_OPENCV FALSE) + +endif() diff --git a/cmake/Option.cmake b/cmake/Option.cmake index f649391..98e9e49 100644 --- a/cmake/Option.cmake +++ b/cmake/Option.cmake @@ -28,6 +28,10 @@ option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON) option(WITH_BOOST "Include Boost support" ON) +# How to install glog? +# Ubuntu: `sudo apt-get install libgoogle-glog-dev` +option(WITH_GLOG "Include glog support" OFF) + # packages @@ -59,6 +63,10 @@ if(NOT WITH_FILESYSTEM) endif() endif() +if(WITH_GLOG) + include(${CMAKE_CURRENT_LIST_DIR}/DetectGLog.cmake) +endif() + find_package(CUDA QUIET) # summary @@ -125,6 +133,16 @@ if(WITH_BOOST) endif() endif() +status(" WITH_GLOG: ${WITH_GLOG}") +if(WITH_GLOG) + if(glog_FOUND) + status(" glog: YES") + status(" glog_VERSION: ${glog_VERSION}") + else() + status(" glog: NO") + endif() +endif() + status("") status("Features:") status(" Filesystem: " diff --git a/cmake/templates/pkginfo.sh.in b/cmake/templates/pkginfo.sh.in new file mode 100644 index 0000000..8778d4e --- /dev/null +++ b/cmake/templates/pkginfo.sh.in @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +OpenCV_VERSION=@OpenCV_VERSION@ +OpenCV_VERSION_MAJOR=@OpenCV_VERSION_MAJOR@ +OpenCV_VERSION_MINOR=@OpenCV_VERSION_MINOR@ +OpenCV_VERSION_PATCH=@OpenCV_VERSION_PATCH@ +OpenCV_VERSION_STATUS=@OpenCV_VERSION_STATUS@ + +_contains() { + [ `echo $1 | grep -c "$2"` -gt 0 ] +} + +if _contains "@OpenCV_INCLUDE_DIRS@" "/ros/"; then + ROS_VERSION=$(rosversion -d) + OpenCV_VERSION=ros-$ROS_VERSION +fi diff --git a/doc/build.sh b/doc/build.sh index c2f368c..5160c61 100755 --- a/doc/build.sh +++ b/doc/build.sh @@ -52,16 +52,30 @@ for lang in "${LANGS[@]}"; do _mkdir "$OUTPUT/$lang" _echo_i "doxygen $DOXYFILE" doxygen $DOXYFILE + + version=`cat $DOXYFILE | grep -m1 "^PROJECT_NUMBER\s*=" | \ + sed -E "s/^.*=[[:space:]]*(.*)[[:space:]]*$/\1/g"` + + # html + if [ -d "$OUTPUT/$lang/html" ]; then + dirname="mynt-eye-s-sdk-apidoc"; \ + [ -n "$version" ] && dirname="$dirname-$version"; \ + dirname="$dirname-$lang" + cd "$OUTPUT/$lang" + [ -d "$dirname" ] && rm -rf "$dirname" + mv "html" "$dirname" && zip -r "$dirname.zip" "$dirname" + fi + + # latex if [ $pdflatex_FOUND ] && [ -f "$OUTPUT/$lang/latex/Makefile" ]; then _echo_in "doxygen make latex" - version=`cat $DOXYFILE | grep -m1 "^PROJECT_NUMBER\s*=" | \ - sed -E "s/^.*=[[:space:]]*(.*)[[:space:]]*$/\1/g"` - filename="mynt-eye-sdk-apidoc"; \ + filename="mynt-eye-s-sdk-apidoc"; \ [ -n "$version" ] && filename="$filename-$version"; \ filename="$filename-$lang.pdf" cd "$OUTPUT/$lang/latex" && _texcjk refman.tex && make [ -f "refman.pdf" ] && mv "refman.pdf" "../$filename" fi + _echo_d "doxygen completed" else _echo_e "$DOXYFILE not found" diff --git a/doc/en/api.doxyfile b/doc/en/api.doxyfile index d7d7e03..9f69ae2 100644 --- a/doc/en/api.doxyfile +++ b/doc/en/api.doxyfile @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "MYNT EYE SDK" +PROJECT_NAME = "MYNT EYE S SDK" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.0.1-rc0 +PROJECT_NUMBER = 2.2.2-rc0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = http://www.myntai.com/camera +PROJECT_BRIEF = http://www.myntai.com/mynteye/standard # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -801,7 +801,7 @@ INPUT = mainpage.md \ specs_ctrl.md \ spec_control_api.md \ spec_control_channel.md \ - ../../_install/include + /usr/local/include/mynteye # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -884,7 +884,8 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = /usr/local/include/mynteye/logger.h \ + /usr/local/include/mynteye/miniglog.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1309,7 +1310,7 @@ DOCSET_PUBLISHER_ID = com.slightech.mynteye.documentation # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. -DOCSET_PUBLISHER_NAME = MYNT EYE SDK +DOCSET_PUBLISHER_NAME = MYNT EYE S SDK # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The diff --git a/doc/en/mainpage.md b/doc/en/mainpage.md index 487ef06..47a2dda 100644 --- a/doc/en/mainpage.md +++ b/doc/en/mainpage.md @@ -1,4 +1,4 @@ -# MYNT EYE SDK {#mainpage} +# MYNT EYE S SDK {#mainpage} * API Classes * API Modules diff --git a/doc/en/spec_control_api.md b/doc/en/spec_control_api.md index 46d2366..475bf06 100644 --- a/doc/en/spec_control_api.md +++ b/doc/en/spec_control_api.md @@ -14,7 +14,7 @@ There are two control modes, one is through UVC standard protocol, the other is | Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Channel | Note | | :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :------ | :----- | -| Frame rate | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | values: {10,15,20,25,30,35,40,45,50,55} | +| Frame rate | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | values: {10,15,20,25,30,35,40,45,50,55,60} | | IMU frequency | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | values: {100,200,250,333,500} | | Exposure mode | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0: enable auto-exposure; 1: manual-exposure | | Max gain | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | valid if auto-exposure | diff --git a/doc/zh-Hans/api.doxyfile b/doc/zh-Hans/api.doxyfile index aa023f5..a30690b 100644 --- a/doc/zh-Hans/api.doxyfile +++ b/doc/zh-Hans/api.doxyfile @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "MYNT EYE SDK" +PROJECT_NAME = "MYNT EYE S SDK" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.0.1-rc0 +PROJECT_NUMBER = 2.2.2-rc0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = http://www.myntai.com/camera +PROJECT_BRIEF = http://www.myntai.com/mynteye/standard # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -801,7 +801,7 @@ INPUT = mainpage.md \ specs_ctrl.md \ spec_control_api.md \ spec_control_channel.md \ - ../../_install/include + /usr/local/include/mynteye # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -884,7 +884,8 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = /usr/local/include/mynteye/logger.h \ + /usr/local/include/mynteye/miniglog.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1309,7 +1310,7 @@ DOCSET_PUBLISHER_ID = com.slightech.mynteye.documentation # The default value is: Publisher. # This tag requires that the tag GENERATE_DOCSET is set to YES. -DOCSET_PUBLISHER_NAME = MYNT EYE SDK +DOCSET_PUBLISHER_NAME = MYNT EYE S SDK # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The diff --git a/doc/zh-Hans/guide_build_linux.md b/doc/zh-Hans/guide_build_linux.md index a1bbda0..8e2bc38 100644 --- a/doc/zh-Hans/guide_build_linux.md +++ b/doc/zh-Hans/guide_build_linux.md @@ -5,13 +5,13 @@ ## 获取代码 ```bash -git clone https://github.com/slightech/MYNT-EYE-SDK-2.git +git clone https://github.com/slightech/MYNT-EYE-S-SDK.git ``` ## 准备依赖 ```bash -cd mynt-eye-sdk-2/ +cd mynt-eye-s-sdk/ make init ``` diff --git a/doc/zh-Hans/guide_build_win.md b/doc/zh-Hans/guide_build_win.md index 8f7a279..30370bc 100644 --- a/doc/zh-Hans/guide_build_win.md +++ b/doc/zh-Hans/guide_build_win.md @@ -72,13 +72,13 @@ GNU Make 4.2.1 ## 获取代码 ```cmd ->git clone https://github.com/slightech/MYNT-EYE-SDK-2.git +>git clone https://github.com/slightech/MYNT-EYE-S-SDK.git ``` ## 准备依赖 ```cmd ->cd mynt-eye-sdk-2 +>cd mynt-eye-s-sdk >make init Make init Init deps diff --git a/doc/zh-Hans/guide_log.md b/doc/zh-Hans/guide_log.md index ef16629..7863260 100644 --- a/doc/zh-Hans/guide_log.md +++ b/doc/zh-Hans/guide_log.md @@ -1,6 +1,6 @@ # 日志 {#guide_log} -日志系统用的 `glog` ,通用配置在头文件 `glog_init.h` 里。 +日志系统用的 `glog` ,通用配置在头文件 `logger.h` 里。 * 日志文件会存储在当前工作目录, `make cleanlog` 可以清理。 -* 如果需要打开详细日志,请取消 `glog_init.h` 里注释的 `FLAGS_v = 2;` ,重新编译。 +* 如果需要打开详细日志,请取消 `logger.h` 里注释的 `FLAGS_v = 2;` ,重新编译。 diff --git a/doc/zh-Hans/mainpage.md b/doc/zh-Hans/mainpage.md index 3097ef4..6b45b5a 100644 --- a/doc/zh-Hans/mainpage.md +++ b/doc/zh-Hans/mainpage.md @@ -1,4 +1,4 @@ -# MYNT EYE SDK {#mainpage} +# MYNT EYE S SDK {#mainpage} * API 类 * API 模块 diff --git a/doc/zh-Hans/spec_control_api.md b/doc/zh-Hans/spec_control_api.md index 9c3bea1..ca93fa4 100644 --- a/doc/zh-Hans/spec_control_api.md +++ b/doc/zh-Hans/spec_control_api.md @@ -16,7 +16,7 @@ | 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 说明 | | :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----- | -| 图像帧率 | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55} | +| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55,60} | | IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 有效值为{100,200,250,333,500} | | 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0:开启自动曝光; 1:关闭 | | 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 | @@ -26,3 +26,5 @@ | HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0:10-bit;1:12-bit | | 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | | | 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | | +| 加速度计量程 | accelerometer_range | 2 | 12 | 6 | 48 | √ | - | XU_CAM_CTRL | 0x0100 | | +| 陀螺仪量程 | gyroscope_range | 2 | 1000 | 250 | 4000 | √ | - | XU_CAM_CTRL | 0x0100 | | diff --git a/include/deprecated/mynteye/api.h b/include/deprecated/mynteye/api.h new file mode 100644 index 0000000..26b4bf5 --- /dev/null +++ b/include/deprecated/mynteye/api.h @@ -0,0 +1 @@ +#include "mynteye/api/api.h" diff --git a/include/deprecated/mynteye/callbacks.h b/include/deprecated/mynteye/callbacks.h new file mode 100644 index 0000000..8f1cd45 --- /dev/null +++ b/include/deprecated/mynteye/callbacks.h @@ -0,0 +1 @@ +#include "mynteye/device/callbacks.h" diff --git a/include/deprecated/mynteye/context.h b/include/deprecated/mynteye/context.h new file mode 100644 index 0000000..8cd87d9 --- /dev/null +++ b/include/deprecated/mynteye/context.h @@ -0,0 +1 @@ +#include "mynteye/device/context.h" diff --git a/include/deprecated/mynteye/device.h b/include/deprecated/mynteye/device.h new file mode 100644 index 0000000..d8648ce --- /dev/null +++ b/include/deprecated/mynteye/device.h @@ -0,0 +1 @@ +#include "mynteye/device/device.h" diff --git a/include/deprecated/mynteye/files.h b/include/deprecated/mynteye/files.h new file mode 100644 index 0000000..335edc2 --- /dev/null +++ b/include/deprecated/mynteye/files.h @@ -0,0 +1 @@ +#include "mynteye/util/files.h" diff --git a/include/deprecated/mynteye/glog_init.h b/include/deprecated/mynteye/glog_init.h new file mode 100644 index 0000000..e094384 --- /dev/null +++ b/include/deprecated/mynteye/glog_init.h @@ -0,0 +1 @@ +#include "mynteye/logger.h" diff --git a/include/deprecated/mynteye/object.h b/include/deprecated/mynteye/object.h new file mode 100644 index 0000000..90bc8d7 --- /dev/null +++ b/include/deprecated/mynteye/object.h @@ -0,0 +1 @@ +#include "mynteye/api/object.h" diff --git a/include/deprecated/mynteye/plugin.h b/include/deprecated/mynteye/plugin.h new file mode 100644 index 0000000..52c6cd9 --- /dev/null +++ b/include/deprecated/mynteye/plugin.h @@ -0,0 +1 @@ +#include "mynteye/api/plugin.h" diff --git a/include/deprecated/mynteye/strings.h b/include/deprecated/mynteye/strings.h new file mode 100644 index 0000000..83b19b5 --- /dev/null +++ b/include/deprecated/mynteye/strings.h @@ -0,0 +1 @@ +#include "mynteye/util/strings.h" diff --git a/include/deprecated/mynteye/times.h b/include/deprecated/mynteye/times.h new file mode 100644 index 0000000..cb3fcd2 --- /dev/null +++ b/include/deprecated/mynteye/times.h @@ -0,0 +1 @@ +#include "mynteye/util/times.h" diff --git a/include/deprecated/mynteye/utils.h b/include/deprecated/mynteye/utils.h new file mode 100644 index 0000000..abd0fe2 --- /dev/null +++ b/include/deprecated/mynteye/utils.h @@ -0,0 +1 @@ +#include "mynteye/device/utils.h" diff --git a/src/api/api.h b/include/mynteye/api/api.h similarity index 98% rename from src/api/api.h rename to include/mynteye/api/api.h index a7f0ff8..7374453 100644 --- a/src/api/api.h +++ b/include/mynteye/api/api.h @@ -11,17 +11,17 @@ // 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. -#ifndef MYNTEYE_API_H_ // NOLINT -#define MYNTEYE_API_H_ +#ifndef MYNTEYE_API_API_H_ +#define MYNTEYE_API_API_H_ #pragma once -#include - #include #include #include #include +#include + #include "mynteye/mynteye.h" #include "mynteye/types.h" @@ -49,6 +49,8 @@ struct MYNTEYE_API StreamData { cv::Mat frame; /** Raw frame. */ std::shared_ptr frame_raw; + /** Frame ID. */ + std::uint16_t frame_id; bool operator==(const StreamData &other) const { if (img && other.img) { @@ -280,4 +282,4 @@ class MYNTEYE_API API { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_API_H_ NOLINT +#endif // MYNTEYE_API_API_H_ diff --git a/src/api/processor/object.h b/include/mynteye/api/object.h similarity index 66% rename from src/api/processor/object.h rename to include/mynteye/api/object.h index 808b150..5dd6d82 100644 --- a/src/api/processor/object.h +++ b/include/mynteye/api/object.h @@ -11,18 +11,20 @@ // 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. -#ifndef MYNTEYE_OBJECT_H_ // NOLINT -#define MYNTEYE_OBJECT_H_ +#ifndef MYNTEYE_API_OBJECT_H_ +#define MYNTEYE_API_OBJECT_H_ #pragma once -#include - #include +#include + #include "mynteye/mynteye.h" MYNTEYE_BEGIN_NAMESPACE +struct ImgData; + /** * Input & output object. */ @@ -56,14 +58,22 @@ struct MYNTEYE_API Object { */ struct MYNTEYE_API ObjMat : public Object { ObjMat() = default; - explicit ObjMat(const cv::Mat &value) : value(value) {} + ObjMat(const cv::Mat &value, std::uint16_t id, + const std::shared_ptr &data) + : value(value), id(id), data(data) {} /** The value */ cv::Mat value; + /** The id **/ + std::uint16_t id; + /** The data **/ + std::shared_ptr data; Object *Clone() const { ObjMat *mat = new ObjMat; mat->value = value.clone(); + mat->id = id; + mat->data = data; return mat; } @@ -77,19 +87,35 @@ struct MYNTEYE_API ObjMat : public Object { */ struct MYNTEYE_API ObjMat2 : public Object { ObjMat2() = default; - ObjMat2(const cv::Mat &first, const cv::Mat &second) - : first(first), second(second) {} + ObjMat2(const cv::Mat &first, std::uint16_t first_id, + const std::shared_ptr &first_data, + const cv::Mat &second, std::uint16_t second_id, + const std::shared_ptr &second_data) + : first(first), first_id(first_id), first_data(first_data), + second(second), second_id(second_id), second_data(second_data) {} /** The first value */ cv::Mat first; + /** The first id **/ + std::uint16_t first_id; + /** The first data **/ + std::shared_ptr first_data; /** The second value */ cv::Mat second; + /** The second id **/ + std::uint16_t second_id; + /** The second data **/ + std::shared_ptr second_data; Object *Clone() const { ObjMat2 *mat2 = new ObjMat2; mat2->first = first.clone(); + mat2->first_id = first_id; + mat2->first_data = first_data; mat2->second = second.clone(); + mat2->second_id = second_id; + mat2->second_data = second_data; return mat2; } @@ -100,4 +126,4 @@ struct MYNTEYE_API ObjMat2 : public Object { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_OBJECT_H_ NOLINT +#endif // MYNTEYE_API_OBJECT_H_ diff --git a/src/api/plugin.h b/include/mynteye/api/plugin.h similarity index 89% rename from src/api/plugin.h rename to include/mynteye/api/plugin.h index 325f6bf..181ad59 100644 --- a/src/api/plugin.h +++ b/include/mynteye/api/plugin.h @@ -11,14 +11,14 @@ // 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. -#ifndef MYNTEYE_PLUGIN_H_ // NOLINT -#define MYNTEYE_PLUGIN_H_ +#ifndef MYNTEYE_API_PLUGIN_H_ +#define MYNTEYE_API_PLUGIN_H_ #pragma once -#include - #include +#include + #include "mynteye/mynteye.h" #ifndef MYNTEYE_PLUGIN_VERSION_CODE @@ -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; } @@ -135,6 +135,7 @@ MYNTEYE_API mynteye::Plugin *plugin_create(); * Destroy the plugin. */ MYNTEYE_API void plugin_destroy(mynteye::Plugin *plugin); + } -#endif // MYNTEYE_PLUGIN_H_ NOLINT +#endif // MYNTEYE_API_PLUGIN_H_ diff --git a/include/mynteye/callbacks.h b/include/mynteye/device/callbacks.h similarity index 94% rename from include/mynteye/callbacks.h rename to include/mynteye/device/callbacks.h index d1f2c0c..f1775ce 100644 --- a/include/mynteye/callbacks.h +++ b/include/mynteye/device/callbacks.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_CALLBACKS_H_ // NOLINT -#define MYNTEYE_CALLBACKS_H_ +#ifndef MYNTEYE_DEVICE_CALLBACKS_H_ +#define MYNTEYE_DEVICE_CALLBACKS_H_ #pragma once #include @@ -113,6 +113,8 @@ struct MYNTEYE_API StreamData { std::shared_ptr img; /** Frame. */ std::shared_ptr frame; + /** Frame ID. */ + std::uint16_t frame_id; }; /** @@ -131,4 +133,4 @@ using MotionCallback = std::function; MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_CALLBACKS_H_ NOLINT +#endif // MYNTEYE_DEVICE_CALLBACKS_H_ diff --git a/src/device/context.h b/include/mynteye/device/context.h similarity index 91% rename from src/device/context.h rename to include/mynteye/device/context.h index 487cacf..bedd84f 100644 --- a/src/device/context.h +++ b/include/mynteye/device/context.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_CONTEXT_H_ // NOLINT -#define MYNTEYE_CONTEXT_H_ +#ifndef MYNTEYE_DEVICE_CONTEXT_H_ +#define MYNTEYE_DEVICE_CONTEXT_H_ #pragma once #include @@ -53,4 +53,4 @@ class MYNTEYE_API Context { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_CONTEXT_H_ NOLINT +#endif // MYNTEYE_DEVICE_CONTEXT_H_ diff --git a/src/device/device.h b/include/mynteye/device/device.h similarity index 96% rename from src/device/device.h rename to include/mynteye/device/device.h index 6d11cd2..11ee2fb 100644 --- a/src/device/device.h +++ b/include/mynteye/device/device.h @@ -11,20 +11,19 @@ // 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. -#ifndef MYNTEYE_DEVICE_H_ // NOLINT -#define MYNTEYE_DEVICE_H_ +#ifndef MYNTEYE_DEVICE_DEVICE_H_ +#define MYNTEYE_DEVICE_DEVICE_H_ #pragma once -#include #include #include #include #include #include -#include "mynteye/callbacks.h" #include "mynteye/mynteye.h" #include "mynteye/types.h" +#include "mynteye/device/callbacks.h" MYNTEYE_BEGIN_NAMESPACE @@ -245,8 +244,11 @@ class MYNTEYE_API Device { /** * Enable cache motion datas. */ - void EnableMotionDatas( - std::size_t max_size = std::numeric_limits::max()); + void EnableMotionDatas(); + /** + * Enable cache motion datas. + */ + void EnableMotionDatas(std::size_t max_size); /** * Get the motion datas. */ @@ -322,4 +324,4 @@ class MYNTEYE_API Device { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_DEVICE_H_ NOLINT +#endif // MYNTEYE_DEVICE_DEVICE_H_ diff --git a/include/mynteye/utils.h b/include/mynteye/device/utils.h similarity index 82% rename from include/mynteye/utils.h rename to include/mynteye/device/utils.h index 8f210f7..0b64ce1 100644 --- a/include/mynteye/utils.h +++ b/include/mynteye/device/utils.h @@ -11,11 +11,12 @@ // 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. -#ifndef MYNTEYE_UTILS_H_ // NOLINT -#define MYNTEYE_UTILS_H_ +#ifndef MYNTEYE_DEVICE_UTILS_H_ +#define MYNTEYE_DEVICE_UTILS_H_ #pragma once #include +#include #include "mynteye/mynteye.h" @@ -55,8 +56,22 @@ namespace utils { MYNTEYE_API float get_real_exposure_time( std::int32_t frame_rate, std::uint16_t exposure_time); +/** + * @ingroup utils + * + * Get sdk root dir. + */ +MYNTEYE_API std::string get_sdk_root_dir(); + +/** + * @ingroup utils + * + * Get sdk install dir. + */ +MYNTEYE_API std::string get_sdk_install_dir(); + } // namespace utils MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_UTILS_H_ NOLINT +#endif // MYNTEYE_DEVICE_UTILS_H_ diff --git a/include/mynteye/global.h b/include/mynteye/global.h index 7a58f4e..710d93f 100644 --- a/include/mynteye/global.h +++ b/include/mynteye/global.h @@ -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 + #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 -void unused(T &&...) {} +#define MYNTEYE_UNUSED(x) (void)x; #endif // MYNTEYE_GLOBAL_H_ diff --git a/include/mynteye/glog_init.h b/include/mynteye/logger.h similarity index 84% rename from include/mynteye/glog_init.h rename to include/mynteye/logger.h index e2ac989..83a7642 100644 --- a/include/mynteye/glog_init.h +++ b/include/mynteye/logger.h @@ -11,10 +11,12 @@ // 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. -#ifndef MYNTEYE_GLOG_INIT_H_ // NOLINT -#define MYNTEYE_GLOG_INIT_H_ +#ifndef MYNTEYE_LOGGER_H_ +#define MYNTEYE_LOGGER_H_ #pragma once +#ifdef WITH_GLOG + #include /** Helper to init glog with args. */ @@ -43,7 +45,7 @@ struct glog_init { FLAGS_log_dir = "."; // Sets the maximum log file size (in MB). - FLAGS_max_log_size = 1024; + FLAGS_max_log_size = 8; // Sets whether to avoid logging to the disk if the disk is full. FLAGS_stop_logging_if_full_disk = true; @@ -62,4 +64,20 @@ struct glog_init { } }; -#endif // MYNTEYE_GLOG_INIT_H_ NOLINT +#else + +struct glog_init { + glog_init(int argc, char *argv[]) { + (void)argc; + (void)argv; + // Do nothing. + } +}; + +#define MYNTEYE_MAX_LOG_LEVEL google::INFO + +#include "mynteye/miniglog.h" + +#endif + +#endif // MYNTEYE_LOGGER_H_ diff --git a/include/mynteye/miniglog.h b/include/mynteye/miniglog.h new file mode 100644 index 0000000..02d377a --- /dev/null +++ b/include/mynteye/miniglog.h @@ -0,0 +1,469 @@ +// Ceres Solver - A fast non-linear least squares minimizer +// Copyright 2013 Google Inc. All rights reserved. +// http://code.google.com/p/ceres-solver/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of Google Inc. nor the names of its contributors may be +// used to endorse or promote products derived from this software without +// specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Author: settinger@google.com (Scott Ettinger) +// mierle@gmail.com (Keir Mierle) +// +// Simplified Glog style logging with Android support. Supported macros in +// decreasing severity level per line: +// +// VLOG(2), VLOG(N) +// VLOG(1), +// LOG(INFO), VLOG(0), LG +// LOG(WARNING), +// LOG(ERROR), +// LOG(FATAL), +// +// With VLOG(n), the output is directed to one of the 5 Android log levels: +// +// 2 - Verbose +// 1 - Debug +// 0 - Info +// -1 - Warning +// -2 - Error +// -3 - Fatal +// +// Any logging of level 2 and above is directed to the Verbose level. All +// Android log output is tagged with the string "native". +// +// If the symbol ANDROID is not defined, all output goes to std::cerr. +// This allows code to be built on a different system for debug. +// +// Portions of this code are taken from the GLOG package. This code is only a +// small subset of the GLOG functionality. Notable differences from GLOG +// behavior include lack of support for displaying unprintable characters and +// lack of stack trace information upon failure of the CHECK macros. On +// non-Android systems, log output goes to std::cerr and is not written to a +// file. +// +// CHECK macros are defined to test for conditions within code. Any CHECK that +// fails will log the failure and terminate the application. +// e.g. CHECK_GE(3, 2) will pass while CHECK_GE(3, 4) will fail after logging +// "Check failed 3 >= 4". +// +// The following CHECK macros are defined: +// +// CHECK(condition) - fails if condition is false and logs condition. +// CHECK_NOTNULL(variable) - fails if the variable is NULL. +// +// The following binary check macros are also defined : +// +// Macro Operator equivalent +// -------------------- ------------------- +// CHECK_EQ(val1, val2) val1 == val2 +// CHECK_NE(val1, val2) val1 != val2 +// CHECK_GT(val1, val2) val1 > val2 +// CHECK_GE(val1, val2) val1 >= val2 +// CHECK_LT(val1, val2) val1 < val2 +// CHECK_LE(val1, val2) val1 <= val2 +// +// Debug only versions of all of the check macros are also defined. These +// macros generate no code in a release build, but avoid unused variable +// warnings / errors. +// +// To use the debug only versions, prepend a D to the normal check macros, e.g. +// DCHECK_EQ(a, b). +#ifndef MYNTEYE_MINIGLOG_H_ +#define MYNTEYE_MINIGLOG_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mynteye/mynteye.h" + +#ifdef MYNTEYE_OS_ANDROID +# include +#endif // ANDROID + +// Log severity level constants. +#ifdef MYNTEYE_OS_WIN + +const int FATAL = -1; +#ifndef ERROR // NOT windows.h +const int ERROR = 0; +#endif +const int WARNING = 1; +const int INFO = 2; + +#else + +const int FATAL = -3; +const int ERROR = -2; +const int WARNING = -1; +const int INFO = 0; + +#endif + +// ------------------------- Glog compatibility ------------------------------ + +namespace google { + +typedef int LogSeverity; +const int FATAL = ::FATAL; +#ifndef ERROR // NOT windows.h +const int ERROR = ::ERROR; +#endif +const int WARNING = ::WARNING; +const int INFO = ::INFO; + +// Sink class used for integration with mock and test functions. If sinks are +// added, all log output is also sent to each sink through the send function. +// In this implementation, WaitTillSent() is called immediately after the send. +// This implementation is not thread safe. +class MYNTEYE_API LogSink { + public: + virtual ~LogSink() {} + virtual void send(LogSeverity severity, + const char* full_filename, + const char* base_filename, + int line, + const struct tm* tm_time, + const char* message, + size_t message_len) = 0; + virtual void WaitTillSent() = 0; +}; + +// Global set of log sinks. The actual object is defined in logging.cc. +MYNTEYE_API extern std::set log_sinks_global; + +// Added by chachi - a runtime global maximum log level. Defined in logging.cc +MYNTEYE_API extern int log_severity_global; + +inline void InitGoogleLogging(char */*argv*/) { + // Do nothing; this is ignored. +} + +// Note: the Log sink functions are not thread safe. +inline void AddLogSink(LogSink *sink) { + // TODO(settinger): Add locks for thread safety. + log_sinks_global.insert(sink); +} +inline void RemoveLogSink(LogSink *sink) { + log_sinks_global.erase(sink); +} + +} // namespace google + +// ---------------------------- Logger Class -------------------------------- + +// Class created for each use of the logging macros. +// The logger acts as a stream and routes the final stream contents to the +// Android logcat output at the proper filter level. If ANDROID is not +// defined, output is directed to std::cerr. This class should not +// be directly instantiated in code, rather it should be invoked through the +// use of the log macros LG, LOG, or VLOG. +class MYNTEYE_API MessageLogger { + public: + MessageLogger(const char *file, int line, const char *tag, int severity) + : file_(file), line_(line), tag_(tag), severity_(severity) { + // Pre-pend the stream with the file and line number. + StripBasename(std::string(file), &filename_only_); + stream_ << SeverityLabel() << "/" << filename_only_ << ":" << line << " "; + } + + // Output the contents of the stream to the proper channel on destruction. + ~MessageLogger() { + stream_ << "\n"; + +#ifdef MYNTEYE_OS_ANDROID + static const int android_log_levels[] = { + ANDROID_LOG_FATAL, // LOG(FATAL) + ANDROID_LOG_ERROR, // LOG(ERROR) + ANDROID_LOG_WARN, // LOG(WARNING) + ANDROID_LOG_INFO, // LOG(INFO), LG, VLOG(0) + ANDROID_LOG_DEBUG, // VLOG(1) + ANDROID_LOG_VERBOSE, // VLOG(2) .. VLOG(N) + }; + + // Bound the logging level. + const int kMaxVerboseLevel = 2; + int android_level_index = std::min(std::max(FATAL, severity_), + kMaxVerboseLevel) - FATAL; + int android_log_level = android_log_levels[android_level_index]; + + // Output the log string the Android log at the appropriate level. + __android_log_write(android_log_level, tag_.c_str(), stream_.str().c_str()); + + // Indicate termination if needed. + if (severity_ == FATAL) { + __android_log_write(ANDROID_LOG_FATAL, + tag_.c_str(), + "terminating.\n"); + } +#else + // If not building on Android, log all output to std::cerr. + std::cerr << stream_.str(); +#endif // ANDROID + + LogToSinks(severity_); + WaitForSinks(); + + // Android logging at level FATAL does not terminate execution, so abort() + // is still required to stop the program. + if (severity_ == FATAL) { + abort(); + } + } + + // Return the stream associated with the logger object. + std::stringstream &stream() { return stream_; } + + private: + void LogToSinks(int severity) { + time_t rawtime; + struct tm* timeinfo; + + time (&rawtime); + timeinfo = localtime(&rawtime); + std::set::iterator iter; + // Send the log message to all sinks. + for (iter = google::log_sinks_global.begin(); + iter != google::log_sinks_global.end(); ++iter) { + (*iter)->send(severity, file_.c_str(), filename_only_.c_str(), line_, + timeinfo, stream_.str().c_str(), stream_.str().size()); + } + } + + void WaitForSinks() { + // TODO(settinger): Add locks for thread safety. + std::set::iterator iter; + + // Call WaitTillSent() for all sinks. + for (iter = google::log_sinks_global.begin(); + iter != google::log_sinks_global.end(); ++iter) { + (*iter)->WaitTillSent(); + } + } + + void StripBasename(const std::string &full_path, std::string *filename) { + // TODO(settinger): Add support for OSs with different path separators. + // const char kSeparator = '/'; + size_t pos = full_path.rfind(MYNTEYE_OS_SEP); + if (pos != std::string::npos) { + *filename = full_path.substr(pos + 1, std::string::npos); + } else { + *filename = full_path; + } + } + + char SeverityLabel() { + switch (severity_) { + case INFO: + return 'I'; + case WARNING: + return 'W'; + case ERROR: + return 'E'; + case FATAL: + return 'F'; + default: + return 'V'; + } + } + + std::string file_; + std::string filename_only_; + int line_; + std::string tag_; + std::stringstream stream_; + int severity_; +}; + +// ---------------------- Logging Macro definitions -------------------------- + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". +class MYNTEYE_API LoggerVoidify { + public: + LoggerVoidify() { } + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(const std::ostream &/*s*/) { } +}; + +// Log only if condition is met. Otherwise evaluates to void. +#define LOG_IF(severity, condition) \ + (static_cast(severity) > google::log_severity_global || !(condition)) ? \ + (void) 0 : LoggerVoidify() & \ + MessageLogger((char *)__FILE__, __LINE__, "native", severity).stream() + +// Log only if condition is NOT met. Otherwise evaluates to void. +#define LOG_IF_FALSE(severity, condition) LOG_IF(severity, !(condition)) + +// 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 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) LOG_IF(n, true) +# define VLOG(n) LOG_IF(n, true) +# define LG LOG_IF(INFO, true) +# define VLOG_IF(n, condition) LOG_IF(n, condition) +#endif + +// 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 <= MYNTEYE_MAX_LOG_LEVEL) +#endif + +#ifdef MYNTEYE_OS_WIN // INFO is 2, change VLOG(2) to VLOG(4) +#undef VLOG +#undef VLOG_IF +#undef VLOG_IS_ON + +#ifdef MYNTEYE_MAX_LOG_LEVEL +# define VLOG(n) LOG_IF(n+2, (n+2 <= MYNTEYE_MAX_LOG_LEVEL)) +# define VLOG_IF(n, condition) \ + LOG_IF(n+2, (n+2 <= MYNTEYE_MAX_LOG_LEVEL) && condition) +#else +# define VLOG(n) LOG_IF(n+2, true) +# define VLOG_IF(n, condition) LOG_IF(n+2, condition) +#endif + +#ifndef MYNTEYE_MAX_LOG_LEVEL +# define VLOG_IS_ON(x) (1+2) +#else +# define VLOG_IS_ON(x) (x+2 <= MYNTEYE_MAX_LOG_LEVEL) +#endif + +#endif + +#ifndef NDEBUG +# define DLOG LOG +#else +# define DLOG(severity) true ? (void) 0 : LoggerVoidify() & \ + MessageLogger((char *)__FILE__, __LINE__, "native", severity).stream() +#endif + + +// Log a message and terminate. +template +void LogMessageFatal(const char *file, int line, const T &message) { + MessageLogger(file, line, "native", FATAL).stream() << message; +} + +// ---------------------------- CHECK macros --------------------------------- + +// Check for a given boolean condition. +#define CHECK(condition) LOG_IF_FALSE(FATAL, condition) \ + << "Check failed: " #condition " " + +#ifndef NDEBUG +// Debug only version of CHECK +# define DCHECK(condition) LOG_IF_FALSE(FATAL, condition) \ + << "Check failed: " #condition " " +#else +// Optimized version - generates no code. +# define DCHECK(condition) if (false) LOG_IF_FALSE(FATAL, condition) \ + << "Check failed: " #condition " " +#endif // NDEBUG + +// ------------------------- CHECK_OP macros --------------------------------- + +// Generic binary operator check macro. This should not be directly invoked, +// instead use the binary comparison macros defined below. +#define CHECK_OP(val1, val2, op) LOG_IF_FALSE(FATAL, (val1 op val2)) \ + << "Check failed: " #val1 " " #op " " #val2 " " + +// Check_op macro definitions +#define CHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) +#define CHECK_NE(val1, val2) CHECK_OP(val1, val2, !=) +#define CHECK_LE(val1, val2) CHECK_OP(val1, val2, <=) +#define CHECK_LT(val1, val2) CHECK_OP(val1, val2, <) +#define CHECK_GE(val1, val2) CHECK_OP(val1, val2, >=) +#define CHECK_GT(val1, val2) CHECK_OP(val1, val2, >) + +#ifndef NDEBUG +// Debug only versions of CHECK_OP macros. +# define DCHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) +# define DCHECK_NE(val1, val2) CHECK_OP(val1, val2, !=) +# define DCHECK_LE(val1, val2) CHECK_OP(val1, val2, <=) +# define DCHECK_LT(val1, val2) CHECK_OP(val1, val2, <) +# define DCHECK_GE(val1, val2) CHECK_OP(val1, val2, >=) +# define DCHECK_GT(val1, val2) CHECK_OP(val1, val2, >) +#else +// These versions generate no code in optimized mode. +# define DCHECK_EQ(val1, val2) if (false) CHECK_OP(val1, val2, ==) +# define DCHECK_NE(val1, val2) if (false) CHECK_OP(val1, val2, !=) +# define DCHECK_LE(val1, val2) if (false) CHECK_OP(val1, val2, <=) +# define DCHECK_LT(val1, val2) if (false) CHECK_OP(val1, val2, <) +# define DCHECK_GE(val1, val2) if (false) CHECK_OP(val1, val2, >=) +# define DCHECK_GT(val1, val2) if (false) CHECK_OP(val1, val2, >) +#endif // NDEBUG + +// ---------------------------CHECK_NOTNULL macros --------------------------- + +// Helpers for CHECK_NOTNULL(). Two are necessary to support both raw pointers +// and smart pointers. +template +T& CheckNotNullCommon(const char *file, int line, const char *names, T& t) { + if (t == NULL) { + LogMessageFatal(file, line, std::string(names)); + } + return t; +} + +template +T* CheckNotNull(const char *file, int line, const char *names, T* t) { + return CheckNotNullCommon(file, line, names, t); +} + +template +T& CheckNotNull(const char *file, int line, const char *names, T& t) { + return CheckNotNullCommon(file, line, names, t); +} + +// Check that a pointer is not null. +#define CHECK_NOTNULL(val) \ + CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) + +#ifndef NDEBUG +// Debug only version of CHECK_NOTNULL +#define DCHECK_NOTNULL(val) \ + CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) +#else +// Optimized version - generates no code. +#define DCHECK_NOTNULL(val) if (false)\ + CheckNotNull(__FILE__, __LINE__, "'" #val "' Must be non NULL", (val)) +#endif // NDEBUG + +#endif // MYNTEYE_MINIGLOG_H_ diff --git a/include/mynteye/mynteye.h.in b/include/mynteye/mynteye.h.in index c2c8eff..ee58cdf 100644 --- a/include/mynteye/mynteye.h.in +++ b/include/mynteye/mynteye.h.in @@ -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 @@ -45,7 +45,7 @@ MYNTEYE_API_VERSION_CHECK( \ ((major<<16)|(minor<<8)|(patch)) // NOLINT /* MYNTEYE_API_VERSION in "X.Y.Z" format */ -#define MYNTEYE_API_VERSION_STR (STRINGIFY(MYNTEYE_API_VERSION_MAJOR.MYNTEYE_API_VERSION_MINOR.MYNTEYE_API_VERSION_PATCH)) // NOLINT +#define MYNTEYE_API_VERSION_STR (MYNTEYE_STRINGIFY(MYNTEYE_API_VERSION_MAJOR.MYNTEYE_API_VERSION_MINOR.MYNTEYE_API_VERSION_PATCH)) // NOLINT #cmakedefine MYNTEYE_NAMESPACE @MYNTEYE_NAMESPACE@ #if defined(MYNTEYE_NAMESPACE) @@ -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 +void UNUSED(T &&...) {} + +MYNTEYE_END_NAMESPACE + #endif // MYNTEYE_MYNTEYE_H_ diff --git a/include/mynteye/types.h b/include/mynteye/types.h index 0ab79fd..b622acd 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -11,7 +11,7 @@ // 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. -#ifndef MYNTEYE_TYPES_H_ // NOLINT +#ifndef MYNTEYE_TYPES_H_ #define MYNTEYE_TYPES_H_ #pragma once @@ -195,6 +195,18 @@ enum class Option : std::uint8_t { ZERO_DRIFT_CALIBRATION, /** Erase chip */ ERASE_CHIP, + /** + * The range of accelerometer + * + * values: {4,8,16,32}, default: 8 + */ + ACCELEROMETER_RANGE, + /** + * The range of gyroscope + * + * values: {500,1000,2000,4000}, default: 1000 + */ + GYROSCOPE_RANGE, /** Last guard */ LAST }; @@ -483,4 +495,4 @@ std::ostream &operator<<(std::ostream &os, const OptionInfo &info); MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_TYPES_H_ NOLINT +#endif // MYNTEYE_TYPES_H_ diff --git a/src/internal/files.h b/include/mynteye/util/files.h similarity index 86% rename from src/internal/files.h rename to include/mynteye/util/files.h index 1f9b402..0ac6ca0 100644 --- a/src/internal/files.h +++ b/include/mynteye/util/files.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_INTERNAL_FILES_H_ // NOLINT -#define MYNTEYE_INTERNAL_FILES_H_ +#ifndef MYNTEYE_UTIL_FILES_H_ +#define MYNTEYE_UTIL_FILES_H_ #pragma once #include @@ -29,4 +29,4 @@ MYNTEYE_API bool mkdir(const std::string &path); MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_INTERNAL_FILES_H_ NOLINT +#endif // MYNTEYE_UTIL_FILES_H_ diff --git a/src/internal/strings.h b/include/mynteye/util/strings.h similarity index 92% rename from src/internal/strings.h rename to include/mynteye/util/strings.h index a6ccdcd..d297464 100644 --- a/src/internal/strings.h +++ b/include/mynteye/util/strings.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_INTERNAL_STRINGS_H_ // NOLINT -#define MYNTEYE_INTERNAL_STRINGS_H_ +#ifndef MYNTEYE_UTIL_STRINGS_H_ +#define MYNTEYE_UTIL_STRINGS_H_ #pragma once #include @@ -59,4 +59,4 @@ std::string trim_copy(const std::string &text); MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_INTERNAL_STRINGS_H_ NOLINT +#endif // MYNTEYE_UTIL_STRINGS_H_ diff --git a/src/internal/times.h b/include/mynteye/util/times.h similarity index 97% rename from src/internal/times.h rename to include/mynteye/util/times.h index 266973a..c1e8038 100644 --- a/src/internal/times.h +++ b/include/mynteye/util/times.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_INTERNAL_TIMES_H_ // NOLINT -#define MYNTEYE_INTERNAL_TIMES_H_ +#ifndef MYNTEYE_UTIL_TIMES_H_ +#define MYNTEYE_UTIL_TIMES_H_ #pragma once #include @@ -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; @@ -220,4 +220,4 @@ inline std::string to_utc_string( MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_INTERNAL_TIMES_H_ NOLINT +#endif // MYNTEYE_UTIL_TIMES_H_ diff --git a/mynteye-config.cmake.in b/mynteye-config.cmake.in index aaeb16a..3514b78 100644 --- a/mynteye-config.cmake.in +++ b/mynteye-config.cmake.in @@ -14,4 +14,7 @@ @PACKAGE_INIT@ +set(mynteye_WITH_API @WITH_API@) +set(mynteye_WITH_GLOG @WITH_GLOG@) + include("${CMAKE_CURRENT_LIST_DIR}/mynteye-targets.cmake") diff --git a/platforms/projects/vs2017/README.md b/platforms/projects/vs2017/README.md new file mode 100644 index 0000000..982839b --- /dev/null +++ b/platforms/projects/vs2017/README.md @@ -0,0 +1,76 @@ +# How to use MYNT® EYE S SDK with Visual Studio 2017 + +This tutorial will create a project with Visual Studio 2017 to start using MYNT® EYE S SDK. + +## Preparation + +Install the win pack of MYNT® EYE S SDK. + +## Create Project + +Open Visual Studio 2017, then `File > New > Project`, + +![](images/1_new_pro.png) + +Select "Windows Console Application", set the project's name and location, click "OK", + +![](images/2_new_pro.png) + +Finally, you will see the new project like this, + +![](images/3_new_pro.png) + +## Config Properties + +Right click the project, and open its "Properties" window, + +![](images/4_config.png) + +Change "Configuration" to "All Configurations", then add the following paths to "Additional Include Directories", + +```bash +$(MYNTEYES_SDK_ROOT)\include +$(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\include +``` + +![](images/5_config_include.png) + +Add the following paths to "Additional Library Directories", + +```bash +$(MYNTEYES_SDK_ROOT)\lib +$(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\x64\vc15\lib +``` + +![](images/6_config_lib_dir.png) + + +Add the following libs to "Additional Dependencies", + +```bash +mynteye.lib +opencv_world343.lib +``` + +![](images/7_config_lib.png) + +If you wanna debug, could change "Configuration" to "Debug" and add these debug libs, + +```bash +mynteyed.lib +opencv_world343d.lib +``` + +![](images/8_config_debug_lib.png) + +## Start using SDK + +Include the headers of SDK and start using its APIs, + +![](images/9_run_x64.png) + +Select "Release x64" or "Debug x64" to run the project. + + diff --git a/platforms/projects/vs2017/images/10_path.png b/platforms/projects/vs2017/images/10_path.png new file mode 100644 index 0000000..7254149 Binary files /dev/null and b/platforms/projects/vs2017/images/10_path.png differ diff --git a/platforms/projects/vs2017/images/1_new_pro.png b/platforms/projects/vs2017/images/1_new_pro.png new file mode 100644 index 0000000..2c50214 Binary files /dev/null and b/platforms/projects/vs2017/images/1_new_pro.png differ diff --git a/platforms/projects/vs2017/images/2_new_pro.png b/platforms/projects/vs2017/images/2_new_pro.png new file mode 100644 index 0000000..f46d196 Binary files /dev/null and b/platforms/projects/vs2017/images/2_new_pro.png differ diff --git a/platforms/projects/vs2017/images/3_new_pro.png b/platforms/projects/vs2017/images/3_new_pro.png new file mode 100644 index 0000000..8e80228 Binary files /dev/null and b/platforms/projects/vs2017/images/3_new_pro.png differ diff --git a/platforms/projects/vs2017/images/4_config.png b/platforms/projects/vs2017/images/4_config.png new file mode 100644 index 0000000..29f4a9c Binary files /dev/null and b/platforms/projects/vs2017/images/4_config.png differ diff --git a/platforms/projects/vs2017/images/5_config_include.png b/platforms/projects/vs2017/images/5_config_include.png new file mode 100644 index 0000000..9a8aa35 Binary files /dev/null and b/platforms/projects/vs2017/images/5_config_include.png differ diff --git a/platforms/projects/vs2017/images/6_config_lib_dir.png b/platforms/projects/vs2017/images/6_config_lib_dir.png new file mode 100644 index 0000000..b9518ba Binary files /dev/null and b/platforms/projects/vs2017/images/6_config_lib_dir.png differ diff --git a/platforms/projects/vs2017/images/7_config_lib.png b/platforms/projects/vs2017/images/7_config_lib.png new file mode 100644 index 0000000..1336081 Binary files /dev/null and b/platforms/projects/vs2017/images/7_config_lib.png differ diff --git a/platforms/projects/vs2017/images/8_config_debug_lib.png b/platforms/projects/vs2017/images/8_config_debug_lib.png new file mode 100644 index 0000000..f4ec94f Binary files /dev/null and b/platforms/projects/vs2017/images/8_config_debug_lib.png differ diff --git a/platforms/projects/vs2017/images/9_run_x64.png b/platforms/projects/vs2017/images/9_run_x64.png new file mode 100644 index 0000000..9ff0e51 Binary files /dev/null and b/platforms/projects/vs2017/images/9_run_x64.png differ diff --git a/platforms/projects/vs2017/mynteyes_demo/.gitignore b/platforms/projects/vs2017/mynteyes_demo/.gitignore new file mode 100644 index 0000000..9d0a5a9 --- /dev/null +++ b/platforms/projects/vs2017/mynteyes_demo/.gitignore @@ -0,0 +1,4 @@ +/.vs/ +/x64/ +/mynteyes_demo/x64/ +/mynteyes_demo/*.user diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo.sln b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo.sln new file mode 100644 index 0000000..9a23cf5 --- /dev/null +++ b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2018 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mynteyes_demo", "mynteyes_demo\mynteyes_demo.vcxproj", "{49798F84-3EA3-4CB5-A873-6163DB4B4A43}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Debug|x64.ActiveCfg = Debug|x64 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Debug|x64.Build.0 = Debug|x64 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Debug|x86.ActiveCfg = Debug|Win32 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Debug|x86.Build.0 = Debug|Win32 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Release|x64.ActiveCfg = Release|x64 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Release|x64.Build.0 = Release|x64 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Release|x86.ActiveCfg = Release|Win32 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F6C50224-4EC6-46EB-AA63-7E32FC6F0648} + EndGlobalSection +EndGlobal diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.cpp b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.cpp new file mode 100644 index 0000000..02233b7 Binary files /dev/null and b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.cpp differ diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj new file mode 100644 index 0000000..9ad85b5 --- /dev/null +++ b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj @@ -0,0 +1,177 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {49798F84-3EA3-4CB5-A873-6163DB4B4A43} + Win32Proj + mynteyesdemo + 10.0.17134.0 + + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\include;$(MYNTEYES_SDK_ROOT)\include;%(AdditionalIncludeDirectories) + + + Console + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\x64\vc15\lib;$(MYNTEYES_SDK_ROOT)\lib;%(AdditionalLibraryDirectories) + mynteyed.lib;opencv_world343d.lib;%(AdditionalDependencies) + + + + + Use + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\include;$(MYNTEYES_SDK_ROOT)\include;%(AdditionalIncludeDirectories) + + + Console + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\x64\vc15\lib;$(MYNTEYES_SDK_ROOT)\lib;%(AdditionalLibraryDirectories) + mynteyed.lib;opencv_world343d.lib;%(AdditionalDependencies) + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\include;$(MYNTEYES_SDK_ROOT)\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\x64\vc15\lib;$(MYNTEYES_SDK_ROOT)\lib;%(AdditionalLibraryDirectories) + mynteye.lib;opencv_world343.lib;%(AdditionalDependencies) + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\include;$(MYNTEYES_SDK_ROOT)\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + $(MYNTEYES_SDK_ROOT)\3rdparty\opencv\build\x64\vc15\lib;$(MYNTEYES_SDK_ROOT)\lib;%(AdditionalLibraryDirectories) + mynteye.lib;opencv_world343.lib;%(AdditionalDependencies) + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj.filters b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj.filters new file mode 100644 index 0000000..182978b --- /dev/null +++ b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.cpp b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.cpp new file mode 100644 index 0000000..d289662 Binary files /dev/null and b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.cpp differ diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.h b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.h new file mode 100644 index 0000000..94d4ed8 Binary files /dev/null and b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/stdafx.h differ diff --git a/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/targetver.h b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/targetver.h new file mode 100644 index 0000000..567cd34 Binary files /dev/null and b/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/targetver.h differ diff --git a/platforms/win/README.txt b/platforms/win/README.txt new file mode 100644 index 0000000..7969b73 --- /dev/null +++ b/platforms/win/README.txt @@ -0,0 +1,176 @@ +# MYNT® EYE S SDK + +################################################################################ +Language: 简体中文 +################################################################################ + +## 如何开始使用 SDK + +1) 运行样例程序 + +安装完 SDK 的 exe 安装包后,桌面会生成 SDK 根目录的快捷方式。 + +进入 "\bin\samples\tutorials" 目录,双击 "get_stereo.exe" 运行,即可看到双目实时画面。 + +2)生成样例工程 + +首先,安装好 Visual Studio 2017 和 CMake 。 + +接着,进入 "\samples" 目录, 双击 "generate.bat" 即可生成样例工程。 + +p.s. 样例教程,可见 https://slightech.github.io/MYNT-EYE-S-SDK/ 主页给出的 Guide 文档。 + +p.p.s. 运行结果,参考下方英文内容。 + +3)如何于 Visual Studio 2017 下使用 SDK + +进入 "\projects\vs2017" ,见 "README.md" 说明。 + +################################################################################ +Language: English +################################################################################ + +## How to start using SDK + +1) Run the prebuilt samples, ensure the SDK works well. + +After you install the win pack of SDK, there will be a shortcut to the SDK root directory on your desktop. + +First, you should plug the MYNT® EYE camera in a USB 3.0 port. + +Second, goto the "\bin\samples\tutorials" directory and click "get_stereo.exe" to run. + +Finally, you will see the window that display the realtime frame of the camera. + +2) Generate samples project of Visual Studio 2017. + +First, you should install Visual Studio 2017 and CMake . + +Second, goto the "\samples" directory and click "generate.bat" to run. + +Finally, you could click `_build\mynteye_samples.sln` to open the samples project. + +p.s. The tutorials of samples are here: https://slightech.github.io/MYNT-EYE-S-SDK-Guide/src/data/contents.html. + +p.p.s. The example result of "generate.bat", + +```cmd +-- The C compiler identification is MSVC 19.14.26429.4 +-- The CXX compiler identification is MSVC 19.14.26429.4 +-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x64/cl.exe +-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x64/cl.exe -- works +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - done +-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x64/cl.exe +-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x64/cl.exe -- works +-- Detecting CXX compiler ABI info +-- Detecting CXX compiler ABI info - done +-- Detecting CXX compile features +-- Detecting CXX compile features - done +-- HOST_ARCH: x86_64 +-- OpenCV ARCH: x64 +-- OpenCV RUNTIME: vc15 +-- OpenCV STATIC: OFF +-- Found OpenCV: C:/Users/John/AppData/Roaming/Slightech/MYNTEYES/SDK/2.2.1/3rdparty/opencv/build (found version "3.4.3") +-- Found OpenCV 3.4.3 in C:/Users/John/AppData/Roaming/Slightech/MYNTEYES/SDK/2.2.1/3rdparty/opencv/build/x64/vc15/lib +-- You might need to add C:\Users\John\AppData\Roaming\Slightech\MYNTEYES\SDK\2.2.1\3rdparty\opencv\build\x64\vc15\bin to your PATH to be able to run your applications. +-- Found OpenCV: 3.4.3 +CMake Warning at C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:567 (message): + Imported targets and dependency information not available for Boost version + (all versions older than 1.33) +Call Stack (most recent call first): + C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:907 (_Boost_COMPONENT_DEPENDENCIES) + C:/Program Files/CMake/share/cmake-3.10/Modules/FindBoost.cmake:1542 (_Boost_MISSING_DEPENDENCIES) + C:/Users/John/AppData/Roaming/Slightech/MYNTEYES/SDK/2.2.1/cmake/Option.cmake:47 (find_package) + CMakeLists.txt:26 (include) + + +-- Could NOT find Boost +-- +-- Platform: +-- HOST_OS: Win +-- HOST_NAME: Win +-- HOST_ARCH: x86_64 +-- HOST_COMPILER: MSVC +-- COMPILER_VERSION: 19.14.26429.4 +-- COMPILER_VERSION_MAJOR: 19 +-- COMPILER_VERSION_MINOR: 14 +-- COMPILER_VERSION_PATCH: 26429 +-- COMPILER_VERSION_TWEAK: 4 +-- CUDA_VERSION: 9.2 +-- CUDA_VERSION_MAJOR: 9 +-- CUDA_VERSION_MINOR: 2 +-- CUDA_VERSION_STRING: 9.2 +-- OpenCV_VERSION: 3.4.3 +-- OpenCV_VERSION_MAJOR: 3 +-- OpenCV_VERSION_MINOR: 4 +-- OpenCV_VERSION_PATCH: 3 +-- OpenCV_VERSION_TWEAK: 0 +-- OpenCV_VERSION_STATUS: +-- OpenCV_WITH_WORLD: TRUE +-- +-- Options: +-- WITH_API: ON +-- OpenCV: YES +-- OpenCV_VERSION: 3.4.3 +-- OpenCV_WORLD: YES +-- WITH_DEVICE_INFO_REQUIRED: ON +-- WITH_BOOST: ON +-- Boost: NO +-- WITH_GLOG: OFF +-- +-- Features: +-- Filesystem: native +-- +-- Visual Studio >= 2010, MSVC >= 10.0 +-- C_FLAGS: /DWIN32 /D_WINDOWS /W3 -Wall -march=native +-- CXX_FLAGS: /DWIN32 /D_WINDOWS /W3 /GR /EHsc -Wall -march=native +-- Found mynteye: 2.2.1 +-- Generating camera_a.bat +-- Generating get_depth_with_region.bat +-- Generating camera_d.bat +-- Generating camera_u.bat +CMake Warning at tutorials/CMakeLists.txt:70 (find_package): + By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has + asked CMake to find a package configuration file provided by "PCL", but + CMake did not find one. + + Could not find a package configuration file provided by "PCL" with any of + the following names: + + PCLConfig.cmake + pcl-config.cmake + + Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR" + to a directory containing one of the above files. If "PCL" provides a + separate development package or SDK, be sure it has been installed. + + +CMake Warning at tutorials/CMakeLists.txt:86 (message): + PCL not found :( + + +-- Generating get_device_info.bat +-- Generating get_img_params.bat +-- Generating get_imu_params.bat +-- Generating get_stereo.bat +-- Generating get_stereo_rectified.bat +-- Generating get_disparity.bat +-- Generating get_depth.bat +-- Generating get_imu.bat +-- Generating get_from_callbacks.bat +-- Generating get_with_plugin.bat +-- Generating ctrl_framerate.bat +-- Generating ctrl_auto_exposure.bat +-- Generating ctrl_manual_exposure.bat +-- Generating ctrl_infrared.bat +-- Generating get_all_device_info.bat +-- Configuring done +-- Generating done +-- Build files have been written to: C:/Users/John/AppData/Roaming/Slightech/MYNTEYES/SDK/2.2.1/samples/_build +Press any key to continue . . . +``` + +3) Start using MYNT® EYE S SDK with Visual Studio 2017 + +Goto the "\projects\vs2017", see the "README.md". diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 2a0c4c6..4781867 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -47,10 +47,6 @@ message(STATUS "CXX_FLAGS: ${CMAKE_CXX_FLAGS}") # packages -LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/third_party/glog/_build) -find_package(glog REQUIRED) -message(STATUS "Found glog: ${glog_VERSION}") - LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake) find_package(mynteye REQUIRED) message(STATUS "Found mynteye: ${mynteye_VERSION}") diff --git a/samples/api/camera.cc b/samples/api/camera.cc index 5cddd85..0d10a54 100644 --- a/samples/api/camera.cc +++ b/samples/api/camera.cc @@ -13,10 +13,9 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" -#include "mynteye/times.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" +#include "mynteye/util/times.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/api/get_depth_with_region.cc b/samples/api/get_depth_with_region.cc index 0bd075c..560b279 100644 --- a/samples/api/get_depth_with_region.cc +++ b/samples/api/get_depth_with_region.cc @@ -14,9 +14,7 @@ #include #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" namespace { @@ -31,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; } @@ -163,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"; @@ -186,7 +184,7 @@ int main(int argc, char *argv[]) { // Show disparity instead of depth, but show depth values in region. auto &&depth_frame = disp_data.frame; -#ifdef USE_OPENCV3 +#ifdef WITH_OPENCV3 // ColormapTypes // http://docs.opencv.org/master/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65 cv::applyColorMap(depth_frame, depth_frame, cv::COLORMAP_JET); diff --git a/samples/device/camera.cc b/samples/device/camera.cc index bcd9695..85af2ed 100644 --- a/samples/device/camera.cc +++ b/samples/device/camera.cc @@ -14,12 +14,10 @@ #include #include -#include "mynteye/glog_init.h" - -#include "mynteye/device.h" -#include "mynteye/utils.h" - -#include "mynteye/times.h" +#include "mynteye/logger.h" +#include "mynteye/device/device.h" +#include "mynteye/device/utils.h" +#include "mynteye/util/times.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/CMakeLists.txt b/samples/tutorials/CMakeLists.txt index 6021b30..4f4696b 100644 --- a/samples/tutorials/CMakeLists.txt +++ b/samples/tutorials/CMakeLists.txt @@ -114,6 +114,7 @@ make_executable2(get_with_plugin SRCS data/get_with_plugin.cc WITH_OPENCV) ## control make_executable2(ctrl_framerate SRCS control/framerate.cc WITH_OPENCV) +make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV) make_executable2(ctrl_auto_exposure SRCS control/auto_exposure.cc util/cv_painter.cc WITH_OPENCV diff --git a/samples/tutorials/control/auto_exposure.cc b/samples/tutorials/control/auto_exposure.cc index efe77e6..0a18547 100644 --- a/samples/tutorials/control/auto_exposure.cc +++ b/samples/tutorials/control/auto_exposure.cc @@ -13,9 +13,8 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" #include "util/cv_painter.h" diff --git a/samples/tutorials/control/framerate.cc b/samples/tutorials/control/framerate.cc index 1d05755..3236bf0 100644 --- a/samples/tutorials/control/framerate.cc +++ b/samples/tutorials/control/framerate.cc @@ -11,14 +11,13 @@ // 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. -#include - -#include - #include -#include "mynteye/api.h" -#include "mynteye/times.h" +#include + +#include "mynteye/logger.h" +#include "mynteye/api/api.h" +#include "mynteye/util/times.h" MYNTEYE_USE_NAMESPACE @@ -30,7 +29,7 @@ int main(int argc, char *argv[]) { // Attention: must set FRAME_RATE and IMU_FREQUENCY together, otherwise won't // succeed. - // FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 + // FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 api->SetOptionValue(Option::FRAME_RATE, 25); // IMU_FREQUENCY values: 100, 200, 250, 333, 500 api->SetOptionValue(Option::IMU_FREQUENCY, 500); diff --git a/samples/tutorials/control/imu_range.cc b/samples/tutorials/control/imu_range.cc new file mode 100644 index 0000000..0b0ba32 --- /dev/null +++ b/samples/tutorials/control/imu_range.cc @@ -0,0 +1,89 @@ +// 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. +#include + +#include + +#include "mynteye/logger.h" +#include "mynteye/api/api.h" +#include "mynteye/util/times.h" + +MYNTEYE_USE_NAMESPACE + +int main(int argc, char *argv[]) { + auto &&api = API::Create(argc, argv); + if (!api) + return 1; + + // ACCELEROMETER_RANGE values: 4, 8, 16, 32 + api->SetOptionValue(Option::ACCELEROMETER_RANGE, 8); + // GYROSCOPE_RANGE values: 500, 1000, 2000, 4000 + api->SetOptionValue(Option::GYROSCOPE_RANGE, 1000); + + LOG(INFO) << "Set ACCELEROMETER_RANGE to " + << api->GetOptionValue(Option::ACCELEROMETER_RANGE); + LOG(INFO) << "Set GYROSCOPE_RANGE to " + << api->GetOptionValue(Option::GYROSCOPE_RANGE); + + // Count img + std::atomic_uint img_count(0); + api->SetStreamCallback( + Stream::LEFT, [&img_count](const api::StreamData &data) { + CHECK_NOTNULL(data.img); + ++img_count; + }); + + // Count imu + std::atomic_uint imu_count(0); + api->SetMotionCallback([&imu_count](const api::MotionData &data) { + CHECK_NOTNULL(data.imu); + ++imu_count; + }); + + api->Start(Source::ALL); + + cv::namedWindow("frame"); + + auto &&time_beg = times::now(); + while (true) { + api->WaitForStreams(); + + auto &&left_data = api->GetStreamData(Stream::LEFT); + auto &&right_data = api->GetStreamData(Stream::RIGHT); + + cv::Mat img; + cv::hconcat(left_data.frame, right_data.frame, img); + cv::imshow("frame", img); + + char key = static_cast(cv::waitKey(1)); + if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q + break; + } + } + auto &&time_end = times::now(); + + api->Stop(Source::ALL); + + // Calculate img fps and imu hz + float elapsed_ms = + times::count(time_end - time_beg) * 0.001f; + LOG(INFO) << "Time beg: " << times::to_local_string(time_beg) + << ", end: " << times::to_local_string(time_end) + << ", cost: " << elapsed_ms << "ms"; + LOG(INFO) << "Img count: " << img_count + << ", fps: " << (1000.f * img_count / elapsed_ms); + LOG(INFO) << "Imu count: " << imu_count + << ", hz: " << (1000.f * imu_count / elapsed_ms); + return 0; +} diff --git a/samples/tutorials/control/infrared.cc b/samples/tutorials/control/infrared.cc index 7ed6286..a6310a7 100644 --- a/samples/tutorials/control/infrared.cc +++ b/samples/tutorials/control/infrared.cc @@ -13,9 +13,8 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/control/manual_exposure.cc b/samples/tutorials/control/manual_exposure.cc index 38afa32..16ce32e 100644 --- a/samples/tutorials/control/manual_exposure.cc +++ b/samples/tutorials/control/manual_exposure.cc @@ -13,9 +13,8 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" #include "util/cv_painter.h" diff --git a/samples/tutorials/data/get_depth.cc b/samples/tutorials/data/get_depth.cc index 274c8ee..e973967 100644 --- a/samples/tutorials/data/get_depth.cc +++ b/samples/tutorials/data/get_depth.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_device_info.cc b/samples/tutorials/data/get_device_info.cc index ee41348..5217c36 100644 --- a/samples/tutorials/data/get_device_info.cc +++ b/samples/tutorials/data/get_device_info.cc @@ -11,9 +11,8 @@ // 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. -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_disparity.cc b/samples/tutorials/data/get_disparity.cc index 5a9f798..243d81e 100644 --- a/samples/tutorials/data/get_disparity.cc +++ b/samples/tutorials/data/get_disparity.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_from_callbacks.cc b/samples/tutorials/data/get_from_callbacks.cc index cb51875..27c30a4 100644 --- a/samples/tutorials/data/get_from_callbacks.cc +++ b/samples/tutorials/data/get_from_callbacks.cc @@ -11,16 +11,15 @@ // 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. -#include - -#include - #include #include #include #include -#include "mynteye/api.h" +#include + +#include "mynteye/logger.h" +#include "mynteye/api/api.h" #include "util/cv_painter.h" @@ -53,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 _(depth_mtx); diff --git a/samples/tutorials/data/get_img_params.cc b/samples/tutorials/data/get_img_params.cc index 5636120..6fa9b8f 100644 --- a/samples/tutorials/data/get_img_params.cc +++ b/samples/tutorials/data/get_img_params.cc @@ -11,9 +11,8 @@ // 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. -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_imu.cc b/samples/tutorials/data/get_imu.cc index 6ed0552..a449f6e 100644 --- a/samples/tutorials/data/get_imu.cc +++ b/samples/tutorials/data/get_imu.cc @@ -13,9 +13,8 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" #include "util/cv_painter.h" diff --git a/samples/tutorials/data/get_imu_params.cc b/samples/tutorials/data/get_imu_params.cc index ddcfd49..7757611 100644 --- a/samples/tutorials/data/get_imu_params.cc +++ b/samples/tutorials/data/get_imu_params.cc @@ -11,9 +11,8 @@ // 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. -#include - -#include "mynteye/api.h" +#include "mynteye/logger.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_points.cc b/samples/tutorials/data/get_points.cc index 828418d..28294f5 100644 --- a/samples/tutorials/data/get_points.cc +++ b/samples/tutorials/data/get_points.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" #include "util/pc_viewer.h" diff --git a/samples/tutorials/data/get_stereo.cc b/samples/tutorials/data/get_stereo.cc index a82a9e9..391c53e 100644 --- a/samples/tutorials/data/get_stereo.cc +++ b/samples/tutorials/data/get_stereo.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_stereo_rectified.cc b/samples/tutorials/data/get_stereo_rectified.cc index 04c4eae..10c0bf5 100644 --- a/samples/tutorials/data/get_stereo_rectified.cc +++ b/samples/tutorials/data/get_stereo_rectified.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/data/get_with_plugin.cc b/samples/tutorials/data/get_with_plugin.cc index a2201ba..e8a0e05 100644 --- a/samples/tutorials/data/get_with_plugin.cc +++ b/samples/tutorials/data/get_with_plugin.cc @@ -13,9 +13,7 @@ // limitations under the License. #include -#include - -#include "mynteye/api.h" +#include "mynteye/api/api.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/intermediate/get_all_device_info.cc b/samples/tutorials/intermediate/get_all_device_info.cc index b113c27..1c335f7 100644 --- a/samples/tutorials/intermediate/get_all_device_info.cc +++ b/samples/tutorials/intermediate/get_all_device_info.cc @@ -11,9 +11,9 @@ // 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. -#include "mynteye/context.h" -#include "mynteye/device.h" -#include "mynteye/glog_init.h" +#include "mynteye/logger.h" +#include "mynteye/device/context.h" +#include "mynteye/device/device.h" MYNTEYE_USE_NAMESPACE diff --git a/samples/tutorials/intermediate/get_depth_and_points.cc b/samples/tutorials/intermediate/get_depth_and_points.cc index c137954..5761c62 100644 --- a/samples/tutorials/intermediate/get_depth_and_points.cc +++ b/samples/tutorials/intermediate/get_depth_and_points.cc @@ -14,9 +14,8 @@ #include #include -#include - -#include "mynteye/api.h" +// #include "mynteye/logger.h" +#include "mynteye/api/api.h" #include "util/cv_painter.h" #include "util/pc_viewer.h" @@ -34,7 +33,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; } @@ -166,7 +165,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"; @@ -188,6 +187,8 @@ int main(int argc, char *argv[]) { painter.DrawImgData(img, *left_data.img); cv::imshow("frame", img); + // LOG(INFO) << "left id: " << left_data.frame_id + // << ", right id: " << right_data.frame_id; auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED); auto &&depth_data = api->GetStreamData(Stream::DEPTH); @@ -195,7 +196,7 @@ int main(int argc, char *argv[]) { // Show disparity instead of depth, but show depth values in region. auto &&depth_frame = disp_data.frame; -#ifdef USE_OPENCV3 +#ifdef WITH_OPENCV3 // ColormapTypes // http://docs.opencv.org/master/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65 cv::applyColorMap(depth_frame, depth_frame, cv::COLORMAP_JET); @@ -206,6 +207,7 @@ int main(int argc, char *argv[]) { depth_region.DrawRect(depth_frame); cv::imshow("depth", depth_frame); + // LOG(INFO) << "depth id: " << disp_data.frame_id; depth_region.ShowElems( depth_data.frame, @@ -225,6 +227,7 @@ int main(int argc, char *argv[]) { auto &&points_data = api->GetStreamData(Stream::POINTS); if (!points_data.frame.empty()) { pcviewer.Update(points_data.frame); + // LOG(INFO) << "points id: " << points_data.frame_id; } char key = static_cast(cv::waitKey(1)); diff --git a/samples/tutorials/util/cv_painter.cc b/samples/tutorials/util/cv_painter.cc index c0c6f6a..d5344b5 100644 --- a/samples/tutorials/util/cv_painter.cc +++ b/samples/tutorials/util/cv_painter.cc @@ -13,16 +13,15 @@ // limitations under the License. #include "util/cv_painter.h" -#include - -#include - #include #include #include #include -#include "mynteye/utils.h" +#include + +#include "mynteye/logger.h" +#include "mynteye/device/utils.h" #define FONT_FACE cv::FONT_HERSHEY_PLAIN #define FONT_SCALE 1 @@ -179,7 +178,7 @@ cv::Rect CVPainter::DrawText( y += offset_y; cv::Point org(x, y); -#ifdef USE_OPENCV2 +#ifdef WITH_OPENCV2 cv::putText( const_cast(img), text, org, FONT_FACE, FONT_SCALE, FONT_COLOR, THICKNESS); diff --git a/samples/tutorials/util/cv_painter.h b/samples/tutorials/util/cv_painter.h index bd606a7..decde17 100644 --- a/samples/tutorials/util/cv_painter.h +++ b/samples/tutorials/util/cv_painter.h @@ -15,10 +15,10 @@ #define MYNTEYE_TUTORIALS_CV_PAINTER_H_ #pragma once -#include - #include +#include + #include "mynteye/types.h" class CVPainter { diff --git a/samples/tutorials/util/pc_viewer.cc b/samples/tutorials/util/pc_viewer.cc index 13d6c00..1ad50a1 100644 --- a/samples/tutorials/util/pc_viewer.cc +++ b/samples/tutorials/util/pc_viewer.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "util/pc_viewer.h" -#include - // #include #include +#include "mynteye/logger.h" + std::shared_ptr CustomColorVis( pcl::PointCloud::ConstPtr pc) { // -------------------------------------------- diff --git a/samples/tutorials/util/pc_viewer.h b/samples/tutorials/util/pc_viewer.h index 4092265..1cf781b 100644 --- a/samples/tutorials/util/pc_viewer.h +++ b/samples/tutorials/util/pc_viewer.h @@ -15,12 +15,12 @@ #define MYNTEYE_TUTORIALS_PC_VIEWER_H_ #pragma once +#include + #include #include -#include - class PCViewer { public: PCViewer(); diff --git a/samples/uvc/camera.cc b/samples/uvc/camera.cc index ac20e03..2a92930 100644 --- a/samples/uvc/camera.cc +++ b/samples/uvc/camera.cc @@ -11,19 +11,19 @@ // 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. -#include -#include - #include #include #include #include #include -#include "mynteye/glog_init.h" +#include +#include + +#include "mynteye/logger.h" #include "mynteye/mynteye.h" #include "mynteye/types.h" -#include "uvc/uvc.h" +#include "mynteye/uvc/uvc.h" struct frame { const void *data = nullptr; @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) { t = static_cast(cv::getTickCount() - t); fps = cv::getTickFrequency() / t; } - UNUSED(fps) + MYNTEYE_UNUSED(fps) uvc::stop_streaming(*device); // cv::destroyAllWindows(); diff --git a/scripts/common/echo.sh b/scripts/common/echo.sh index 4d9369f..abb90b2 100644 --- a/scripts/common/echo.sh +++ b/scripts/common/echo.sh @@ -27,11 +27,13 @@ ECHO="echo -e" # task colors COLOR_STRONG="1;35" # Magenta COLOR_INFO="1;34" # Blue +COLOR_WARN="1;33" # Yellow COLOR_DONE="1;32" # Green COLOR_ERROR="1;31" # Red # action colors COLOR_STRONG_NORMAL="35" COLOR_INFO_NORMAL="34" +COLOR_WARN_NORMAL="33" COLOR_DONE_NORMAL="32" COLOR_ERROR_NORMAL="31" @@ -59,6 +61,10 @@ _echo_i() { _echo_ "$1" "$COLOR_INFO" } +_echo_w() { + _echo_ "$1" "$COLOR_WARN" +} + _echo_d() { _echo_ "$1" "$COLOR_DONE" } @@ -75,6 +81,10 @@ _echo_in() { _echo_ "$1" "$COLOR_INFO_NORMAL" } +_echo_wn() { + _echo_ "$1" "$COLOR_WARN_NORMAL" +} + _echo_dn() { _echo_ "$1" "$COLOR_DONE_NORMAL" } diff --git a/scripts/init.sh b/scripts/init.sh index c034f3e..c75a70f 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -14,181 +14,30 @@ # limitations under the License. # _VERBOSE_=1 +# _INIT_LINTER_=1 # _FORCE_INSRALL_=1 +_INSTALL_OPTIONS_=$@ BASE_DIR=$(cd "$(dirname "$0")" && pwd) -source "$BASE_DIR/common/echo.sh" -source "$BASE_DIR/common/detect.sh" -source "$BASE_DIR/common/host.sh" - -PYTHON="python" -if [ "$HOST_OS" = "Win" ]; then - if ! _detect_cmd $PYTHON; then - PYTHON="python2" # try python2 on MSYS - fi -fi - -_detect $PYTHON 1 - -PYTHON_FOUND="${PYTHON}_FOUND" -if [ -z "${!PYTHON_FOUND}" ]; then - _echo_en "$PYTHON not found" -fi - -if [ "$HOST_OS" = "Linux" ]; then - _detect_install() { - _detect_cmd "$1" || [ $(dpkg-query -W -f='${Status}' "$1" 2> /dev/null \ - | grep -c "ok installed") -gt 0 ] - } -elif [ "$HOST_OS" = "Mac" ]; then - _detect_install() { - _detect_cmd "$1" || brew ls --versions "$1" > /dev/null - } -else - _detect_install() { - _detect_cmd "$1" - } -fi - -_install_deps() { - _cmd="$1"; shift; _deps_all=($@) - _echo "Install cmd: $_cmd" - _echo "Install deps: ${_deps_all[*]}" - if [ -n "${_FORCE_INSRALL_}" ]; then - _echo_d "$_cmd ${_deps_all[*]}" - $_cmd ${_deps_all[@]} - return - fi - _deps=() - for _dep in "${_deps_all[@]}"; do - _detect_install $_dep || _deps+=($_dep) - done - if [ ${#_deps[@]} -eq 0 ]; then - _echo_i "All deps already exist" - else - _echo_d "$_cmd ${_deps[*]} (not exists)" - $_cmd ${_deps[@]} - fi -} +source "$BASE_DIR/init_tools.sh" ## deps _echo_s "Init deps" if [ "$HOST_OS" = "Linux" ]; then - # detect apt-get - _detect apt-get - # apt-get install - _install_deps "sudo apt-get install" build-essential curl cmake git clang-format - _install_deps "sudo apt-get install" libv4l-dev - if ! _detect_cmd clang-format; then - # on Ubuntu 14.04, apt-cache search clang-format - _install_deps "sudo apt-get install" clang-format-3.9 - sudo ln -sf clang-format-3.9 /usr/bin/clang-format - sudo ln -sf clang-format-diff-3.9 /usr/bin/clang-format-diff - fi - # sudo - SUDO="sudo" + _install_deps "$SUDO apt-get install" libv4l-dev elif [ "$HOST_OS" = "Mac" ]; then - # detect brew - if ! _detect_cmd brew; then - _echo_sn "Install brew" - _detect curl - _detect ruby - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - fi - # brew install - _install_deps "brew install" curl cmake git clang-format - # link clang-format-diff (if not compatible with Python 3, fix it by yourself) - [ -f "/usr/local/bin/clang-format-diff" ] || \ - ln -s /usr/local/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff _install_deps "brew install" libuvc elif [ "$HOST_OS" = "Win" ]; then - # detect pacman on MSYS - _detect pacman - # pacman install (common) - _install_deps "pacman -S" curl git clang-format - if [ "$HOST_NAME" = "MINGW" ]; then - # pacman install (MINGW) - _deps=() - if [ "$HOST_ARCH" = "x64" ]; then - _deps+=(mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake) - elif [ "$HOST_ARCH" = "x86" ]; then - _deps+=(mingw-w64-i686-toolchain mingw-w64-i686-cmake) - else - _echo_e "Unknown host arch :(" - exit 1 - fi - if ! [ ${#_deps[@]} -eq 0 ]; then - _echo_d "pacman -S ${_deps[*]}" - pacman -S ${_deps[@]} - fi - else - # detect cmake on MSYS - _detect cmake - fi - # update - # pacman -Syu - # search - # pacman -Ss make - # autoremove - # pacman -Qtdq | pacman -Rs - + # _install_deps "pacman -S" ? + _echo else # unexpected _echo_e "Unknown host os :(" exit 1 fi -## pip - -# detect pip -if ! _detect_cmd pip; then - if [ -n "${!PYTHON_FOUND}" ]; then - _echo_sn "Install pip" - [ -f "get-pip.py" ] || curl -O https://bootstrap.pypa.io/get-pip.py - $SUDO $PYTHON get-pip.py - else - _echo_en "Skipped install pip, as $PYTHON not found" - fi -fi -# pip install -if _detect_cmd pip; then - _echo_d "pip install --upgrade autopep8 cpplint pylint requests" - $SUDO pip install --upgrade autopep8 cpplint pylint requests -else - _echo_en "Skipped pip install packages, as pip not found" -fi - -## realpath - -# detect realpath -if ! _detect_cmd realpath; then - _echo_sn "Install realpath" - if [ "$HOST_OS" = "Linux" ]; then - # How to install realpath on Ubuntu 14.04 - # https://www.howtoinstall.co/en/ubuntu/trusty/realpath - sudo apt-get install coreutils realpath - elif [ "$HOST_OS" = "Mac" ]; then - brew install coreutils - elif [ "$HOST_OS" = "Win" ]; then - pacman -S coreutils - else # unexpected - _echo_e "Unknown host os :(" - exit 1 - fi -fi - -ROOT_DIR=$(realpath "$BASE_DIR/..") - -## init - -if [ -n "${!PYTHON_FOUND}" ]; then - _echo_s "Init git hooks" - $PYTHON "$ROOT_DIR/tools/linter/init-git-hooks.py" -else - _echo_en "Skipped init git hooks, as $PYTHON not found" -fi - ## cmake version _echo_s "Expect cmake version >= 3.0" diff --git a/scripts/init_tools.sh b/scripts/init_tools.sh new file mode 100644 index 0000000..0078271 --- /dev/null +++ b/scripts/init_tools.sh @@ -0,0 +1,219 @@ +#!/usr/bin/env bash +# Copyright 2018 Slightech Inc. 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. + +_INIT_BUILD_=1 +# _INIT_LINTER_=1 +# _FORCE_INSRALL_=1 +# _INSTALL_OPTIONS_=-y + +BASE_DIR=$(cd "$(dirname "$0")" && pwd) + +source "$BASE_DIR/common/echo.sh" +source "$BASE_DIR/common/detect.sh" +source "$BASE_DIR/common/host.sh" + +## functions + +if [ "$HOST_OS" = "Linux" ]; then + _detect_install() { + _detect_cmd "$1" || [ $(dpkg-query -W -f='${Status}' "$1" 2> /dev/null \ + | grep -c "ok installed") -gt 0 ] + } +elif [ "$HOST_OS" = "Mac" ]; then + _detect_install() { + _detect_cmd "$1" || brew ls --versions "$1" > /dev/null + } +else + _detect_install() { + _detect_cmd "$1" + } +fi + +_install_deps() { + _cmd="$1"; shift; _deps_all=($@) + if [ -n "${_INSTALL_OPTIONS_}" ]; then + _cmd="$_cmd $_INSTALL_OPTIONS_" + fi + _echo "Install cmd: $_cmd" + _echo "Install deps: ${_deps_all[*]}" + if [ -n "${_FORCE_INSRALL_}" ]; then + _echo_d "$_cmd ${_deps_all[*]}" + $_cmd ${_deps_all[@]} + return + fi + _deps=() + for _dep in "${_deps_all[@]}"; do + _detect_install $_dep || _deps+=($_dep) + done + if [ ${#_deps[@]} -eq 0 ]; then + _echo_i "All deps already exist" + else + _echo_d "$_cmd ${_deps[*]} (not exists)" + $_cmd ${_deps[@]} + fi +} + +## init tools + +_echo_s "Init tools" + +if [ "$HOST_OS" = "Linux" ]; then + # sudo + SUDO="sudo" + _detect_cmd $SUDO || SUDO= + # detect apt-get + _detect apt-get + # apt-get install + if [ -n "${_INIT_BUILD_}" ]; then + _install_deps "$SUDO apt-get install" build-essential curl cmake git make + fi + if [ -n "${_INIT_LINTER_}" ]; then + _install_deps "$SUDO apt-get install" clang-format + if ! _detect_cmd clang-format; then + # on Ubuntu 14.04, apt-cache search clang-format + _install_deps "$SUDO apt-get install" clang-format-3.9 + $SUDO ln -sf clang-format-3.9 /usr/bin/clang-format + $SUDO ln -sf clang-format-diff-3.9 /usr/bin/clang-format-diff + fi + fi +elif [ "$HOST_OS" = "Mac" ]; then + # detect brew + if ! _detect_cmd brew; then + _echo_sn "Install brew" + _detect curl + _detect ruby + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + fi + # brew install + if [ -n "${_INIT_BUILD_}" ]; then + _install_deps "brew install" curl cmake git make + fi + if [ -n "${_INIT_LINTER_}" ]; then + _install_deps "brew install" clang-format + # link clang-format-diff (if not compatible with Python 3, fix it by yourself) + [ -f "/usr/local/bin/clang-format-diff" ] || \ + ln -s /usr/local/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff + fi +elif [ "$HOST_OS" = "Win" ]; then + # detect pacman on MSYS + _detect pacman + # pacman install + if [ -n "${_INIT_BUILD_}" ]; then + _install_deps "pacman -S" curl git make + if [ "$HOST_NAME" = "MINGW" ]; then + # MINGW: cmake + _deps=() + if [ "$HOST_ARCH" = "x64" ]; then + _deps+=(mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake) + elif [ "$HOST_ARCH" = "x86" ]; then + _deps+=(mingw-w64-i686-toolchain mingw-w64-i686-cmake) + else + _echo_e "Unknown host arch :(" + exit 1 + fi + if ! [ ${#_deps[@]} -eq 0 ]; then + _install_deps "pacman -S" ${_deps[@]} + fi + else + # Install CMake for Windows + # https://cmake.org/ + _detect cmake + fi + fi + if [ -n "${_INIT_LINTER_}" ]; then + _install_deps "pacman -S" clang-format + fi + # update + # pacman -Syu + # search + # pacman -Ss make + # autoremove + # pacman -Qtdq | pacman -Rs - +else # unexpected + _echo_e "Unknown host os :(" + exit 1 +fi + +## init linter - optional + +if [ -n "${_INIT_LINTER_}" ]; then + +# python + +PYTHON="python" +if [ "$HOST_OS" = "Win" ]; then + if ! _detect_cmd $PYTHON; then + PYTHON="python2" # try python2 on MSYS + fi +fi + +_detect $PYTHON 1 + +PYTHON_FOUND="${PYTHON}_FOUND" +if [ -z "${!PYTHON_FOUND}" ]; then + _echo_en "$PYTHON not found" +fi + +# pip + +# detect pip +if ! _detect_cmd pip; then + if [ -n "${!PYTHON_FOUND}" ]; then + _echo_sn "Install pip" + [ -f "get-pip.py" ] || curl -O https://bootstrap.pypa.io/get-pip.py + $SUDO $PYTHON get-pip.py + else + _echo_en "Skipped install pip, as $PYTHON not found" + fi +fi +# pip install +if _detect_cmd pip; then + _echo_d "pip install --upgrade autopep8 cpplint pylint requests" + $SUDO pip install --upgrade autopep8 cpplint pylint requests +else + _echo_en "Skipped pip install packages, as pip not found" +fi + +# realpath + +# detect realpath +if ! _detect_cmd realpath; then + _echo_sn "Install realpath" + if [ "$HOST_OS" = "Linux" ]; then + # How to install realpath on Ubuntu 14.04 + # https://www.howtoinstall.co/en/ubuntu/trusty/realpath + $SUDO apt-get install coreutils realpath + elif [ "$HOST_OS" = "Mac" ]; then + brew install coreutils + elif [ "$HOST_OS" = "Win" ]; then + pacman -S coreutils + else # unexpected + _echo_e "Unknown host os :(" + exit 1 + fi +fi + +ROOT_DIR=$(realpath "$BASE_DIR/..") + +# init git hooks + +if [ -n "${!PYTHON_FOUND}" ]; then + _echo_s "Init git hooks" + $PYTHON "$ROOT_DIR/tools/linter/init-git-hooks.py" +else + _echo_en "Skipped init git hooks, as $PYTHON not found" +fi + +fi # _INIT_LINTER_ diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..e3903e1 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# 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. + +BASE_DIR=$(cd "$(dirname "$0")" && pwd) +ROOT_DIR=$(dirname "$BASE_DIR") +CONFIG_FILE="$ROOT_DIR/CMakeLists.txt" + +version=$(cat "$CONFIG_FILE" | grep -m1 "mynteye VERSION") +version=$(echo "${version%LANGUAGES*}") +version=$(echo "${version#*VERSION}" | tr -d '[:space:]') + +echo "$version" diff --git a/scripts/win/cmake/mynteye-targets-release.cmake b/scripts/win/cmake/mynteye-targets-release.cmake new file mode 100644 index 0000000..a009b81 --- /dev/null +++ b/scripts/win/cmake/mynteye-targets-release.cmake @@ -0,0 +1,29 @@ +#---------------------------------------------------------------- +# Generated CMake target import file for configuration "Release". +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Import target "mynteye" for configuration "Release" +set_property(TARGET mynteye APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +set_target_properties(mynteye PROPERTIES + IMPORTED_IMPLIB_RELEASE "${MYNTEYES_SDK_ROOT}/lib/mynteye.lib" + IMPORTED_LOCATION_RELEASE "${MYNTEYES_SDK_ROOT}/bin/mynteye.dll" + ) + +# Import target "mynteye" for configuration "Debug" +set_property(TARGET mynteye APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) +set_target_properties(mynteye PROPERTIES + IMPORTED_IMPLIB_DEBUG "${MYNTEYES_SDK_ROOT}/lib/mynteyed.lib" + IMPORTED_LOCATION_DEBUG "${MYNTEYES_SDK_ROOT}/bin/mynteyed.dll" + ) + +list(APPEND _IMPORT_CHECK_TARGETS mynteye ) +list(APPEND _IMPORT_CHECK_FILES_FOR_mynteye + "${MYNTEYES_SDK_ROOT}/lib/mynteye.lib" "${MYNTEYES_SDK_ROOT}/bin/mynteye.dll" + "${MYNTEYES_SDK_ROOT}/lib/mynteyed.lib" "${MYNTEYES_SDK_ROOT}/bin/mynteyed.dll" + ) + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) diff --git a/scripts/win/cmake/mynteye-targets.cmake b/scripts/win/cmake/mynteye-targets.cmake new file mode 100644 index 0000000..dd35c23 --- /dev/null +++ b/scripts/win/cmake/mynteye-targets.cmake @@ -0,0 +1,102 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget mynteye) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +if(NOT MYNTEYES_SDK_ROOT) + if(DEFINED ENV{MYNTEYES_SDK_ROOT}) + set(MYNTEYES_SDK_ROOT $ENV{MYNTEYES_SDK_ROOT}) + else() + get_filename_component(MYNTEYES_SDK_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../.." ABSOLUTE) + endif() +endif() + +# The installation prefix configured by this project. +set(_IMPORT_PREFIX "${MYNTEYES_SDK_ROOT}") + +# Create imported target mynteye +add_library(mynteye SHARED IMPORTED) + +set_target_properties(mynteye PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "GLOG_NO_ABBREVIATED_SEVERITIES" + INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" + INTERFACE_LINK_LIBRARIES "opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_shape;opencv_stitching;opencv_superres;opencv_video;opencv_videoio;opencv_videostab;opencv_world" +) + +if(CMAKE_VERSION VERSION_LESS 2.8.12) + message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") +endif() + +# Load information for each installed configuration. +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +file(GLOB CONFIG_FILES "${_DIR}/mynteye-targets-*.cmake") +foreach(f ${CONFIG_FILES}) + include(${f}) +endforeach() + +# Cleanup temporary variables. +set(_IMPORT_PREFIX) + +# Loop over all imported files and verify that they actually exist +foreach(target ${_IMPORT_CHECK_TARGETS} ) + foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) + if(NOT EXISTS "${file}" ) + message(FATAL_ERROR "The imported target \"${target}\" references the file + \"${file}\" +but this file does not exist. Possible reasons include: +* The file was deleted, renamed, or moved to another location. +* An install or uninstall procedure did not complete successfully. +* The installation package was faulty and contained + \"${CMAKE_CURRENT_LIST_FILE}\" +but not all the files it references. +") + endif() + endforeach() + unset(_IMPORT_CHECK_FILES_FOR_${target}) +endforeach() +unset(_IMPORT_CHECK_TARGETS) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/scripts/win/generate.bat b/scripts/win/generate.bat new file mode 100644 index 0000000..71d5e8d --- /dev/null +++ b/scripts/win/generate.bat @@ -0,0 +1,20 @@ +@echo off +setlocal +set _MY_DIR=%~dp0 + +set _VS_GEN="Visual Studio 15 2017 Win64" +REM set _VS_GEN="Visual Studio 14 2015 Win64" + +cd %_MY_DIR% + +mkdir _build +cd _build/ + +cmake -DCMAKE_BUILD_TYPE=Release ^ +-DCMAKE_PREFIX_PATH="%_MY_DIR%/../lib/cmake" ^ +-DOpenCV_DIR="%_MY_DIR%/../3rdparty/opencv/build" ^ +-G %_VS_GEN% ^ +.. + +cd %_MY_DIR% +pause diff --git a/scripts/win/nsis/Include/EnvVarUpdate.nsh b/scripts/win/nsis/Include/EnvVarUpdate.nsh new file mode 100644 index 0000000..8aeba45 --- /dev/null +++ b/scripts/win/nsis/Include/EnvVarUpdate.nsh @@ -0,0 +1,350 @@ +/** + * EnvVarUpdate.nsh + * : Environmental Variables: append, prepend, and remove entries + * + * WARNING: If you use StrFunc.nsh header then include it before this file + * with all required definitions. This is to avoid conflicts + * + * Usage: + * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" + * + * Credits: + * Version 1.0 + * * Cal Turney (turnec2) + * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this + * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, + * WriteEnvStr, and un.DeleteEnvStr + * * Diego Pedroso (deguix) for StrTok + * * Kevin English (kenglish_hi) for StrContains + * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry + * (dandaman32) for StrReplace + * + * Version 1.1 (compatibility with StrFunc.nsh) + * * techtonik + * + * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries + * + */ + + +!ifndef ENVVARUPDATE_FUNCTION +!define ENVVARUPDATE_FUNCTION +!verbose push +!verbose 3 +!include "LogicLib.nsh" +!include "WinMessages.NSH" +!include "StrFunc.nsh" + +; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- +!macro _IncludeStrFunction StrFuncName + !ifndef ${StrFuncName}_INCLUDED + ${${StrFuncName}} + !endif + !ifndef Un${StrFuncName}_INCLUDED + ${Un${StrFuncName}} + !endif + !define un.${StrFuncName} "${Un${StrFuncName}}" +!macroend + +!insertmacro _IncludeStrFunction StrTok +!insertmacro _IncludeStrFunction StrStr +!insertmacro _IncludeStrFunction StrRep + +; ---------------------------------- Macro Definitions ---------------------------------------- +!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString + Push "${EnvVarName}" + Push "${Action}" + Push "${RegLoc}" + Push "${PathString}" + Call EnvVarUpdate + Pop "${ResultVar}" +!macroend +!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' + +!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString + Push "${EnvVarName}" + Push "${Action}" + Push "${RegLoc}" + Push "${PathString}" + Call un.EnvVarUpdate + Pop "${ResultVar}" +!macroend +!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' +; ---------------------------------- Macro Definitions end------------------------------------- + +;----------------------------------- EnvVarUpdate start---------------------------------------- +!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' +!define hkcu_current_user 'HKCU "Environment"' + +!macro EnvVarUpdate UN + +Function ${UN}EnvVarUpdate + + Push $0 + Exch 4 + Exch $1 + Exch 3 + Exch $2 + Exch 2 + Exch $3 + Exch + Exch $4 + Push $5 + Push $6 + Push $7 + Push $8 + Push $9 + Push $R0 + + /* After this point: + ------------------------- + $0 = ResultVar (returned) + $1 = EnvVarName (input) + $2 = Action (input) + $3 = RegLoc (input) + $4 = PathString (input) + $5 = Orig EnvVar (read from registry) + $6 = Len of $0 (temp) + $7 = tempstr1 (temp) + $8 = Entry counter (temp) + $9 = tempstr2 (temp) + $R0 = tempChar (temp) */ + + ; Step 1: Read contents of EnvVarName from RegLoc + ; + ; Check for empty EnvVarName + ${If} $1 == "" + SetErrors + DetailPrint "ERROR: EnvVarName is blank" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Check for valid Action + ${If} $2 != "A" + ${AndIf} $2 != "P" + ${AndIf} $2 != "R" + SetErrors + DetailPrint "ERROR: Invalid Action - must be A, P, or R" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ${If} $3 == HKLM + ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 + ${ElseIf} $3 == HKCU + ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5 + ${Else} + SetErrors + DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Check for empty PathString + ${If} $4 == "" + SetErrors + DetailPrint "ERROR: PathString is blank" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ;;khc - here check if length is going to be greater then max string length + ;; and abort if so - also abort if original path empty - may mean + ;; it was too long as well- write message to say set it by hand + Push $6 + Push $7 + Push $8 + StrLen $7 $4 + StrLen $6 $5 + IntOp $8 $6 + $7 + ${If} $5 == "" + ${OrIf} $8 >= ${NSIS_MAX_STRLEN} + SetErrors + DetailPrint "Current $1 length ($6) too long to modify in NSIS; set manually if needed" + Pop $8 + Pop $7 + Pop $6 + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + Pop $8 + Pop $7 + Pop $6 + ;;khc + + ; Make sure we've got some work to do + ${If} $5 == "" + ${AndIf} $2 == "R" + SetErrors + DetailPrint "$1 is empty - Nothing to remove" + Goto EnvVarUpdate_Restore_Vars + ${EndIf} + + ; Step 2: Scrub EnvVar + ; + StrCpy $0 $5 ; Copy the contents to $0 + ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or + ; after the last one are not removed here but instead in Step 3) + ${If} $0 != "" ; If EnvVar is not empty ... + ${Do} + ${${UN}StrStr} $7 $0 " ;" + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 " ;" ";" ; Remove ';' + ${Loop} + ${Do} + ${${UN}StrStr} $7 $0 "; " + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';' + ${Loop} + ${Do} + ${${UN}StrStr} $7 $0 ";;" + ${If} $7 == "" + ${ExitDo} + ${EndIf} + ${${UN}StrRep} $0 $0 ";;" ";" + ${Loop} + + ; Remove a leading or trailing semicolon from EnvVar + StrCpy $7 $0 1 0 + ${If} $7 == ";" + StrCpy $0 $0 "" 1 ; Change ';' to '' + ${EndIf} + StrLen $6 $0 + IntOp $6 $6 - 1 + StrCpy $7 $0 1 $6 + ${If} $7 == ";" + StrCpy $0 $0 $6 ; Change ';' to '' + ${EndIf} + ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug + ${EndIf} + + /* Step 3. Remove all instances of the target path/string (even if "A" or "P") + $6 = bool flag (1 = found and removed PathString) + $7 = a string (e.g. path) delimited by semicolon(s) + $8 = entry counter starting at 0 + $9 = copy of $0 + $R0 = tempChar */ + + ${If} $5 != "" ; If EnvVar is not empty ... + StrCpy $9 $0 + StrCpy $0 "" + StrCpy $8 0 + StrCpy $6 0 + + ${Do} + ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter + + ${If} $7 == "" ; If we've run out of entries, + ${ExitDo} ; were done + ${EndIf} ; + + ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) + ${Do} + StrCpy $R0 $7 1 + ${If} $R0 != " " + ${ExitDo} + ${EndIf} + StrCpy $7 $7 "" 1 ; Remove leading space + ${Loop} + ${Do} + StrCpy $R0 $7 1 -1 + ${If} $R0 != " " + ${ExitDo} + ${EndIf} + StrCpy $7 $7 -1 ; Remove trailing space + ${Loop} + ${If} $7 == $4 ; If string matches, remove it by not appending it + StrCpy $6 1 ; Set 'found' flag + ${ElseIf} $7 != $4 ; If string does NOT match + ${AndIf} $0 == "" ; and the 1st string being added to $0, + StrCpy $0 $7 ; copy it to $0 without a prepended semicolon + ${ElseIf} $7 != $4 ; If string does NOT match + ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, + StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon + ${EndIf} ; + + IntOp $8 $8 + 1 ; Bump counter + ${Loop} ; Check for duplicates until we run out of paths + ${EndIf} + + ; Step 4: Perform the requested Action + ; + ${If} $2 != "R" ; If Append or Prepend + ${If} $6 == 1 ; And if we found the target + DetailPrint "Target is already present in $1. It will be removed and" + ${EndIf} + ${If} $0 == "" ; If EnvVar is (now) empty + StrCpy $0 $4 ; just copy PathString to EnvVar + ${If} $6 == 0 ; If found flag is either 0 + ${OrIf} $6 == "" ; or blank (if EnvVarName is empty) + DetailPrint "$1 was empty and has been updated with the target" + ${EndIf} + ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty), + StrCpy $0 $0;$4 ; append PathString + ${If} $6 == 1 + DetailPrint "appended to $1" + ${Else} + DetailPrint "Target was appended to $1" + ${EndIf} + ${Else} ; If Prepend (and EnvVar is not empty), + StrCpy $0 $4;$0 ; prepend PathString + ${If} $6 == 1 + DetailPrint "prepended to $1" + ${Else} + DetailPrint "Target was prepended to $1" + ${EndIf} + ${EndIf} + ${Else} ; If Action = Remove + ${If} $6 == 1 ; and we found the target + DetailPrint "Target was found and removed from $1" + ${Else} + DetailPrint "Target was NOT found in $1 (nothing to remove)" + ${EndIf} + ${If} $0 == "" + DetailPrint "$1 is now empty" + ${EndIf} + ${EndIf} + + ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change + ; + ClearErrors + ${If} $3 == HKLM + WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section + ${ElseIf} $3 == HKCU + WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section + ${EndIf} + + IfErrors 0 +4 + MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" + DetailPrint "Could not write updated $1 to $3" + Goto EnvVarUpdate_Restore_Vars + + ; "Export" our change + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + EnvVarUpdate_Restore_Vars: + ; + ; Restore the user's variables and return ResultVar + Pop $R0 + Pop $9 + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Push $0 ; Push my $0 (ResultVar) + Exch + Pop $0 ; Restore his $0 + +FunctionEnd + +!macroend ; EnvVarUpdate UN +!insertmacro EnvVarUpdate "" +!insertmacro EnvVarUpdate "un." +;----------------------------------- EnvVarUpdate end---------------------------------------- + +!verbose pop +!endif diff --git a/scripts/win/nsis/mynt.ico b/scripts/win/nsis/mynt.ico new file mode 100644 index 0000000..f4d3c39 Binary files /dev/null and b/scripts/win/nsis/mynt.ico differ diff --git a/scripts/win/nsis/winpack.nsi.in b/scripts/win/nsis/winpack.nsi.in new file mode 100644 index 0000000..b70cd3d --- /dev/null +++ b/scripts/win/nsis/winpack.nsi.in @@ -0,0 +1,198 @@ +; winpack.nsi + +!addincludedir scripts\win\nsis\Include +!include EnvVarUpdate.nsh + +!addplugindir scripts\win\nsis\Plugins + +!include WinMessages.nsh + +!define VERSION "@mynteye_VERSION@" +!define OpenCV_VERSION "@OpenCV_VERSION@" + +!define DSETDIR "$APPDATA" +;!define DSETDIR "$PROGRAMFILES64" + +; HKLM (all users) vs HKCU (current user) defines +!define ENV_HKLM 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' +!define ENV_HKCU 'HKCU "Environment"' + +;-------------------------------- + +; The name of the installer +Name "MYNTEYE S SDK ${VERSION}" + +; The icon of the installer +Icon "scripts\win\nsis\mynt.ico" + +; The file to write +OutFile "mynteye-s-${VERSION}-win-x64-opencv-${OpenCV_VERSION}.exe" + +; The default installation directory +InstallDir ${DSETDIR}\Slightech\MYNTEYES\SDK\${VERSION} + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "Software\MYNTEYESSDK" "Install_Dir" + +; Request application privileges for Windows Vista +;RequestExecutionLevel user +RequestExecutionLevel admin + +;-------------------------------- + +; Pages + +Page components +Page directory +Page instfiles + +UninstPage uninstConfirm +UninstPage instfiles + +;-------------------------------- + +; The stuff to install +Section "SDK (required)" + + SectionIn RO + + ; Set output path to the installation directory. + SetOutPath $INSTDIR + + ; Put file there + File /r "mynteye-s-${VERSION}-win-x64-opencv-${OpenCV_VERSION}\*" + + ; Write the installation path into the registry + WriteRegStr HKLM "SOFTWARE\MYNTEYESSDK" "Install_Dir" "$INSTDIR" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "DisplayName" "MYNTEYE S SDK" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" "NoRepair" 1 + WriteUninstaller "uninstall.exe" + + ; Set variables for local machine + WriteRegExpandStr ${ENV_HKLM} MYNTEYES_SDK_ROOT "$INSTDIR" + + ;${EnvVarUpdate} $0 "PATH" "P" "HKLM" "%MYNTEYES_SDK_PATH%" + ${EnvVarUpdate} $0 "PATH" "P" "HKLM" "$INSTDIR\bin;$INSTDIR\3rdparty\opencv\build\x64\vc15\bin" + + ; Push "%MYNTEYES_SDK_PATH%" + ; Call AddToPath + + ; Make sure windows knows about the change + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + +SectionEnd + +; Optional section (can be disabled by the user) +Section "Desktop Shortcuts" + + CreateShortcut "$DESKTOP\MYNTEYE S SDK ${VERSION}.lnk" "$INSTDIR" "" "$INSTDIR" 0 + +SectionEnd + +Function .onInstSuccess + + WriteRegStr "HKLM" "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" \ + "View MYNTEYES README.txt" \ + "cmd.exe /c start /max notepad.exe $INSTDIR\README.txt" + + MessageBox MB_OKCANCEL "Reboot your system now?" /SD IDOK IDCANCEL NoReboot + Reboot + NoReboot: + +FunctionEnd + +Function .onInstFailed + MessageBox MB_OK "Install failed." +FunctionEnd + +;-------------------------------- + +; Uninstaller + +Section "Uninstall" + + ; Remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MYNTEYESSDK" + DeleteRegKey HKLM "SOFTWARE\MYNTEYESSDK" + + ; Remove install stuff + RMDir /r "$INSTDIR" + + ; Remove shortcuts, if any + Delete "$DESKTOP\MYNTEYE S SDK ${VERSION}.lnk" + + ; Remove directories used + StrCpy $0 "${DSETDIR}\Slightech\MYNTEYES" + Call un.DeleteDirIfEmpty + StrCpy $0 "${DSETDIR}\Slightech" + Call un.DeleteDirIfEmpty + + RMDir /r "$APPDATA\Slightech\MYNTEYES" + StrCpy $0 "$APPDATA\Slightech" + Call un.DeleteDirIfEmpty + + ; Delete variables + DeleteRegValue ${ENV_HKLM} MYNTEYES_SDK_ROOT + + ;${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "%MYNTEYES_SDK_PATH%" + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\bin" + ${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\3rdparty\opencv\build\x64\vc15\bin" + + ; Push "%MYNTEYES_SDK_PATH%" + ; Call un.RemoveFromPath + + ; Make sure windows knows about the change + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + +SectionEnd + +Function un.onUninstSuccess + MessageBox MB_OK "Uninstall success." +FunctionEnd + +Function un.onUninstFailed + MessageBox MB_OK "Uninstall failed." +FunctionEnd + +;-------------------------------- + +; DeleteDirIfEmpty - Delete dir only if empty + +Function un.DeleteDirIfEmpty + FindFirst $R0 $R1 "$0\*.*" + strcmp $R1 "." 0 NoDelete + FindNext $R0 $R1 + strcmp $R1 ".." 0 NoDelete + ClearErrors + FindNext $R0 $R1 + IfErrors 0 NoDelete + FindClose $R0 + Sleep 1000 + RMDir "$0" + NoDelete: + FindClose $R0 +FunctionEnd + +;-------------------------------- + +; Path Manipulation +; http://nsis.sourceforge.net/Path_Manipulation +; Environmental Variables: append, prepend, and remove entries +; http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries +; Setting Environment Variables +; http://nsis.sourceforge.net/Setting_Environment_Variables +; Setting Environment Variables to Active Installer Process +; http://nsis.sourceforge.net/Setting_Environment_Variables_to_Active_Installer_Process + +; Delete files and subdirectories +; http://nsis.sourceforge.net/Delete_files_and_subdirectories +; Delete dir only if empty +; http://nsis.sourceforge.net/Delete_dir_only_if_empty + +;https://gist.github.com/azalea/deb3c1ed2a984eadf96be77b81dd49b1 +;!include ProcessEnvPrependPath.nsh diff --git a/scripts/win/winpack.sh b/scripts/win/winpack.sh new file mode 100644 index 0000000..e081ac9 --- /dev/null +++ b/scripts/win/winpack.sh @@ -0,0 +1,179 @@ +#!/usr/bin/env bash +# 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. + +BASE_DIR=$(cd "$(dirname "$0")" && pwd) +ROOT_DIR=$(realpath "$BASE_DIR/../..") +SCRIPTS_DIR=$(realpath "$BASE_DIR/..") + +source "$SCRIPTS_DIR/common/echo.sh" +source "$SCRIPTS_DIR/common/detect.sh" + +if [ ! -d "$ROOT_DIR/3rdparty/opencv" ]; then + _echo_e "3rdparty/opencv not found, please manually download it to here." + _echo_e + _echo_e " OpenCV Win pack 3.4.3: https://opencv.org/releases.html" + exit 1 +fi + +if ! _detect_cmd makensis; then + _echo_e "makensis not found, please manually download and install it." + _echo_e + _echo_e " NSIS: http://nsis.sourceforge.net" + exit 1 +fi + +export OpenCV_DIR="$ROOT_DIR/3rdparty/opencv/build" + +_rm() { + [ -e "$1" ] && (rm -r "$1" && _echo_i "RM: $1") +} + +_md() { + [ ! -d "$1" ] && (mkdir -p "$1" && _echo_i "MD: $1") +} + +# _mv_subs [sub1 sub2 ...] +_mv_subs() { + _src_dir="$1"; shift; _dst_dir="$1"; shift; _subs="$@"; + if [ -z "$_subs" ]; then + _subs=`ls $_src_dir` + fi + for _sub in $_subs; do + _src="$_src_dir/$_sub" + [ ! -e "$_src" ] && (_echo_i "Not exist: $_src") && continue + _dst= + [ -f "$_src" ] && _dst="$_dst_dir" + [ -d "$_src" ] && _dst="$_dst_dir/$_sub" + [ -z "$_dst" ] && continue + # _echo "_src: $_src" + # _echo "_dst: $_dst" + mv "$_src" "$_dst" + done +} + +################################################################################ +# build release + +make samples tools + +################################################################################ +# build debug + +rm -r "$ROOT_DIR/_build" +rm -r "$ROOT_DIR/_output" +make build BUILD_TYPE=Debug + +mv "$ROOT_DIR/_output/bin/mynteyed.dll" "$ROOT_DIR/_install/bin/mynteyed.dll" +mv "$ROOT_DIR/_output/lib/mynteyed.lib" "$ROOT_DIR/_install/lib/mynteyed.lib" + +################################################################################ +# move to _install + +# 3rdparty/opencv +_md "$ROOT_DIR/_install/3rdparty" +mv "$ROOT_DIR/3rdparty/opencv" "$ROOT_DIR/_install/3rdparty/opencv" + +# cmake +mv "$ROOT_DIR/cmake" "$ROOT_DIR/_install/cmake" + +# samples +mv "$ROOT_DIR/samples/_output/bin" "$ROOT_DIR/_install/bin/samples" +mv "$ROOT_DIR/samples/_output/lib" "$ROOT_DIR/_install/lib/samples" +_rm "$ROOT_DIR/samples/_build" +_rm "$ROOT_DIR/samples/_output" +mv "$ROOT_DIR/samples" "$ROOT_DIR/_install/samples" + +# tools +mv "$ROOT_DIR/tools/_output/bin" "$ROOT_DIR/_install/bin/tools" +mv "$ROOT_DIR/tools/_output/lib" "$ROOT_DIR/_install/lib/tools" +_rm "$ROOT_DIR/tools/_build" +_rm "$ROOT_DIR/tools/_output" +mv "$ROOT_DIR/tools/linter" "$ROOT_DIR/3rdparty/linter" +mv "$ROOT_DIR/tools" "$ROOT_DIR/_install/tools" + +# platforms/win +mv "$ROOT_DIR/platforms/win/README.txt" "$ROOT_DIR/_install" + +_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/.vs" +_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/x64" +_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/x64" +_rm "$ROOT_DIR/platforms/projects/vs2017/mynteyes_demo/mynteyes_demo/mynteyes_demo.vcxproj.user" +mv "$ROOT_DIR/platforms/projects" "$ROOT_DIR/_install/projects" + +################################################################################ +# copy to _install + +cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/" +cp -f "$ROOT_DIR/scripts/win/cmake/mynteye-targets-release.cmake" "$ROOT_DIR/_install/lib/cmake/mynteye/" + +cp -f "$ROOT_DIR/scripts/win/generate.bat" "$ROOT_DIR/_install/samples/" +cp -f "$ROOT_DIR/scripts/win/generate.bat" "$ROOT_DIR/_install/tools/" + +################################################################################ +# archive exe + +source "$ROOT_DIR/pkginfo.sh" +_pkgname="$1-opencv-$OpenCV_VERSION" + +_rm "$ROOT_DIR/$_pkgname.exe" +mv "$ROOT_DIR/_install" "$ROOT_DIR/$_pkgname" + +makensis "$ROOT_DIR/winpack.nsi" + +if _detect_cmd git; then + _git_branch=`git symbolic-ref --short -q HEAD` + if [ "$_git_branch" == "develop" ]; then + _git_hash=`git rev-parse --short HEAD` + mv "$ROOT_DIR/$_pkgname.exe" "$ROOT_DIR/$_pkgname-dev-$_git_hash.exe" + fi +fi + +mv "$ROOT_DIR/$_pkgname" "$ROOT_DIR/_install" + +################################################################################ +# remove from _install + +_rm "$ROOT_DIR/_install/samples/generate.bat" +_rm "$ROOT_DIR/_install/tools/generate.bat" + +################################################################################ +# move back from _install + +# 3rdparty/opencv +mv "$ROOT_DIR/_install/3rdparty/opencv" "$ROOT_DIR/3rdparty/opencv" + +# cmake +mv "$ROOT_DIR/_install/cmake" "$ROOT_DIR/cmake" + +# samples +mv "$ROOT_DIR/_install/samples" "$ROOT_DIR/samples" + +# tools +mv "$ROOT_DIR/_install/tools" "$ROOT_DIR/tools" +mv "$ROOT_DIR/3rdparty/linter" "$ROOT_DIR/tools/linter" + +# platforms/win +mv "$ROOT_DIR/_install/README.txt" "$ROOT_DIR/platforms/win" + +mv "$ROOT_DIR/_install/projects" "$ROOT_DIR/platforms/projects" + +################################################################################ +# clean build + +_rm "$ROOT_DIR/_build" +_rm "$ROOT_DIR/_output" + + +_echo_d "Win pack success" diff --git a/src/api/api.cc b/src/mynteye/api/api.cc similarity index 94% rename from src/api/api.cc rename to src/mynteye/api/api.cc index ddf443a..631f014 100644 --- a/src/api/api.cc +++ b/src/mynteye/api/api.cc @@ -11,29 +11,26 @@ // 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. -#include "api/api.h" +#include "mynteye/api/api.h" #ifdef WITH_BOOST_FILESYSTEM #include #include #endif -#include - #include #include -#include "mynteye/glog_init.h" -#include "mynteye/utils.h" - -#include "api/plugin.h" -#include "api/synthetic.h" -#include "device/device.h" -#include "device/device_s.h" -#include "internal/dl.h" +#include "mynteye/logger.h" +#include "mynteye/api/dl.h" +#include "mynteye/api/plugin.h" +#include "mynteye/api/synthetic.h" +#include "mynteye/device/device.h" +#include "mynteye/device/device_s.h" +#include "mynteye/device/utils.h" #if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM) -#if defined(OS_WIN) +#if defined(MYNTEYE_OS_WIN) #include #endif #endif @@ -70,7 +67,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()); @@ -91,8 +88,8 @@ bool dir_exists(const std::string &p) { #endif std::vector get_plugin_paths() { - std::string info_path(MYNTEYE_SDK_INSTALL_DIR); - info_path.append(OS_SEP "share" OS_SEP "mynteye" OS_SEP "build.info"); + std::string info_path = utils::get_sdk_install_dir(); + 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()) { @@ -186,16 +183,17 @@ std::vector get_plugin_paths() { } plats.push_back(host_os + "-" + host_arch); - std::vector dirs{MYNTEYE_SDK_ROOT_DIR, MYNTEYE_SDK_INSTALL_DIR}; + std::vector dirs{ + utils::get_sdk_root_dir(), utils::get_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); @@ -228,7 +226,7 @@ API::API(std::shared_ptr device) : device_(device) { "to write the image params. If you update the SDK from " "1.x, the `SN*.conf` is the file contains them. Besides, " "you could also calibrate them by yourself. Read the guide " - "doc (https://github.com/slightech/MYNT-EYE-SDK-2-Guide) " + "doc (https://github.com/slightech/MYNT-EYE-S-SDK-Guide) " "to learn more."; } } diff --git a/src/internal/dl.cc b/src/mynteye/api/dl.cc similarity index 84% rename from src/internal/dl.cc rename to src/mynteye/api/dl.cc index 8ba22b7..d7559b6 100644 --- a/src/internal/dl.cc +++ b/src/mynteye/api/dl.cc @@ -11,13 +11,14 @@ // 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. -#include "internal/dl.h" +#include "mynteye/api/dl.h" -#include +#include "mynteye/logger.h" 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(); diff --git a/src/internal/dl.h b/src/mynteye/api/dl.h similarity index 83% rename from src/internal/dl.h rename to src/mynteye/api/dl.h index 901608a..be0c05b 100644 --- a/src/internal/dl.h +++ b/src/mynteye/api/dl.h @@ -11,13 +11,14 @@ // 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. -#ifndef MYNTEYE_INTERNAL_DL_H_ // NOLINT -#define MYNTEYE_INTERNAL_DL_H_ +#ifndef MYNTEYE_API_DL_H_ +#define MYNTEYE_API_DL_H_ #pragma once #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 #else #include @@ -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 *; @@ -66,4 +68,4 @@ Func *DL::Sym(const char *symbol) { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_INTERNAL_DL_H_ NOLINT +#endif // MYNTEYE_API_DL_H_ diff --git a/src/api/processor/processor.cc b/src/mynteye/api/processor.cc similarity index 97% rename from src/api/processor/processor.cc rename to src/mynteye/api/processor.cc index 8ba3bca..2583b5a 100644 --- a/src/api/processor/processor.cc +++ b/src/mynteye/api/processor.cc @@ -11,15 +11,14 @@ // 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. -#include "api/processor/processor.h" - -#include +#include "mynteye/api/processor.h" #include #include -#include "internal/strings.h" -#include "internal/times.h" +#include "mynteye/logger.h" +#include "mynteye/util/strings.h" +#include "mynteye/util/times.h" MYNTEYE_BEGIN_NAMESPACE diff --git a/src/api/processor/processor.h b/src/mynteye/api/processor.h similarity index 95% rename from src/api/processor/processor.h rename to src/mynteye/api/processor.h index 82b2681..11fa6f7 100644 --- a/src/api/processor/processor.h +++ b/src/mynteye/api/processor.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_PROCESSOR_H_ // NOLINT -#define MYNTEYE_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_H_ #pragma once #include @@ -25,8 +25,7 @@ #include #include "mynteye/mynteye.h" - -#include "api/processor/object.h" +#include "mynteye/api/object.h" MYNTEYE_BEGIN_NAMESPACE @@ -119,4 +118,4 @@ void iterate_processors( MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_H_ diff --git a/src/api/processor/depth_processor.cc b/src/mynteye/api/processor/depth_processor.cc similarity index 89% rename from src/api/processor/depth_processor.cc rename to src/mynteye/api/processor/depth_processor.cc index 73769de..aaaf610 100644 --- a/src/api/processor/depth_processor.cc +++ b/src/mynteye/api/processor/depth_processor.cc @@ -11,12 +11,12 @@ // 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. -#include "api/processor/depth_processor.h" - -#include +#include "mynteye/api/processor/depth_processor.h" #include +#include "mynteye/logger.h" + MYNTEYE_BEGIN_NAMESPACE const char DepthProcessor::NAME[] = "DepthProcessor"; @@ -40,12 +40,14 @@ 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(in); ObjMat *output = Object::Cast(out); cv::Mat channels[3 /*input->value.channels()*/]; cv::split(input->value, channels); channels[2].convertTo(output->value, CV_16UC1); + output->id = input->id; + output->data = input->data; return true; } diff --git a/src/api/processor/depth_processor.h b/src/mynteye/api/processor/depth_processor.h similarity index 84% rename from src/api/processor/depth_processor.h rename to src/mynteye/api/processor/depth_processor.h index 44fe231..c0e0aba 100644 --- a/src/api/processor/depth_processor.h +++ b/src/mynteye/api/processor/depth_processor.h @@ -11,13 +11,13 @@ // 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. -#ifndef MYNTEYE_DEPTH_PROCESSOR_H_ // NOLINT -#define MYNTEYE_DEPTH_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_H_ #pragma once #include -#include "api/processor/processor.h" +#include "mynteye/api/processor.h" MYNTEYE_BEGIN_NAMESPACE @@ -38,4 +38,4 @@ class DepthProcessor : public Processor { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_DEPTH_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_DEPTH_PROCESSOR_H_ diff --git a/src/api/processor/disparity_normalized_processor.cc b/src/mynteye/api/processor/disparity_normalized_processor.cc similarity index 90% rename from src/api/processor/disparity_normalized_processor.cc rename to src/mynteye/api/processor/disparity_normalized_processor.cc index 0ce2a9a..9a629e8 100644 --- a/src/api/processor/disparity_normalized_processor.cc +++ b/src/mynteye/api/processor/disparity_normalized_processor.cc @@ -11,13 +11,13 @@ // 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. -#include "api/processor/disparity_normalized_processor.h" +#include "mynteye/api/processor/disparity_normalized_processor.h" + +#include #include -#include - -#include +#include "mynteye/logger.h" MYNTEYE_BEGIN_NAMESPACE @@ -44,11 +44,13 @@ 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(in); ObjMat *output = Object::Cast(out); cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1); // cv::normalize maybe return empty == + output->id = input->id; + output->data = input->data; return !output->value.empty(); } diff --git a/src/api/processor/disparity_normalized_processor.h b/src/mynteye/api/processor/disparity_normalized_processor.h similarity index 82% rename from src/api/processor/disparity_normalized_processor.h rename to src/mynteye/api/processor/disparity_normalized_processor.h index 779f1f7..99d395b 100644 --- a/src/api/processor/disparity_normalized_processor.h +++ b/src/mynteye/api/processor/disparity_normalized_processor.h @@ -11,13 +11,13 @@ // 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. -#ifndef MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ // NOLINT -#define MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_DISPARITY_NORMALIZED_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_DISPARITY_NORMALIZED_PROCESSOR_H_ #pragma once #include -#include "api/processor/processor.h" +#include "mynteye/api/processor.h" MYNTEYE_BEGIN_NAMESPACE @@ -38,4 +38,4 @@ class DisparityNormalizedProcessor : public Processor { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_DISPARITY_NORMALIZED_PROCESSOR_H_ diff --git a/src/api/processor/disparity_processor.cc b/src/mynteye/api/processor/disparity_processor.cc similarity index 94% rename from src/api/processor/disparity_processor.cc rename to src/mynteye/api/processor/disparity_processor.cc index cea855a..b662366 100644 --- a/src/api/processor/disparity_processor.cc +++ b/src/mynteye/api/processor/disparity_processor.cc @@ -11,13 +11,13 @@ // 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. -#include "api/processor/disparity_processor.h" +#include "mynteye/api/processor/disparity_processor.h" + +#include #include -#include - -#include +#include "mynteye/logger.h" MYNTEYE_BEGIN_NAMESPACE @@ -30,7 +30,7 @@ DisparityProcessor::DisparityProcessor(std::int32_t proc_period) int blockSize_ = 15; // 15 int numDisparities_ = 64; // 64 -#ifdef USE_OPENCV2 +#ifdef WITH_OPENCV2 bm_ = cv::Ptr( new cv::StereoBM( cv::StereoBM::BASIC_PRESET, @@ -72,12 +72,12 @@ 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(in); ObjMat *output = Object::Cast(out); cv::Mat disparity; -#ifdef USE_OPENCV2 +#ifdef WITH_OPENCV2 (*bm_)(input->first, input->second, disparity); #else bm_->compute(input->first, input->second, disparity); diff --git a/src/api/processor/disparity_processor.h b/src/mynteye/api/processor/disparity_processor.h similarity index 85% rename from src/api/processor/disparity_processor.h rename to src/mynteye/api/processor/disparity_processor.h index 6a92ce6..0ec43b6 100644 --- a/src/api/processor/disparity_processor.h +++ b/src/mynteye/api/processor/disparity_processor.h @@ -11,15 +11,15 @@ // 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. -#ifndef MYNTEYE_DISPARITY_PROCESSOR_H_ // NOLINT -#define MYNTEYE_DISPARITY_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_DISPARITY_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_DISPARITY_PROCESSOR_H_ #pragma once #include #include -#include "api/processor/processor.h" +#include "mynteye/api/processor.h" namespace cv { @@ -49,4 +49,4 @@ class DisparityProcessor : public Processor { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_DISPARITY_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_DISPARITY_PROCESSOR_H_ diff --git a/src/api/processor/points_processor.cc b/src/mynteye/api/processor/points_processor.cc similarity index 95% rename from src/api/processor/points_processor.cc rename to src/mynteye/api/processor/points_processor.cc index 9b2fc76..9b40e85 100644 --- a/src/api/processor/points_processor.cc +++ b/src/mynteye/api/processor/points_processor.cc @@ -11,13 +11,13 @@ // 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. -#include "api/processor/points_processor.h" +#include "mynteye/api/processor/points_processor.h" + +#include #include -#include - -#include +#include "mynteye/logger.h" MYNTEYE_BEGIN_NAMESPACE @@ -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(in); ObjMat *output = Object::Cast(out); diff --git a/src/api/processor/points_processor.h b/src/mynteye/api/processor/points_processor.h similarity index 85% rename from src/api/processor/points_processor.h rename to src/mynteye/api/processor/points_processor.h index 04599da..e571091 100644 --- a/src/api/processor/points_processor.h +++ b/src/mynteye/api/processor/points_processor.h @@ -11,15 +11,15 @@ // 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. -#ifndef MYNTEYE_POINTS_PROCESSOR_H_ // NOLINT -#define MYNTEYE_POINTS_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_H_ #pragma once -#include - #include -#include "api/processor/processor.h" +#include + +#include "mynteye/api/processor.h" MYNTEYE_BEGIN_NAMESPACE @@ -43,4 +43,4 @@ class PointsProcessor : public Processor { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_POINTS_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_POINTS_PROCESSOR_H_ diff --git a/src/api/processor/rectify_processor.cc b/src/mynteye/api/processor/rectify_processor.cc similarity index 91% rename from src/api/processor/rectify_processor.cc rename to src/mynteye/api/processor/rectify_processor.cc index ba5b3b2..ab47402 100644 --- a/src/api/processor/rectify_processor.cc +++ b/src/mynteye/api/processor/rectify_processor.cc @@ -11,16 +11,15 @@ // 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. -#include "api/processor/rectify_processor.h" +#include "mynteye/api/processor/rectify_processor.h" + +#include #include #include -#include - -#include - -#include "device/device.h" +#include "mynteye/logger.h" +#include "mynteye/device/device.h" MYNTEYE_BEGIN_NAMESPACE @@ -49,11 +48,15 @@ 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(in); ObjMat2 *output = Object::Cast(out); cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR); cv::remap(input->second, output->second, map21, map22, cv::INTER_LINEAR); + output->first_id = input->first_id; + output->first_data = input->first_data; + output->second_id = input->second_id; + output->second_data = input->second_data; return true; } diff --git a/src/api/processor/rectify_processor.h b/src/mynteye/api/processor/rectify_processor.h similarity index 87% rename from src/api/processor/rectify_processor.h rename to src/mynteye/api/processor/rectify_processor.h index e3d9c2c..0cb33a0 100644 --- a/src/api/processor/rectify_processor.h +++ b/src/mynteye/api/processor/rectify_processor.h @@ -11,17 +11,17 @@ // 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. -#ifndef MYNTEYE_RECTIFY_PROCESSOR_H_ // NOLINT -#define MYNTEYE_RECTIFY_PROCESSOR_H_ +#ifndef MYNTEYE_API_PROCESSOR_RECTIFY_PROCESSOR_H_ +#define MYNTEYE_API_PROCESSOR_RECTIFY_PROCESSOR_H_ #pragma once -#include - #include #include -#include "api/processor/processor.h" +#include + #include "mynteye/types.h" +#include "mynteye/api/processor.h" MYNTEYE_BEGIN_NAMESPACE @@ -52,4 +52,4 @@ class RectifyProcessor : public Processor { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_RECTIFY_PROCESSOR_H_ NOLINT +#endif // MYNTEYE_API_PROCESSOR_RECTIFY_PROCESSOR_H_ diff --git a/src/api/synthetic.cc b/src/mynteye/api/synthetic.cc similarity index 87% rename from src/api/synthetic.cc rename to src/mynteye/api/synthetic.cc index 3c5a194..3c7e298 100644 --- a/src/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -11,23 +11,22 @@ // 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. -#include "api/synthetic.h" - -#include +#include "mynteye/api/synthetic.h" #include #include #include -#include "api/plugin.h" -#include "api/processor/depth_processor.h" -#include "api/processor/disparity_normalized_processor.h" -#include "api/processor/disparity_processor.h" -#include "api/processor/object.h" -#include "api/processor/points_processor.h" -#include "api/processor/processor.h" -#include "api/processor/rectify_processor.h" -#include "device/device.h" +#include "mynteye/logger.h" +#include "mynteye/api/object.h" +#include "mynteye/api/plugin.h" +#include "mynteye/api/processor.h" +#include "mynteye/api/processor/depth_processor.h" +#include "mynteye/api/processor/disparity_normalized_processor.h" +#include "mynteye/api/processor/disparity_processor.h" +#include "mynteye/api/processor/points_processor.h" +#include "mynteye/api/processor/rectify_processor.h" +#include "mynteye/device/device.h" #define RECTIFY_PROC_PERIOD 0 #define DISPARITY_PROC_PERIOD 0 @@ -46,7 +45,7 @@ cv::Mat frame2mat(const std::shared_ptr &frame) { } api::StreamData data2api(const device::StreamData &data) { - return {data.img, frame2mat(data.frame), data.frame}; + return {data.img, frame2mat(data.frame), data.frame, data.frame_id}; } void process_childs( @@ -165,9 +164,10 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) { } if (output != nullptr) { if (stream == Stream::LEFT_RECTIFIED) { - return {nullptr, output->first, nullptr}; + return {output->first_data, output->first, nullptr, output->first_id}; } else { - return {nullptr, output->second, nullptr}; + return {output->second_data, output->second, nullptr, + output->second_id}; } } VLOG(2) << "Rectify not ready now"; @@ -179,7 +179,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) { auto &&out = processor->GetOutput(); if (out != nullptr) { auto &&output = Object::Cast(out); - return {nullptr, output->value, nullptr}; + return {output->data, output->value, nullptr, output->id}; } VLOG(2) << "Disparity not ready now"; } break; @@ -189,7 +189,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) { auto &&out = processor->GetOutput(); if (out != nullptr) { auto &&output = Object::Cast(out); - return {nullptr, output->value, nullptr}; + return {output->data, output->value, nullptr, output->id}; } VLOG(2) << "Disparity normalized not ready now"; } break; @@ -198,7 +198,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) { auto &&out = processor->GetOutput(); if (out != nullptr) { auto &&output = Object::Cast(out); - return {nullptr, output->value, nullptr}; + return {output->data, output->value, nullptr, output->id}; } VLOG(2) << "Points not ready now"; } break; @@ -207,7 +207,7 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) { auto &&out = processor->GetOutput(); if (out != nullptr) { auto &&output = Object::Cast(out); - return {nullptr, output->value, nullptr}; + return {output->data, output->value, nullptr, output->id}; } VLOG(2) << "Depth not ready now"; } break; @@ -456,7 +456,9 @@ void Synthetic::ProcessNativeStream( if (left_data.img && right_data.img && left_data.img->frame_id == right_data.img->frame_id) { auto &&processor = find_processor(processor_); - processor->Process(ObjMat2{left_data.frame, right_data.frame}); + processor->Process(ObjMat2{ + left_data.frame, left_data.frame_id, left_data.img, + right_data.frame, right_data.frame_id, right_data.img}); } return; } @@ -471,25 +473,30 @@ void Synthetic::ProcessNativeStream( if (left_rect_data.img && right_rect_data.img && left_rect_data.img->frame_id == right_rect_data.img->frame_id) { process_childs( - processor_, RectifyProcessor::NAME, - ObjMat2{left_rect_data.frame, right_rect_data.frame}); + processor_, RectifyProcessor::NAME, ObjMat2{ + left_rect_data.frame, left_rect_data.frame_id, left_rect_data.img, + right_rect_data.frame, right_rect_data.frame_id, + right_rect_data.img}); } return; } switch (stream) { case Stream::DISPARITY: { - process_childs(processor_, DisparityProcessor::NAME, ObjMat{data.frame}); + process_childs(processor_, DisparityProcessor::NAME, + ObjMat{data.frame, data.frame_id, data.img}); } break; case Stream::DISPARITY_NORMALIZED: { - process_childs( - processor_, DisparityNormalizedProcessor::NAME, ObjMat{data.frame}); + process_childs(processor_, DisparityNormalizedProcessor::NAME, + ObjMat{data.frame, data.frame_id, data.img}); } break; case Stream::POINTS: { - process_childs(processor_, PointsProcessor::NAME, ObjMat{data.frame}); + process_childs(processor_, PointsProcessor::NAME, + ObjMat{data.frame, data.frame_id, data.img}); } break; case Stream::DEPTH: { - process_childs(processor_, DepthProcessor::NAME, ObjMat{data.frame}); + process_childs(processor_, DepthProcessor::NAME, + ObjMat{data.frame, data.frame_id, data.img}); } break; default: break; @@ -498,7 +505,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 +515,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 +524,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 +533,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 +542,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; } @@ -546,18 +553,19 @@ void Synthetic::OnRectifyPostProcess(Object *const out) { const ObjMat2 *output = Object::Cast(out); if (HasStreamCallback(Stream::LEFT_RECTIFIED)) { stream_callbacks_.at(Stream::LEFT_RECTIFIED)( - {nullptr, output->first, nullptr}); + {output->first_data, output->first, nullptr, output->first_id}); } if (HasStreamCallback(Stream::RIGHT_RECTIFIED)) { stream_callbacks_.at(Stream::RIGHT_RECTIFIED)( - {nullptr, output->second, nullptr}); + {output->second_data, output->second, nullptr, output->second_id}); } } void Synthetic::OnDisparityPostProcess(Object *const out) { const ObjMat *output = Object::Cast(out); if (HasStreamCallback(Stream::DISPARITY)) { - stream_callbacks_.at(Stream::DISPARITY)({nullptr, output->value, nullptr}); + stream_callbacks_.at(Stream::DISPARITY)( + {output->data, output->value, nullptr, output->id}); } } @@ -565,21 +573,23 @@ void Synthetic::OnDisparityNormalizedPostProcess(Object *const out) { const ObjMat *output = Object::Cast(out); if (HasStreamCallback(Stream::DISPARITY_NORMALIZED)) { stream_callbacks_.at(Stream::DISPARITY_NORMALIZED)( - {nullptr, output->value, nullptr}); + {output->data, output->value, nullptr, output->id}); } } void Synthetic::OnPointsPostProcess(Object *const out) { const ObjMat *output = Object::Cast(out); if (HasStreamCallback(Stream::POINTS)) { - stream_callbacks_.at(Stream::POINTS)({nullptr, output->value, nullptr}); + stream_callbacks_.at(Stream::POINTS)( + {output->data, output->value, nullptr, output->id}); } } void Synthetic::OnDepthPostProcess(Object *const out) { const ObjMat *output = Object::Cast(out); if (HasStreamCallback(Stream::DEPTH)) { - stream_callbacks_.at(Stream::DEPTH)({nullptr, output->value, nullptr}); + stream_callbacks_.at(Stream::DEPTH)( + {output->data, output->value, nullptr, output->id}); } } diff --git a/src/api/synthetic.h b/src/mynteye/api/synthetic.h similarity index 97% rename from src/api/synthetic.h rename to src/mynteye/api/synthetic.h index 2153ed9..441ddfb 100644 --- a/src/api/synthetic.h +++ b/src/mynteye/api/synthetic.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_SYNTHETIC_H_ // NOLINT -#define MYNTEYE_SYNTHETIC_H_ +#ifndef MYNTEYE_API_SYNTHETIC_H_ +#define MYNTEYE_API_SYNTHETIC_H_ #pragma once #include @@ -20,7 +20,7 @@ #include #include -#include "api/api.h" +#include "mynteye/api/api.h" MYNTEYE_BEGIN_NAMESPACE @@ -169,4 +169,4 @@ bool Synthetic::DeactivateProcessor(bool childs) { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_SYNTHETIC_H_ NOLINT +#endif // MYNTEYE_API_SYNTHETIC_H_ diff --git a/src/internal/async_callback.h b/src/mynteye/device/async_callback.h similarity index 87% rename from src/internal/async_callback.h rename to src/mynteye/device/async_callback.h index c00f4b4..d416fb1 100644 --- a/src/internal/async_callback.h +++ b/src/mynteye/device/async_callback.h @@ -11,8 +11,8 @@ // 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. -#ifndef MYNTEYE_INTERNAL_ASYNC_CALLBACK_H_ // NOLINT -#define MYNTEYE_INTERNAL_ASYNC_CALLBACK_H_ +#ifndef MYNTEYE_DEVICE_ASYNC_CALLBACK_H_ +#define MYNTEYE_DEVICE_ASYNC_CALLBACK_H_ #pragma once #include @@ -57,6 +57,6 @@ class AsyncCallback { MYNTEYE_END_NAMESPACE -#include "internal/async_callback_impl.h" +#include "mynteye/device/async_callback_impl.h" -#endif // MYNTEYE_INTERNAL_ASYNC_CALLBACK_H_ NOLINT +#endif // MYNTEYE_DEVICE_ASYNC_CALLBACK_H_ diff --git a/src/internal/async_callback_impl.h b/src/mynteye/device/async_callback_impl.h similarity index 92% rename from src/internal/async_callback_impl.h rename to src/mynteye/device/async_callback_impl.h index 3c502b3..9e79f26 100644 --- a/src/internal/async_callback_impl.h +++ b/src/mynteye/device/async_callback_impl.h @@ -11,15 +11,15 @@ // 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. -#ifndef MYNTEYE_INTERNAL_ASYNC_CALLBACK_IMPL_H_ // NOLINT -#define MYNTEYE_INTERNAL_ASYNC_CALLBACK_IMPL_H_ +#ifndef MYNTEYE_DEVICE_ASYNC_CALLBACK_IMPL_H_ +#define MYNTEYE_DEVICE_ASYNC_CALLBACK_IMPL_H_ #pragma once -#include - #include #include +#include "mynteye/logger.h" + MYNTEYE_BEGIN_NAMESPACE template @@ -89,4 +89,4 @@ void AsyncCallback::Run() { MYNTEYE_END_NAMESPACE -#endif // MYNTEYE_INTERNAL_ASYNC_CALLBACK_IMPL_H_ NOLINT +#endif // MYNTEYE_DEVICE_ASYNC_CALLBACK_IMPL_H_ diff --git a/src/internal/channels.cc b/src/mynteye/device/channels.cc similarity index 96% rename from src/internal/channels.cc rename to src/mynteye/device/channels.cc index e8eb253..5864402 100644 --- a/src/internal/channels.cc +++ b/src/mynteye/device/channels.cc @@ -11,9 +11,7 @@ // 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. -#include "internal/channels.h" - -#include +#include "mynteye/device/channels.h" #include #include @@ -22,8 +20,9 @@ #include #include -#include "internal/strings.h" -#include "internal/times.h" +#include "mynteye/logger.h" +#include "mynteye/util/strings.h" +#include "mynteye/util/times.h" #define IMU_TRACK_PERIOD 25 // ms @@ -64,6 +63,12 @@ int XuCamCtrlId(Option option) { case Option::FRAME_RATE: return 7; break; + case Option::ACCELEROMETER_RANGE: + return 9; + break; + case Option::GYROSCOPE_RANGE: + return 10; + break; default: LOG(FATAL) << "No cam ctrl id for " << option; } @@ -136,7 +141,8 @@ void Channels::UpdateControlInfos() { for (auto &&option : std::vector