78 Commits

Author SHA1 Message Date
John Zhao
721ad22b0a Update version 2018-10-22 22:18:22 +08:00
kalman
4d644a1d71 Update img.params 2018-10-18 15:11:21 +08:00
kalman
1f96a6ee29 Add frame rate 60 2018-10-17 11:12:40 +08:00
kalman
204fff2175 Update device.info,img.params and imu params 2018-10-17 10:59:50 +08:00
John Zhao
12f5a8f3cc Update README.md 2018-09-27 09:56:17 +08:00
John Zhao
6435bf04a2 Fix generate apidoc 2018-09-27 09:31:42 +08:00
John Zhao
2ae3116f0d Update doc version 2018-09-26 16:01:47 +08:00
John Zhao
a26dbec7b1 Fix log level & strip basename 2018-09-11 14:12:45 +08:00
John Zhao
0bcd3c02b9 Fix miniglog on win 2018-09-11 13:24:07 +08:00
John Zhao
c6f195360f Change make install 2018-09-11 10:58:42 +08:00
John Zhao
1b95e376a5 Update macros 2018-09-11 10:50:44 +08:00
John Zhao
cf9e714626 Fix flags on win 2018-09-11 10:10:14 +08:00
Osenberg-Y
5f233a35c0 Merge branch develop 2018-09-11 10:05:57 +08:00
Osenberg-Y
36e90e3793 Fix bug in repeatedly publishing camera infomation. 2018-09-06 19:45:51 +08:00
John Zhao
ca605d6114 Set max log level to info for miniglog 2018-09-04 17:31:21 +08:00
John Zhao
89c798daa8 Change max log size 2018-09-04 17:18:35 +08:00
John Zhao
2784937ad1 Remove submodule glog 2018-09-04 17:11:39 +08:00
John Zhao
d96797c835 Add miniglog 2018-09-04 17:00:18 +08:00
John Zhao
94ecacef6c Build pass without glog 2018-09-04 16:07:36 +08:00
John Zhao
02856194a0 Update find mynteye in cmakelists of wrappers 2018-09-04 15:59:38 +08:00
John Zhao
4d5ff16f82 Change log header 2018-09-04 15:49:11 +08:00
John Zhao
30a9397602 Add glog option 2018-09-04 15:07:26 +08:00
John Zhao
55165b8878 Update init script, make linter optional 2018-09-04 10:47:54 +08:00
Osenberg-Y
12adc79096 Merge branch into develop 2018-09-03 14:42:25 +08:00
Osenberg-Y
4addab5cc0 Merge branch 'develop' of https://code.slightech.com:666/mynteye/mynt-eye-sdk-2 into develop 2018-09-02 14:50:49 +08:00
kalman
92585a3b8d Replace LOG(WARNING) with VLOG(2) When get imu params failed or image packet is unaccepted 2018-09-01 21:03:28 +08:00
kalman
54f01eec1a Miss blank line 2018-09-01 20:51:14 +08:00
kalman
d80d506360 Throw error in v4l2 when time out 2018-09-01 20:47:35 +08:00
Osenberg-Y
692cbac8d8 Temporary version 2018-08-28 16:46:51 +08:00
Osenberg-Y
d4343b574a Optimized the display of raw image and imu rate information 2018-08-17 17:56:41 +08:00
Osenberg-Y
1f003f505b Fixed no pointcloud on ros 2018-08-14 14:16:07 +08:00
John Zhao
a96246cc20 Change install dir on win 2018-08-14 13:46:18 +08:00
John Zhao
5f24d0857e Update README.md 2018-08-14 11:13:21 +08:00
John Zhao
bbf789b174 Update doc version 2018-08-14 11:05:23 +08:00
John Zhao
66c9af58fc Install to default path 2018-08-14 10:45:13 +08:00
John Zhao
375acb534c Update README.md 2018-08-13 09:12:34 +08:00
John Zhao
28204d5c0a Format comments 2018-08-13 09:10:23 +08:00
John Zhao
c9483c2aca Remove frame rate 60 2018-08-12 11:36:04 +08:00
Osenberg-Y
45b4fdeedf Remove frame rate 60 2018-08-07 17:35:42 +08:00
Osenberg-Y
455b5b931e Modification of publishing topic only when that was subscribed. 2018-08-07 11:15:45 +08:00
John Zhao
8ab9b42896 Fix constexpr on VS 2015 2018-08-04 14:05:19 +08:00
Osenberg-Y
3258e969ee Merge branch develop 2018-08-02 17:14:41 +08:00
Osenberg-Y
cc74b2663b Fixed img_params_writer write img.params failure 2018-08-02 16:38:19 +08:00
John Zhao
e270e99340 Update glog flags 2018-08-01 15:11:47 +08:00
Osenberg-Y
0c92f770f2 Fix make tools compile fail when using opencv2.4.x version 2018-07-27 14:50:02 +08:00
Osenberg-Y
5a9fffe3ed Fix compile failure on VS2015. Using const instead of constexpr 2018-07-26 13:15:14 +08:00
John Zhao
384ff028a8 Publish more camera infos 2018-07-22 12:20:27 +08:00
John Zhao
0f9bdd5cf2 Fix ros camera info 2018-07-22 11:37:21 +08:00
John Zhao
54165b1acb Fix t as right to left 2018-07-22 10:42:15 +08:00
John Zhao
087ef28da1 Update ros rviz 2018-07-19 16:55:51 +08:00
John Zhao
b2bd1f389d Update glog & default flags 2018-07-19 15:46:19 +08:00
John Zhao
6a82b06b84 Update README.md 2018-07-18 09:23:51 +08:00
John Zhao
518416ac4d Update version 2018-07-17 21:58:03 +08:00
John Zhao
c53dd50730 Remove flags of opencv windows 2018-07-17 15:12:35 +08:00
John Zhao
4892f52158 Fix win flags with opencv2 2018-07-17 10:13:50 +08:00
John Zhao
3dc21c0378 Limit max data size for async callback 2018-07-11 15:04:14 +08:00
John Zhao
0153261447 Update cmake files 2018-07-11 13:31:48 +08:00
John Zhao
25f72dd74f Add WITH_DEVICE_INFO_REQUIRED option 2018-07-11 12:17:21 +08:00
John Zhao
438ba6481d Optimize cmake options and print summary 2018-07-11 12:00:16 +08:00
John Zhao
922bf624e7 Do small change 2018-07-11 11:58:32 +08:00
junyang
9014f3df57 Point cloud unit conversion in wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc 2018-07-11 02:14:19 +08:00
junyang
c2f04c487e Increase the effectiveness of checking all values. 2018-07-11 02:07:01 +08:00
John Zhao
725a8c2e57 Add api doc of en 2018-07-10 17:24:10 +08:00
John Zhao
d04078068a Update api doc 2018-07-10 17:23:33 +08:00
John Zhao
9567546894 Update api doc 2018-07-08 13:04:41 +08:00
KalmanSLightech
27eb9e6cb2 Change the position of 'hardTimeToSoftTime' 2018-07-03 18:56:16 +08:00
KalmanSLightech
c5b054c864 change function name 2018-07-03 18:06:24 +08:00
nico
becccd9b8f Timestamp synchronization through one association. 2018-07-02 12:20:24 +08:00
John Zhao
1c1503aae2 Add get_all_device_info sample 2018-06-14 09:38:38 +08:00
John Zhao
d3a67b7d29 Change output of processor to smart pointer 2018-06-13 18:00:31 +08:00
John Zhao
a119b36f72 Catch process exception 2018-06-12 23:08:28 +08:00
John Zhao
24ca757c92 Improve process childs 2018-06-12 22:05:47 +08:00
John Zhao
92b38291ee Check image params when use api 2018-06-12 15:58:13 +08:00
John Zhao
377f9b21f1 Check supports stream or not when get its data 2018-06-12 12:31:07 +08:00
John Zhao
591bbdd3e6 Fix doc comments of api 2018-06-12 10:46:39 +08:00
John Zhao
68e413e5e2 Try python2 after detect python 2018-06-12 10:43:09 +08:00
John Zhao
3e42060ff1 Make python optional in init.sh 2018-06-12 10:22:15 +08:00
John Zhao
40b7acd5c3 Update README.md 2018-06-10 22:26:25 +08:00
122 changed files with 4878 additions and 923 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -14,7 +14,7 @@
cmake_minimum_required(VERSION 3.0)
project(mynteye VERSION 2.0.0 LANGUAGES C CXX)
project(mynteye VERSION 2.2.1 LANGUAGES C CXX)
include(cmake/Common.cmake)
@@ -44,26 +44,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)
if(WITH_API)
include(cmake/DetectOpenCV.cmake)
endif()
find_package(Boost COMPONENTS filesystem)
if(Boost_FOUND)
set(WITH_BOOST_FILESYSTEM true)
add_definitions(-DWITH_FILESYSTEM)
add_definitions(-DWITH_BOOST_FILESYSTEM)
message(STATUS "With boost filesystem: ${Boost_VERSION}")
#message(STATUS " Boost_LIBRARIES: ${Boost_LIBRARIES}")
elseif(OS_WIN)
add_definitions(-DWITH_FILESYSTEM)
add_definitions(-DWITH_NATIVE_FILESYSTEM)
message(STATUS "With native filesystem")
endif()
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)
@@ -107,19 +97,28 @@ 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
)
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()
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_SOURCE_DIR}/include/mynteye/logger.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
@@ -136,6 +135,11 @@ if(WITH_API)
${CMAKE_CURRENT_SOURCE_DIR}/src/api/processor/object.h
)
endif()
if(NOT WITH_GLOG)
list(APPEND MYNTEYE_PUBLIC_H
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/miniglog.h
)
endif()
if(OS_WIN)
set(UVC_SRC src/uvc/uvc-wmf.cc)
@@ -180,21 +184,25 @@ if(WITH_API)
src/api/processor/points_processor.cc
)
endif()
if(NOT WITH_GLOG)
list(APPEND MYNTEYE_SRCS src/public/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}
@@ -254,32 +262,7 @@ install(EXPORT ${MYNTEYE_NAME}-targets
## build.info
macro(set_default_value VARIABLE DEFAULT)
if(NOT ${VARIABLE})
set(${VARIABLE} ${DEFAULT})
endif()
endmacro()
macro(set_version_values VARIABLE)
string(REPLACE "." ";" __version_list "${${VARIABLE}}")
list(LENGTH __version_list __len)
if(${__len} GREATER 0)
list(GET __version_list 0 ${VARIABLE}_MAJOR)
endif()
if(${__len} GREATER 1)
list(GET __version_list 1 ${VARIABLE}_MINOR)
endif()
if(${__len} GREATER 2)
list(GET __version_list 2 ${VARIABLE}_PATCH)
endif()
if(${__len} GREATER 3)
list(GET __version_list 3 ${VARIABLE}_TWEAK)
endif()
endmacro()
find_package(CUDA QUIET)
set_version_values(CMAKE_CXX_COMPILER_VERSION)
# set default int values for yaml file (build.info)
set_default_value(CMAKE_CXX_COMPILER_VERSION_MAJOR 0)
set_default_value(CMAKE_CXX_COMPILER_VERSION_MINOR 0)
set_default_value(CMAKE_CXX_COMPILER_VERSION_PATCH 0)

2
CPPLINT.cfg Normal file
View File

@@ -0,0 +1,2 @@
set noparent
filter=-build/c++11

View File

@@ -16,6 +16,12 @@ include CommonDefs.mk
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
# CMAKE_INSTALL_PREFIX:
# https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html
#
# UNIX: /usr/local
# Windows: c:/Program Files/${PROJECT_NAME}
.DEFAULT_GOAL := help
help:
@@ -25,8 +31,8 @@ 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 ros build ros wrapper"
@@ -35,7 +41,7 @@ help:
.PHONY: help
all: test tools samples
all: test samples tools
.PHONY: all
@@ -43,7 +49,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
@@ -54,19 +61,17 @@ opendoc: apidoc
[ -f "$$html" ] && $(SH) ./scripts/open.sh $$html; \
done
.PHONY: apidoc opendoc
cleandoc:
@$(call rm,./doc/_output/)
.PHONY: apidoc opendoc cleandoc
# deps
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
@@ -78,9 +83,13 @@ init: submodules
# build
build: third_party
build: submodules
@$(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
@@ -114,9 +123,13 @@ 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
@@ -225,8 +238,7 @@ cleanlog:
@$(call rm_f,*ERROR*)
@$(call rm_f,*FATAL*)
cleanall: clean
@$(call rm,./doc/_output/)
cleanall: clean cleandoc
@$(call rm,./test/gtest/_build/)
@$(call rm,./third_party/glog/_build/)
@$(FIND) . -type f -name ".DS_Store" -print0 | xargs -0 rm -f

View File

@@ -1,5 +1,7 @@
# MYNT® EYE SDK
[![](https://img.shields.io/badge/MYNT%20EYE%20SDK-2.0.1--rc2-brightgreen.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2)
## Overview
MYNT® EYE SDK 2.0 is a cross-platform library for MYNT® EYE cameras.
@@ -15,16 +17,19 @@ 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/2422149/mynt-eye-sdk-apidoc-2.0.1-rc2-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422151/mynt-eye-sdk-apidoc-2.0.1-rc2-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/2422152/mynt-eye-sdk-apidoc-2.0.1-rc2-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422153/mynt-eye-sdk-apidoc-2.0.1-rc2-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-rc2-html-zh-Hans/mynt-eye-sdk-apidoc-2.0.1-rc2-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/2422160/mynt-eye-sdk-guide-2.0.1-rc2-en.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422161/mynt-eye-sdk-guide-2.0.1-rc2-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/2422162/mynt-eye-sdk-guide-2.0.1-rc2-zh-Hans.pdf) [![](https://img.shields.io/badge/Download-HTML-blue.svg?style=flat)](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422164/mynt-eye-sdk-guide-2.0.1-rc2-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-rc2-html-zh-Hans/mynt-eye-sdk-guide-2.0.1-rc2-html-zh-Hans/index.html)
> Supported languages: `zh-Hans`.
> 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.0-rc`.
Get firmwares from our online disks: [MYNTEYE_BOX][]. The latest version is `2.0.1`.
## Usage

26
cmake/DetectGLog.cmake Normal file
View File

@@ -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)

View File

@@ -12,7 +12,143 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include(${CMAKE_CURRENT_LIST_DIR}/IncludeGuard.cmake)
cmake_include_guard()
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)
# build components
option(WITH_API "Build with API layer, need OpenCV" ON)
message(STATUS "Options:")
message(STATUS " WITH_API: ${WITH_API}")
option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON)
# 3rdparty components
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
if(WITH_API)
include(${CMAKE_CURRENT_LIST_DIR}/DetectOpenCV.cmake)
endif()
if(WITH_DEVICE_INFO_REQUIRED)
add_definitions(-DWITH_DEVICE_INFO_REQUIRED)
endif()
if(WITH_BOOST)
find_package(Boost COMPONENTS filesystem)
if(Boost_FOUND)
set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
set(WITH_FILESYSTEM TRUE)
set(WITH_BOOST_FILESYSTEM TRUE)
add_definitions(-DWITH_FILESYSTEM)
add_definitions(-DWITH_BOOST_FILESYSTEM)
endif()
endif()
if(NOT WITH_FILESYSTEM)
if(MSVC OR MSYS OR MINGW) # win
set(WITH_FILESYSTEM TRUE)
set(WITH_NATIVE_FILESYSTEM TRUE)
add_definitions(-DWITH_FILESYSTEM)
add_definitions(-DWITH_NATIVE_FILESYSTEM)
endif()
endif()
if(WITH_GLOG)
include(${CMAKE_CURRENT_LIST_DIR}/DetectGLog.cmake)
endif()
find_package(CUDA QUIET)
# summary
set_version_values(CMAKE_CXX_COMPILER_VERSION)
status("")
status("Platform:")
status(" HOST_OS: ${HOST_OS}")
status(" HOST_NAME: ${HOST_NAME}")
status(" HOST_ARCH: ${HOST_ARCH}")
status(" HOST_COMPILER: ${CMAKE_CXX_COMPILER_ID}")
status(" COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
status(" COMPILER_VERSION_MAJOR: ${CMAKE_CXX_COMPILER_VERSION_MAJOR}")
status(" COMPILER_VERSION_MINOR: ${CMAKE_CXX_COMPILER_VERSION_MINOR}")
status(" COMPILER_VERSION_PATCH: ${CMAKE_CXX_COMPILER_VERSION_PATCH}")
status(" COMPILER_VERSION_TWEAK: ${CMAKE_CXX_COMPILER_VERSION_TWEAK}")
if(CUDA_FOUND)
status(" CUDA_VERSION: ${CUDA_VERSION}")
status(" CUDA_VERSION_MAJOR: ${CUDA_VERSION_MAJOR}")
status(" CUDA_VERSION_MINOR: ${CUDA_VERSION_MINOR}")
status(" CUDA_VERSION_STRING: ${CUDA_VERSION_STRING}")
endif()
if(OpenCV_FOUND)
status(" OpenCV_VERSION: ${OpenCV_VERSION}")
status(" OpenCV_VERSION_MAJOR: ${OpenCV_VERSION_MAJOR}")
status(" OpenCV_VERSION_MINOR: ${OpenCV_VERSION_MINOR}")
status(" OpenCV_VERSION_PATCH: ${OpenCV_VERSION_PATCH}")
status(" OpenCV_VERSION_TWEAK: ${OpenCV_VERSION_TWEAK}")
status(" OpenCV_VERSION_STATUS: ${OpenCV_VERSION_STATUS}")
status(" OpenCV_WITH_WORLD: ${WITH_OPENCV_WORLD}")
endif()
if(mynteye_VERSION)
status(" MYNTEYE_VERSION: ${mynteye_VERSION}")
status(" MYNTEYE_VERSION_MAJOR: ${mynteye_VERSION_MAJOR}")
status(" MYNTEYE_VERSION_MINOR: ${mynteye_VERSION_MINOR}")
status(" MYNTEYE_VERSION_PATCH: ${mynteye_VERSION_PATCH}")
status(" MYNTEYE_VERSION_TWEAK: ${mynteye_VERSION_TWEAK}")
endif()
status("")
status("Options:")
status(" WITH_API: ${WITH_API}")
if(WITH_API)
if(OpenCV_FOUND)
status(" OpenCV: YES")
status(" OpenCV_VERSION: ${OpenCV_VERSION}")
status(" OpenCV_WORLD: " IF WITH_OPENCV_WORLD "YES" ELSE "NO")
else()
status(" OpenCV: NO")
endif()
endif()
status(" WITH_DEVICE_INFO_REQUIRED: ${WITH_DEVICE_INFO_REQUIRED}")
status(" WITH_BOOST: ${WITH_BOOST}")
if(WITH_BOOST)
if(Boost_FOUND)
status(" Boost: YES")
status(" Boost_VERSION: ${Boost_VERSION_STRING}")
#status(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
else()
status(" Boost: NO")
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: "
IF WITH_BOOST_FILESYSTEM "boost"
ELIF WITH_NATIVE_FILESYSTEM "native"
ELSE "none"
)
status("")

View File

@@ -49,3 +49,88 @@ macro(make_executable NAME)
endif()
endif()
endmacro()
# set_default_value(VARIABLE DEFAULT)
macro(set_default_value VARIABLE DEFAULT)
if(NOT ${VARIABLE})
set(${VARIABLE} ${DEFAULT})
endif()
endmacro()
# set_version_values(VARIABLE)
macro(set_version_values VARIABLE)
string(REPLACE "." ";" __version_list "${${VARIABLE}}")
list(LENGTH __version_list __len)
if(${__len} GREATER 0)
list(GET __version_list 0 ${VARIABLE}_MAJOR)
endif()
if(${__len} GREATER 1)
list(GET __version_list 1 ${VARIABLE}_MINOR)
endif()
if(${__len} GREATER 2)
list(GET __version_list 2 ${VARIABLE}_PATCH)
endif()
if(${__len} GREATER 3)
list(GET __version_list 3 ${VARIABLE}_TWEAK)
endif()
endmacro()
# status(TEXT [IF cond text [ELIF cond text] [ELSE cond text]])
macro(status TEXT)
set(options)
set(oneValueArgs)
set(multiValueArgs IF ELIF ELSE)
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
#message(STATUS "TEXT: ${TEXT}")
#message(STATUS "THIS_IF: ${THIS_IF}")
#message(STATUS "THIS_ELIF: ${THIS_ELIF}")
#message(STATUS "THIS_ELSE: ${THIS_ELSE}")
set(__msg_list "${TEXT}")
set(__continue TRUE)
if(__continue AND DEFINED THIS_IF)
#message(STATUS "-- THIS_IF: ${THIS_IF}")
list(LENGTH THIS_IF __if_len)
if(${__if_len} GREATER 1)
list(GET THIS_IF 0 __if_cond)
if(${__if_cond})
list(REMOVE_AT THIS_IF 0)
list(APPEND __msg_list ${THIS_IF})
set(__continue FALSE)
endif()
else()
message(FATAL_ERROR "status() IF must have cond and text, >= 2 items")
endif()
endif()
if(__continue AND DEFINED THIS_ELIF)
#message(STATUS "-- THIS_ELIF: ${THIS_ELIF}")
list(LENGTH THIS_ELIF __elif_len)
if(${__elif_len} GREATER 1)
list(GET THIS_ELIF 0 __elif_cond)
if(${__elif_cond})
list(REMOVE_AT THIS_ELIF 0)
list(APPEND __msg_list ${THIS_ELIF})
set(__continue FALSE)
endif()
else()
message(FATAL_ERROR "status() ELIF must have cond and text, >= 2 items")
endif()
endif()
if(__continue AND DEFINED THIS_ELSE)
#message(STATUS "-- THIS_ELSE: ${THIS_ELSE}")
list(LENGTH THIS_ELSE __else_len)
if(${__else_len} GREATER 0)
list(APPEND __msg_list ${THIS_ELSE})
else()
message(FATAL_ERROR "status() ELSE must have text, >= 1 items")
endif()
endif()
string(REPLACE ";" "" __msg_list "${__msg_list}")
message(STATUS "${__msg_list}")
endmacro()

View File

@@ -40,8 +40,8 @@ OUTPUT="$BASE_DIR/_output"
_texcjk() {
tex="$1"; shift;
_echo_in "add cjk to $tex"
sed -i "" -e $'s/^\\\\begin{document}$/\\\\usepackage{CJKutf8}\\\n\\\\begin{document}\\\n\\\\begin{CJK}{UTF8}{gbsn}/g' $tex
sed -i "" -e $'s/^\\\\end{document}$/\\\\end{CJK}\\\n\\\\end{document}/g' $tex
sed -i "" -E $'s/^\\\\begin{document}$/\\\\usepackage{CJKutf8}\\\n\\\\begin{document}\\\n\\\\begin{CJK}{UTF8}{gbsn}/g' $tex
sed -i "" -E $'s/^\\\\end{document}$/\\\\end{CJK}\\\n\\\\end{document}/g' $tex
}
for lang in "${LANGS[@]}"; do
@@ -52,11 +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-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"
filename="mynt-eye-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" "../mynteye-apidoc.pdf"
[ -f "refman.pdf" ] && mv "refman.pdf" "../$filename"
fi
_echo_d "doxygen completed"
else
_echo_e "$DOXYFILE not found"

2495
doc/en/api.doxyfile Normal file

File diff suppressed because it is too large Load Diff

11
doc/en/mainpage.md Normal file
View File

@@ -0,0 +1,11 @@
# MYNT EYE SDK {#mainpage}
* <a class="el" href="annotated.html">API Classes</a>
* <a class="el" href="modules.html">API Modules</a>
* \link enumerations Enumerations\endlink
* \link datatypes Datatypes\endlink
* \link utils Utiliities\endlink
* \link calibration Intrinsics & Extrinsics\endlink
* <span style="font-weight:bold">Device Specifications</span>
* @subpage specs_data
* @subpage specs_ctrl

View File

@@ -0,0 +1,26 @@
# Control Protocols {#spec_control_api}
There are two control modes, one is through UVC standard protocol, the other is through UVC custom protocol with extension unit.
## Standard Protocol
| Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Note |
| :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :--- |
| Gain | gain | 2 | 24 | 0 | 48 | √ | 0x12 | valid if manual-exposure |
| Brightness | brightness/exposure_time | 2 | 120 | 0 | 240 | √ | 0x14 | valid if manual-exposure |
| Contrast | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | valid if manual-exposure |
## Custom Protocol
| Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Channel | Note |
| :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :------ | :----- |
| 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 |
| Max exposure time | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | valid if auto-exposure |
| Desired brightness | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | valid if auto-exposure |
| IR control | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | |
| HDR mode | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0: 10-bit; 1: 12-bit |
| Zero drift calibration | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | |
| Erase chip | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | |

View File

@@ -0,0 +1,53 @@
# Control Channels {#spec_control_channel}
| Name | Field | Address | Bandwidth | Node |
| :----- | :----- | :----- | :----- | :----- |
| Camera control channel | XU_CAM_CTRL_CHANNEL | 1 | 3 | |
| Half-Duplex channel | XU_HALF_DUPLEX_CHANNEL | 2 | 20 | |
| IMU write channel | XU_IMUDATA_WRITE_CHANNEL | 3 | 5 | |
| IMU read channel | XU_IMUDATA_READ_CHANNEL | 4 | 2000 | |
| File channel | XU_FILE_CHANNEL | 5 | 2000 | |
## Camera Control Channel
The channel provides get, set and query (min, max, default).
## Half-Duplex Channel
The channel only provides set, such as zero drift correction.
## IMU Channel
The channel is used to request and response IMU data, see @ref spec_imu_data.
## File Channel
The channel is used to read and write device information, image params, and IMU params.
| Name | Header | Size | File | Checksum |
| :--- | :- | :--- | :--- | :-------- |
| Bytes | 1 | 2 | - | 1 |
| Type | uint8_t | uint16_t | - | uint8_t |
| Description | Flags | Content size | Content data | Checksum, XOR of all content bytes |
| Header Bit Subscript | Description |
| :------------------- | :---------- |
| 0 | Device information |
| 1 | Image params |
| 2 | IMU params |
| 3~6 | Undefined |
| 7 | 0: Get; 1: Set |
### File Content Packet
| Name | ID | Size | Content |
| :--- | :- | :--- | :------ |
| Bytes | 1 | 2 | - |
| Type | uint8_t | uint16_t | - |
| Description | Content ID | Content size | Content data |
| File | ID | Max Size |
| :--- | :- | :------- |
| Device information | 1 | 250 |
| Image params | 2 | 250 |
| IMU params | 4 | 500 |

View File

@@ -0,0 +1,14 @@
# Device Information {#spec_hardware_info}
| Name | Field | Fixed Value | USB Descriptor | UVC Extension Unit | Bytes | Note |
| :----- | :----- | :-------- | :-------------- | :----------------- | :-------- | :----- |
| VID | vid | 0x04B4 | √ | × | 2 | |
| PID | pid | 0x00F9 | √ | × | 2 | |
| Device name | name | MYNT-EYE-? | √ | √ Get | 16 | MYNT-EYE-S1000 |
| Serial number | serial_number | - | √ | √ Get | 16 | |
| Firmware version | firmware_version | - | √ | √ Get | 2 | major,minor |
| Hardware version | hardware_version | - | × | √ Get | 3 | major,minor,flag |
| Spec version | spec_version | - | × | √ Get | 2 | major,minor |
| Lens type | lens_type | - | × | √ Get/Set | 4 | vendor(2),product(2); default: 0 |
| IMU type | imu_type | - | × | √ Get/Set | 4 | vendor(2),product(2); default: 0 |
| Nominal baseline | nominal_baseline | - | × | √ Get/Set | 2 | unit: mm; default: 0 |

20
doc/en/spec_image_data.md Normal file
View File

@@ -0,0 +1,20 @@
# Image Data {#spec_image_data}
| Name | Field | Unit | Bytes | Note |
| :----- | :----- | :----- | :-------- | :----- |
| Frame ID | frame_id | - | 2 | uint16_t; [0,65535] |
| Timestamp | timestamp | 10 us | 4 | uint32_t |
| Exposure Time | exposure_time | 10 us | 2 | uint16_t |
## Image Packet
| Name | Header | Size | Frame ID | Timestamp | Exposure Time | Checksum |
| :--- | :----- | :--- | :------- | :-------- | :------------ | :------- |
| Bytes | 1 | 1 | 2 | 4 | 2 | 1 |
| Type | uint8_t | uint8_t | uint16_t | uint32_t | uint16_t | uint8_t |
| Description | 0x3B | 0x08, content size | Frame ID | Timestamp | Exposure time | Checksum, XOR of all content bytes |
* The image packet will be dropped, if checksum is incorrect.
* The accuracy of the time unit: 0.01 ms / 10 us.
* The timestamp could indicate 11.9 hours, it will accumulate again after overflow.
* The timestamp accumulation starts from the time of power-on, instead of opening.

View File

@@ -0,0 +1,23 @@
# Image Params {#spec_image_params}
## Image Intrinsics
| Name | Field | Unit | Bytes | Note |
| :----- | :----- | :----- | :-------- | :----- |
| Image width | width | px | 2 | uint16_t; [0,65535] |
| Image height | height | px | 2 | uint16_t; [0,65535] |
| Focal length | fx | - | 8 | double |
| ^ | fy | - | 8 | double |
| Principal point | cx | - | 8 | double |
| ^ | cy | - | 8 | double |
| Distortion model | model | - | 1 | uint8_t; pinhole,... |
| Distortion coefficients | coeffs[5] | - | 40 | double; k1,k2,p1,p2,k3 |
## Image Extrinsics
Transformation matrix from left image to right image.
| Name | Field | Unit | Bytes | Note |
| :----- | :----- | :----- | :-------- | :----- |
| Rotation matrix | rotation[3][3] | - | 72 | double |
| Translation vector | translation[3] | - | 24 | double |

42
doc/en/spec_imu_data.md Normal file
View File

@@ -0,0 +1,42 @@
# IMU Data {#spec_imu_data}
## IMU Request Packet
| Name | Header | Serial Number |
| :--- | :----- | :------------ |
| Bytes | 1 | 4 |
| Type | uint8_t | uint32_t |
| Description | 0x5A | First request should be 0, otherwise the last one |
## IMU Response Packet
The IMU response packet contains multiple IMU packets, and each IMU packet contains multiple IMU segments.
| Name | Header | State | Size | IMU Packets | Checksum |
| :--- | :----- | :---- | :--- | :---------- | :------- |
| Bytes | 1 | 1 | 2 | ... | 1 |
| Type | uint8_t | uint8_t | uint16_t | - | uint8_t |
| Description | 0x5B | 0 is success, others are failed | Content size | IMU packets | Checksum, XOR of all content bytes |
### IMU Packet
The IMU packet is an array of IMU datas.
| Name | Serial Number | Timestamp | Count | IMU Datas |
| :--- | :------------ | :-------- | :---- | :-------- |
| Bytes | 4 | 4 | 1 | ... |
| Type | uint32_t | uint32_t | uint8_t | - |
| Description | Serial number | IMU basic timestamp | The number of IMU datas | IMU datas |
### IMU Segment
| Name | Offset | Frame ID | Accelerometer | Temperature | Gyroscope |
| :--- | :----- | :------- | :------------ | :---------- | :-------- |
| Bytes | 2 | 2 | 6 | 2 | 6 |
| Type | int16_t | uint16_t | int16_t * 3 | int16_t | int16_t * 3 |
| Description | The timestamp offset | Image frame ID | Accel x,y,z values | IMU temperature | Gyro x,y,z values |
* Formula for converting the accel & gyro values to real ones: **real = data * range / 0x10000** .
* ``accel`` default ``range`` is **8 g**, ``gyro`` default ``range`` is **1000 deg/s**.
* Formula for converting the temperature to real value: **real = data / ratio + offset** .
* default ``ratio`` is **326.8**, default ``offset`` is **25℃**.

23
doc/en/spec_imu_params.md Normal file
View File

@@ -0,0 +1,23 @@
# IMU Params {#spec_imu_params}
## IMU Intrinsics
| Name | Field | Unit | Bytes | Note |
| :----- | :----- | :----- | :-------- | :----- |
| Scale matrix | acc_scale[3][3] | - | 72 | double |
| ^ | gyro_scale[3][3] | - | 72 | double |
| Zero-drift | acc_drift[3] | - | 24 | double |
| ^ | gyro_drift[3] | - | 24 | double |
| Noise density | acc_noise[3] | - | 24 | double |
| ^ | gyro_noise[3] | - | 24 | double |
| Random walk | acc_bias[3] | - | 24 | double |
| ^ | gyro_bias[3] | - | 24 | double |
## IMU Extrinsics
Transformation matrix from left image to IMU.
| Name | Field | Unit | Bytes | Note |
| :----- | :----- | :----- | :-------- | :----- |
| Rotation matrix | rotation[3][3] | - | 72 | double |
| Translation vector | translation[3] | - | 24 | double |

4
doc/en/specs_ctrl.md Normal file
View File

@@ -0,0 +1,4 @@
# Device Control Specification {#specs_ctrl}
* @subpage spec_control_api
* @subpage spec_control_channel

7
doc/en/specs_data.md Normal file
View File

@@ -0,0 +1,7 @@
# Device Data Specification {#specs_data}
* @subpage spec_hardware_info
* @subpage spec_image_params
* @subpage spec_imu_params
* @subpage spec_image_data
* @subpage spec_imu_data

View File

@@ -1,4 +1,4 @@
# Doxyfile 1.8.13
# Doxyfile 1.8.14
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -20,8 +20,8 @@
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all text
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
# for the list of possible encodings.
# built into libc) for the transcoding. See
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
# The default value is: UTF-8.
DOXYFILE_ENCODING = UTF-8
@@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE SDK"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 2.0.0-rc
PROJECT_NUMBER = 2.2.1-rc
# 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
@@ -236,7 +236,8 @@ TAB_SIZE = 2
# will allow you to put the command \sideeffect (or @sideeffect) in the
# documentation, which will result in a user-defined paragraph with heading
# "Side Effects:". You can put \n's in the value part of an alias to insert
# newlines.
# newlines (in the resulting output). You can put ^^ in the value part of an
# alias to insert a newline as if a physical newline was in the original file.
ALIASES =
@@ -337,7 +338,7 @@ BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
# will parse them like normal C++ but will assume all classes use public instead
# of private inheritance when no explicit protection keyword is present.
# The default value is: NO.
@@ -708,7 +709,7 @@ LAYOUT_FILE =
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
# extension is automatically appended if omitted. This requires the bibtex tool
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
# For LaTeX the style of the bibliography can be controlled using
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
# search path. See also \cite for info how to create references.
@@ -791,14 +792,6 @@ WARN_LOGFILE =
# Note: If this tag is empty the current directory is searched.
INPUT = mainpage.md \
guides.md \
guide_build_linux.md \
guide_build_win.md \
guide_samples.md \
guide_tools.md \
guide_log.md \
guide_opencv.md \
guide_ros.md \
specs_data.md \
spec_hardware_info.md \
spec_image_params.md \
@@ -808,12 +801,12 @@ 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
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
# possible encodings.
# The default value is: UTF-8.
@@ -891,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
@@ -1061,7 +1055,7 @@ SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
# (see http://www.gnu.org/software/global/global.html). You will need version
# (see https://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
#
# To use it do the following:
@@ -1206,7 +1200,7 @@ HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a colorwheel, see
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
# Minimum value: 0, maximum value: 359, default value: 220.
@@ -1242,6 +1236,17 @@ HTML_COLORSTYLE_GAMMA = 80
HTML_TIMESTAMP = NO
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that
# are dynamically created via Javascript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have Javascript,
# like the Qt help browser.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_DYNAMIC_MENUS = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
@@ -1265,12 +1270,12 @@ HTML_INDEX_NUM_ENTRIES = 100
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
# environment (see: https://developer.apple.com/tools/xcode/), introduced with
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
# Makefile in the HTML output directory. Running make will produce the docset in
# that directory and running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1386,7 +1391,7 @@ QCH_FILE =
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1394,8 +1399,7 @@ QHP_NAMESPACE = com.slightech.mynteye
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
# folders).
# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.
@@ -1403,23 +1407,21 @@ QHP_VIRTUAL_FOLDER = doc
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
# filters).
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_NAME =
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
# filters).
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
@@ -1512,7 +1514,7 @@ EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
@@ -1524,7 +1526,7 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# http://www.mathjax.org) which uses client side Javascript for the rendering
# https://www.mathjax.org) which uses client side Javascript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
@@ -1551,11 +1553,11 @@ MATHJAX_FORMAT = HTML-CSS
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from http://www.mathjax.org before deployment.
# The default value is: http://cdn.mathjax.org/mathjax/latest.
# MathJax from https://www.mathjax.org before deployment.
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
# extension names that should be enabled during MathJax rendering. For example
@@ -1613,7 +1615,7 @@ SERVER_BASED_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/).
# Xapian (see: https://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
@@ -1626,7 +1628,7 @@ EXTERNAL_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: http://xapian.org/). See the section "External Indexing and
# Xapian (see: https://xapian.org/). See the section "External Indexing and
# Searching" for details.
# This tag requires that the tag SEARCHENGINE is set to YES.
@@ -1815,7 +1817,7 @@ LATEX_SOURCE_CODE = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# The default value is: plain.
# This tag requires that the tag GENERATE_LATEX is set to YES.
@@ -1998,9 +2000,9 @@ DOCBOOK_PROGRAMLISTING = NO
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
# AutoGen Definitions (see http://autogen.sf.net) file that captures the
# structure of the code including all documentation. Note that this feature is
# still experimental and incomplete at the moment.
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
# the structure of the code including all documentation. Note that this feature
# is still experimental and incomplete at the moment.
# The default value is: NO.
GENERATE_AUTOGEN_DEF = NO

View File

@@ -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;` ,重新编译。

View File

@@ -1,9 +1,11 @@
# MYNT EYE SDK {#mainpage}
* API 模块
* <a class="el" href="annotated.html">API 类</a>
* <a class="el" href="modules.html">API 模块</a>
* \link enumerations 枚举类型\endlink
* \link datatypes 数据类型\endlink
* \link utils 工具函数\endlink
* \link calibration 内参与外参\endlink
* 设备说明
* <span style="font-weight:bold">设备说明</span>
* @subpage specs_data
* @subpage specs_ctrl

View File

@@ -1,4 +1,4 @@
# 控制 API 说明 {#spec_contorl_api}
# 控制 API 说明 {#spec_control_api}
控制有两种实现方式,一是通过 UVC 标准协议,二是通过 UVC 拓展通道自定义协议。
@@ -8,21 +8,21 @@
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----- |
| 增益 | gain | 2 | 24 | 0 | 48 | √ | 0x12 | 关闭自动曝光,手动设定的参数 |
| 亮度 | brightness/exposure_time | 2 | 120 | 0 | 240 | √ | 0x14 | 关闭自动曝光,手动设定的参数 |
| 对比度 | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | |
| 对比度 | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | 关闭自动曝光,手动设定的参数 |
> UVC 标准协议实现的控制,有现成的 API 进行 Get & Set ,包括 Min, Max, Default 。
## 自定义协议
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 通道地址 | 说明 |
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----------- | :----- |
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | 步进为5即有效值为{10,15,20,25,30,35,40,45,50,55,60} |
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | 有效值为{100,200,250,333,500} |
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0x0100 | 0开启自动曝光 1关闭 |
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
| 期望亮度 | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | 0x0100 | |
| IR 控制 | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | 0x0100 | |
| HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0x0100 | 010-bit112-bit |
| 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | 0x0200 | |
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | 0x0200 | |
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 说明 |
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----- |
| 图像帧率 | 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 | 开始自动曝光,可设定的阈值 |
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
| 期望亮度 | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
| IR 控制 | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | |
| HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 010-bit112-bit |
| 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | |
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | |

View File

@@ -1,4 +1,4 @@
# 拓展通道说明 {#spec_contorl_channel}
# 拓展通道说明 {#spec_control_channel}
| 名称 | 字段 | 地址 | 带宽 | 说明 |
| :----- | :----- | :----- | :----- | :----- |
@@ -14,7 +14,7 @@
## 半双工通道
半双工通道是那些仅需 Get 或 Set 的控制通道,如请求零漂矫正。
半双工通道是那些仅需 Set 的控制通道,如请求零漂矫正。
## IMU 通道
@@ -25,18 +25,18 @@
用来读写硬件信息、图像参数、 IMU 参数的通道。
| Name | Header | Size | File | Checksum |
| :--- | :- | :--- | :--- | :-------- |
| :--- | :----- | :--- | :--- | :-------- |
| 字节数 | 1 | 2 | - | 1 |
| 类型 | uint8_t | uint16_t | - | uint8_t |
| 描述 | 标识 | 文件内容大小 | 文件内容 | 校验码(文件内容所有字节异或) |
| Header bit | Description |
| :--------- | :---------- |
| 0 | 0: Get; 1: Set |
| 1~4 | 未定义 |
| 5 | IMU 参数 |
| 6 | 图像参数 |
| 7 | 硬件信息 |
| Header Bit Subscript | Description |
| :------------------- | :---------- |
| 0 | 硬件信息 |
| 1 | 图像参数 |
| 2 | IMU 参数 |
| 3~6 | 未定义 |
| 7 | 0: Get; 1: Set |
### 文件内容包

View File

@@ -5,7 +5,7 @@
| VID | vid | 0x04B4 | √ | × | 2 | |
| PID | pid | 0x00F9 | √ | × | 2 | |
| 设备名称 | name | MYNT-EYE-? | √ | √ Get | 16 | MYNT-EYE-S1000 |
| 序列号 | serial_number | - | √ | √ Get | 16 | |
| 序列号 | serial_number | - | √ | √ Get | 16 | |
| 固件版本 | firmware_version | - | √ | √ Get | 2 | major,minor |
| 硬件版本 | hardware_version | - | × | √ Get | 3 | major,minor,flag |
| 协议版本 | spec_version | - | × | √ Get | 2 | major,minor |

View File

@@ -10,13 +10,13 @@
## 图像数据包
| Name | Header | Size | FrameID | Timestamp | ExposureTime | Checksum |
| :--- | :----- | :--- | :------ | :-------- | :----------- | :------- |
| Name | Header | Size | Frame ID | Timestamp | Exposure Time | Checksum |
| :--- | :----- | :--- | :------- | :-------- | :------------ | :------- |
| 字节数 | 1 | 1 | 2 | 4 | 2 | 1 |
| 类型 | uint8_t | uint8_t | uint16_t | uint32_t | uint16_t | uint8_t |
| 描述 | 0x3B | 0x08 (数据内容大小) | 帧 ID | 时间戳 | 曝光时间 | 校验码(数据内容所有字节异或) |
* 数据包校验不过,会丢弃该帧。
* 时间单位精度为: 0.01 ms / 10 us 。
* 时间单位精度为: 0.01 ms / 10 us 。
* 4 字节能表示的最大时间约是 11.9 小时,溢出后将重累计。
* 时间累计是从上电时从开始,而不是从打开时开始。

View File

@@ -13,7 +13,7 @@
| 畸变模型 | model | - | 1 | uint8_t; pinhole,... |
| 畸变参数 | coeffs[5] | - | 40 | double; k1,k2,p1,p2,k3 |
> 图像内参不同分辨率会不同。如果多分辨率的话,就会有多个。
> 图像分辨率不同,内参不同。多分辨率的话,有多个内参
## 图像外参

View File

@@ -30,11 +30,11 @@ IMU 包/小包,是一组 IMU 数据。
### IMU 段
| Name | Offset | FrameID | Accelerometer | Temperature | Gyroscope |
| :--- | :----- | :------ | :------------ | :---------- | :-------- |
| Name | Offset | Frame ID | Accelerometer | Temperature | Gyroscope |
| :--- | :----- | :------- | :------------ | :---------- | :-------- |
| 字节数 | 2 | 2 | 6 | 2 | 6 |
| 类型 | int16_t | uint16_t | int16_t * 3 | int16_t | int16_t * 3 |
| Description | 相对基准时间戳的偏移量 | 图像帧 ID | 加速度计 x y z 三轴的值 | IMU 的温度 | 陀螺仪 x y z 三轴的值 |
| 描述 | 相对基准时间戳的偏移量 | 图像帧 ID | 加速度计 x y z 三轴的值 | IMU 的温度 | 陀螺仪 x y z 三轴的值 |
* 加速度计和陀螺仪的计量值换算成物理值公式: **real = data * range / 0x10000**
* 加速度计量程默认值为 **8 g** ,陀螺仪量程默认值为 **1000 deg/s**

View File

@@ -1,4 +1,4 @@
# 设备控制说明 {#specs_ctrl}
* @subpage spec_contorl_api
* @subpage spec_contorl_channel
* @subpage spec_control_api
* @subpage spec_control_channel

View File

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

View File

@@ -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 <glog/logging.h>
/** Helper to init glog with args. */
@@ -25,14 +27,30 @@ struct glog_init {
glog_init(int argc, char *argv[]) {
(void)argc;
// FLAGS_logtostderr = true;
FLAGS_alsologtostderr = true;
// Set whether log messages go to stderr instead of logfiles
FLAGS_logtostderr = true;
// Set whether log messages go to stderr in addition to logfiles.
// FLAGS_alsologtostderr = true;
// Set color messages logged to stderr (if supported by terminal).
FLAGS_colorlogtostderr = true;
// FLAGS_log_dir = ".";
FLAGS_max_log_size = 1024;
// Log suppression level: messages logged at a lower level than this
// are suppressed.
FLAGS_minloglevel = google::GLOG_INFO;
// If specified, logfiles are written into this directory instead of the
// default logging directory.
FLAGS_log_dir = ".";
// Sets the maximum log file size (in MB).
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;
// Show all VLOG(m) messages for m <= this.
// FLAGS_v = 2;
google::InitGoogleLogging(argv[0]);
@@ -46,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_

469
include/mynteye/miniglog.h Normal file
View File

@@ -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 <algorithm>
#include <ctime>
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include "mynteye/mynteye.h"
#ifdef MYNTEYE_OS_ANDROID
# include <android/log.h>
#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<LogSink *> 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<google::LogSink*>::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<google::LogSink *>::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<int>(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<class T>
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 <typename T>
T& CheckNotNullCommon(const char *file, int line, const char *names, T& t) {
if (t == NULL) {
LogMessageFatal(file, line, std::string(names));
}
return t;
}
template <typename T>
T* CheckNotNull(const char *file, int line, const char *names, T* t) {
return CheckNotNullCommon(file, line, names, t);
}
template <typename T>
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_

View File

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

View File

@@ -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")

View File

@@ -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}")
@@ -79,4 +75,6 @@ add_subdirectory(uvc)
# tutorials
add_subdirectory(tutorials)
if(WITH_API)
add_subdirectory(tutorials)
endif()

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/logger.h"
#include "mynteye/api.h"
#include "mynteye/times.h"

View File

@@ -14,13 +14,8 @@
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#define WIN_FLAGS \
cv::WINDOW_AUTOSIZE | cv::WINDOW_KEEPRATIO | cv::WINDOW_GUI_NORMAL
namespace {
class DepthRegion {
@@ -34,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;
}
@@ -159,14 +154,14 @@ int main(int argc, char *argv[]) {
api->Start(Source::VIDEO_STREAMING);
cv::namedWindow("frame", WIN_FLAGS);
cv::namedWindow("depth", WIN_FLAGS);
cv::namedWindow("region", WIN_FLAGS);
cv::namedWindow("frame");
cv::namedWindow("depth");
cv::namedWindow("region");
DepthRegion depth_region(3);
auto depth_info = [](
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
UNUSED(depth)
MYNTEYE_UNUSED(depth)
std::ostringstream os;
os << "depth pos: [" << point.y << ", " << point.x << "]"
<< "±" << n << ", unit: mm";

View File

@@ -14,7 +14,7 @@
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "mynteye/glog_init.h"
#include "mynteye/logger.h"
#include "mynteye/device.h"
#include "mynteye/utils.h"

View File

@@ -63,7 +63,7 @@ macro(make_executable2 NAME)
endif()
endmacro()
if(WITH_API)
# packages
# If you install PCL to different directory, please set CMAKE_PREFIX_PATH to find it.
#LIST(APPEND CMAKE_PREFIX_PATH /usr/local/share)
@@ -124,10 +124,10 @@ make_executable2(ctrl_manual_exposure
)
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
endif()
# intermediate level
make_executable2(get_all_device_info SRCS intermediate/get_all_device_info.cc WITH_OPENCV)
if(PCL_FOUND)
if(OpenCV_VERSION VERSION_LESS 4.0)

View File

@@ -13,9 +13,8 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
#include "util/cv_painter.h"

View File

@@ -13,11 +13,10 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include <atomic>
#include "mynteye/api.h"
#include "mynteye/logger.h"
#include "mynteye/times.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,9 +13,8 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,9 +13,8 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
#include "util/cv_painter.h"

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -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 <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,14 +13,13 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include <atomic>
#include <memory>
#include <mutex>
#include <sstream>
#include "mynteye/api.h"
#include "mynteye/logger.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<std::mutex> _(depth_mtx);

View File

@@ -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 <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
MYNTEYE_USE_NAMESPACE
@@ -25,8 +24,8 @@ int main(int argc, char *argv[]) {
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
<< "}";
LOG(INFO) << "Extrinsics left to right: {"
<< api->GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
LOG(INFO) << "Extrinsics right to left: {"
<< api->GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
return 0;
}

View File

@@ -13,9 +13,8 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
#include "util/cv_painter.h"

View File

@@ -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 <glog/logging.h>
#include "mynteye/api.h"
#include "mynteye/logger.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "util/pc_viewer.h"

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include <opencv2/highgui/highgui.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
MYNTEYE_USE_NAMESPACE

View File

@@ -0,0 +1,50 @@
// 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 "mynteye/context.h"
#include "mynteye/device.h"
#include "mynteye/logger.h"
MYNTEYE_USE_NAMESPACE
int main(int argc, char *argv[]) {
glog_init _(argc, argv);
LOG(INFO) << "Detecting MYNT EYE devices";
Context context;
auto &&devices = context.devices();
size_t n = devices.size();
if (n <= 0) {
LOG(ERROR) << "No MYNT EYE devices :(";
return 1;
}
for (size_t i = 0; i < n; i++) {
auto &&device = devices[i];
LOG(INFO) << "MYNT EYE device index: " << i;
LOG(INFO) << " Device name: " << device->GetInfo(Info::DEVICE_NAME);
LOG(INFO) << " Serial number: " << device->GetInfo(Info::SERIAL_NUMBER);
LOG(INFO) << " Firmware version: "
<< device->GetInfo(Info::FIRMWARE_VERSION);
LOG(INFO) << " Hardware version: "
<< device->GetInfo(Info::HARDWARE_VERSION);
LOG(INFO) << " Spec version: " << device->GetInfo(Info::SPEC_VERSION);
LOG(INFO) << " Lens type: " << device->GetInfo(Info::LENS_TYPE);
LOG(INFO) << " IMU type: " << device->GetInfo(Info::IMU_TYPE);
LOG(INFO) << " Nominal baseline: "
<< device->GetInfo(Info::NOMINAL_BASELINE);
}
return 0;
}

View File

@@ -14,16 +14,11 @@
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <glog/logging.h>
#include "mynteye/api.h"
#include "util/cv_painter.h"
#include "util/pc_viewer.h"
#define WIN_FLAGS \
cv::WINDOW_AUTOSIZE | cv::WINDOW_KEEPRATIO | cv::WINDOW_GUI_NORMAL
namespace {
class DepthRegion {
@@ -37,7 +32,7 @@ class DepthRegion {
* 鼠标事件:默认不选中区域,随鼠标移动而显示。单击后,则会选中区域来显示。你可以再单击已选中区域或双击未选中区域,取消选中。
*/
void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
UNUSED(flags)
MYNTEYE_UNUSED(flags)
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
return;
}
@@ -162,14 +157,14 @@ int main(int argc, char *argv[]) {
api->Start(Source::VIDEO_STREAMING);
cv::namedWindow("frame", WIN_FLAGS);
cv::namedWindow("depth", WIN_FLAGS);
cv::namedWindow("region", WIN_FLAGS);
cv::namedWindow("frame");
cv::namedWindow("depth");
cv::namedWindow("region");
DepthRegion depth_region(3);
auto depth_info = [](
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
UNUSED(depth)
MYNTEYE_UNUSED(depth)
std::ostringstream os;
os << "depth pos: [" << point.y << ", " << point.x << "]"
<< "±" << n << ", unit: mm";

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include "util/cv_painter.h"
#include <glog/logging.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <iomanip>
@@ -22,6 +20,7 @@
#include <memory>
#include <utility>
#include "mynteye/logger.h"
#include "mynteye/utils.h"
#define FONT_FACE cv::FONT_HERSHEY_PLAIN

View File

@@ -13,12 +13,12 @@
// limitations under the License.
#include "util/pc_viewer.h"
#include <glog/logging.h>
// #include <pcl/common/common_headers.h>
#include <cmath>
#include "mynteye/logger.h"
std::shared_ptr<pcl::visualization::PCLVisualizer> CustomColorVis(
pcl::PointCloud<pcl::PointXYZ>::ConstPtr pc) {
// --------------------------------------------

View File

@@ -20,7 +20,7 @@
#include <iostream>
#include <mutex>
#include "mynteye/glog_init.h"
#include "mynteye/logger.h"
#include "mynteye/mynteye.h"
#include "mynteye/types.h"
#include "uvc/uvc.h"
@@ -157,7 +157,7 @@ int main(int argc, char *argv[]) {
t = static_cast<double>(cv::getTickCount() - t);
fps = cv::getTickFrequency() / t;
}
UNUSED(fps)
MYNTEYE_UNUSED(fps)
uvc::stop_streaming(*device);
// cv::destroyAllWindows();

View File

@@ -14,163 +14,29 @@
# limitations under the License.
# _VERBOSE_=1
# _INIT_LINTER_=1
# _FORCE_INSRALL_=1
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
# default python on MSYS
PYTHON="python2"
fi
_detect $PYTHON
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
_echo_sn "Install pip"
[ -f "get-pip.py" ] || curl -O https://bootstrap.pypa.io/get-pip.py
$SUDO $PYTHON get-pip.py
fi
# pip install
_echo_d "pip install --upgrade autopep8 cpplint pylint requests"
$SUDO pip install --upgrade autopep8 cpplint pylint requests
## 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
_echo_s "Init git hooks"
$PYTHON "$ROOT_DIR/tools/linter/init-git-hooks.py"
## cmake version
_echo_s "Expect cmake version >= 3.0"

214
scripts/init_tools.sh Normal file
View File

@@ -0,0 +1,214 @@
#!/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
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=($@)
_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 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_

View File

@@ -18,21 +18,20 @@
#include <boost/range/iterator_range.hpp>
#endif
#include <glog/logging.h>
#include <algorithm>
#include <thread>
#include "mynteye/glog_init.h"
#include "mynteye/logger.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"
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
#if defined(OS_WIN)
#if defined(MYNTEYE_OS_WIN)
#include <windows.h>
#endif
#endif
@@ -69,16 +68,18 @@ 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());
return (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY));
return (attrs != INVALID_FILE_ATTRIBUTES) &&
!(attrs & FILE_ATTRIBUTE_DIRECTORY);
}
bool dir_exists(const std::string &p) {
DWORD attrs = GetFileAttributes(p.c_str());
return (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY));
return (attrs != INVALID_FILE_ATTRIBUTES) &&
(attrs & FILE_ATTRIBUTE_DIRECTORY);
}
#else
@@ -89,7 +90,7 @@ bool dir_exists(const std::string &p) {
std::vector<std::string> get_plugin_paths() {
std::string info_path(MYNTEYE_SDK_INSTALL_DIR);
info_path.append(OS_SEP "share" OS_SEP "mynteye" OS_SEP "build.info");
info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info");
cv::FileStorage fs(info_path, cv::FileStorage::READ);
if (!fs.isOpened()) {
@@ -186,13 +187,13 @@ std::vector<std::string> get_plugin_paths() {
std::vector<std::string> dirs{MYNTEYE_SDK_ROOT_DIR, MYNTEYE_SDK_INSTALL_DIR};
for (auto &&plat : plats) {
for (auto &&dir : dirs) {
auto &&plat_dir = dir + OS_SEP "plugins" + OS_SEP + plat;
auto &&plat_dir = dir + MYNTEYE_OS_SEP "plugins" + MYNTEYE_OS_SEP + plat;
// VLOG(2) << "plat_dir: " << plat_dir;
if (!dir_exists(plat_dir))
continue;
for (auto &&name : names) {
// VLOG(2) << " name: " << name;
auto &&path = plat_dir + OS_SEP + name;
auto &&path = plat_dir + MYNTEYE_OS_SEP + name;
if (!file_exists(path))
continue;
paths.push_back(path);
@@ -207,9 +208,29 @@ std::vector<std::string> get_plugin_paths() {
} // namespace
API::API(std::shared_ptr<Device> device)
: device_(device), synthetic_(new Synthetic(this)) {
API::API(std::shared_ptr<Device> device) : device_(device) {
VLOG(2) << __func__;
if (std::dynamic_pointer_cast<StandardDevice>(device_) != nullptr) {
bool in_l_ok, in_r_ok, ex_r2l_ok;
device_->GetIntrinsics(Stream::LEFT, &in_l_ok);
device_->GetIntrinsics(Stream::RIGHT, &in_r_ok);
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT, &ex_r2l_ok);
if (!in_l_ok || !in_r_ok || !ex_r2l_ok) {
#if defined(WITH_DEVICE_INFO_REQUIRED)
LOG(FATAL)
#else
LOG(WARNING)
#endif
<< "Image params not found, but we need it to process the "
"images. Please `make tools` and use `img_params_writer` "
"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) "
"to learn more.";
}
}
synthetic_.reset(new Synthetic(this));
}
API::~API() {

View File

@@ -246,12 +246,12 @@ class MYNTEYE_API API {
void DisableStreamData(const Stream &stream);
/**
* Get the datas of stream.
* @note default cache 4 datas at most.
* Get the latest data of stream.
*/
api::StreamData GetStreamData(const Stream &stream);
/**
* Get the latest data of stream.
* Get the datas of stream.
* @note default cache 4 datas at most.
*/
std::vector<api::StreamData> GetStreamDatas(const Stream &stream);

View File

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

View File

@@ -13,12 +13,14 @@
// limitations under the License.
#include "api/processor/depth_processor.h"
#include <glog/logging.h>
#include "mynteye/logger.h"
#include <utility>
MYNTEYE_BEGIN_NAMESPACE
const char DepthProcessor::NAME[] = "DepthProcessor";
DepthProcessor::DepthProcessor(std::int32_t proc_period)
: Processor(std::move(proc_period)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
@@ -38,7 +40,7 @@ Object *DepthProcessor::OnCreateOutput() {
bool DepthProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
cv::Mat channels[3 /*input->value.channels()*/];

View File

@@ -23,7 +23,7 @@ MYNTEYE_BEGIN_NAMESPACE
class DepthProcessor : public Processor {
public:
static constexpr auto &&NAME = "DepthProcessor";
static const char NAME[];
explicit DepthProcessor(std::int32_t proc_period = 0);
virtual ~DepthProcessor();

View File

@@ -15,12 +15,15 @@
#include <opencv2/imgproc/imgproc.hpp>
#include <glog/logging.h>
#include <utility>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
const char DisparityNormalizedProcessor::NAME[] =
"DisparityNormalizedProcessor";
DisparityNormalizedProcessor::DisparityNormalizedProcessor(
std::int32_t proc_period)
: Processor(std::move(proc_period)) {
@@ -41,7 +44,7 @@ Object *DisparityNormalizedProcessor::OnCreateOutput() {
bool DisparityNormalizedProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1);

View File

@@ -23,7 +23,7 @@ MYNTEYE_BEGIN_NAMESPACE
class DisparityNormalizedProcessor : public Processor {
public:
static constexpr auto &&NAME = "DisparityNormalizedProcessor";
static const char NAME[];
explicit DisparityNormalizedProcessor(std::int32_t proc_period = 0);
virtual ~DisparityNormalizedProcessor();

View File

@@ -15,12 +15,14 @@
#include <opencv2/calib3d/calib3d.hpp>
#include <glog/logging.h>
#include <utility>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
const char DisparityProcessor::NAME[] = "DisparityProcessor";
DisparityProcessor::DisparityProcessor(std::int32_t proc_period)
: Processor(std::move(proc_period)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
@@ -72,7 +74,7 @@ Object *DisparityProcessor::OnCreateOutput() {
bool DisparityProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat *output = Object::Cast<ObjMat>(out);

View File

@@ -29,7 +29,7 @@ MYNTEYE_BEGIN_NAMESPACE
class DisparityProcessor : public Processor {
public:
static constexpr auto &&NAME = "DisparityProcessor";
static const char NAME[];
explicit DisparityProcessor(std::int32_t proc_period = 0);
virtual ~DisparityProcessor();

View File

@@ -17,6 +17,8 @@
#include <opencv2/core/core.hpp>
#include <memory>
#include "mynteye/mynteye.h"
MYNTEYE_BEGIN_NAMESPACE
@@ -29,6 +31,7 @@ struct MYNTEYE_API Object {
virtual ~Object() = default;
virtual Object *Clone() const = 0;
virtual bool DecValidity() const = 0;
/** Cast the obj to T pointer */
template <typename T>
@@ -41,6 +44,11 @@ struct MYNTEYE_API Object {
static const T *Cast(const Object *obj) {
return dynamic_cast<const T *>(obj);
}
template <typename T>
static std::shared_ptr<T> Cast(const std::shared_ptr<Object> &obj) {
return std::dynamic_pointer_cast<T>(obj);
}
};
/**
@@ -58,6 +66,10 @@ struct MYNTEYE_API ObjMat : public Object {
mat->value = value.clone();
return mat;
}
bool DecValidity() const {
return !value.empty();
}
};
/**
@@ -80,6 +92,10 @@ struct MYNTEYE_API ObjMat2 : public Object {
mat2->second = second.clone();
return mat2;
}
bool DecValidity() const {
return !first.empty() && !second.empty();
}
};
MYNTEYE_END_NAMESPACE

View File

@@ -15,12 +15,14 @@
#include <opencv2/calib3d/calib3d.hpp>
#include <glog/logging.h>
#include <utility>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
const char PointsProcessor::NAME[] = "PointsProcessor";
PointsProcessor::PointsProcessor(cv::Mat Q, std::int32_t proc_period)
: Processor(std::move(proc_period)), Q_(std::move(Q)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
@@ -40,7 +42,7 @@ Object *PointsProcessor::OnCreateOutput() {
bool PointsProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat *input = Object::Cast<ObjMat>(in);
ObjMat *output = Object::Cast<ObjMat>(out);
cv::reprojectImageTo3D(input->value, output->value, Q_, true);

View File

@@ -25,7 +25,7 @@ MYNTEYE_BEGIN_NAMESPACE
class PointsProcessor : public Processor {
public:
static constexpr auto &&NAME = "PointsProcessor";
static const char NAME[];
explicit PointsProcessor(cv::Mat Q, std::int32_t proc_period = 0);
virtual ~PointsProcessor();

View File

@@ -13,10 +13,12 @@
// limitations under the License.
#include "api/processor/processor.h"
#include <glog/logging.h>
#include <exception>
#include <utility>
#include "mynteye/logger.h"
#include "internal/strings.h"
#include "internal/times.h"
MYNTEYE_BEGIN_NAMESPACE
@@ -128,6 +130,10 @@ bool Processor::Process(const Object &in) {
return false;
}
}
if (!in.DecValidity()) {
LOG(WARNING) << Name() << " process with invalid input";
return false;
}
{
std::lock_guard<std::mutex> lk(mtx_input_ready_);
input_.reset(in.Clone());
@@ -137,9 +143,9 @@ bool Processor::Process(const Object &in) {
return true;
}
Object *Processor::GetOutput() {
std::shared_ptr<Object> Processor::GetOutput() {
std::lock_guard<std::mutex> lk(mtx_result_);
return output_result_.get();
return std::shared_ptr<Object>(std::move(output_result_));
}
std::uint64_t Processor::GetDroppedCount() {
@@ -192,14 +198,21 @@ void Processor::Run() {
pre_callback_(input_.get());
}
bool ok = false;
if (callback_) {
if (callback_(input_.get(), output_.get(), parent_)) {
ok = true;
try {
if (callback_) {
if (callback_(input_.get(), output_.get(), parent_)) {
ok = true;
} else {
ok = OnProcess(input_.get(), output_.get(), parent_);
}
} else {
ok = OnProcess(input_.get(), output_.get(), parent_);
}
} else {
ok = OnProcess(input_.get(), output_.get(), parent_);
// CV_Assert(false);
} catch (const std::exception &e) {
std::string msg(e.what());
strings::rtrim(msg);
LOG(ERROR) << Name() << " process error \"" << msg << "\"";
}
if (!ok) {
VLOG(2) << Name() << " process failed";

View File

@@ -65,7 +65,7 @@ class Processor /*: public std::enable_shared_from_this<Processor>*/ {
* Returns the last output.
* @note Returns null if not output now.
*/
Object *GetOutput();
std::shared_ptr<Object> GetOutput();
std::uint64_t GetDroppedCount();

View File

@@ -16,21 +16,23 @@
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <glog/logging.h>
#include <utility>
#include "mynteye/logger.h"
#include "device/device.h"
MYNTEYE_BEGIN_NAMESPACE
const char RectifyProcessor::NAME[] = "RectifyProcessor";
RectifyProcessor::RectifyProcessor(
std::shared_ptr<Device> device, std::int32_t proc_period)
: Processor(std::move(proc_period)) {
VLOG(2) << __func__ << ": proc_period=" << proc_period;
InitParams(
device->GetIntrinsics(Stream::LEFT), device->GetIntrinsics(Stream::RIGHT),
device->GetExtrinsics(Stream::LEFT, Stream::RIGHT));
device->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
}
RectifyProcessor::~RectifyProcessor() {
@@ -47,7 +49,7 @@ Object *RectifyProcessor::OnCreateOutput() {
bool RectifyProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
const ObjMat2 *input = Object::Cast<ObjMat2>(in);
ObjMat2 *output = Object::Cast<ObjMat2>(out);
cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR);
@@ -56,7 +58,7 @@ bool RectifyProcessor::OnProcess(
}
void RectifyProcessor::InitParams(
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_left_to_right) {
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left) {
cv::Size size{in_left.width, in_left.height};
cv::Mat M1 =
@@ -68,12 +70,12 @@ void RectifyProcessor::InitParams(
cv::Mat D1(1, 5, CV_64F, in_left.coeffs);
cv::Mat D2(1, 5, CV_64F, in_right.coeffs);
cv::Mat R =
(cv::Mat_<double>(3, 3) << ex_left_to_right.rotation[0][0],
ex_left_to_right.rotation[0][1], ex_left_to_right.rotation[0][2],
ex_left_to_right.rotation[1][0], ex_left_to_right.rotation[1][1],
ex_left_to_right.rotation[1][2], ex_left_to_right.rotation[2][0],
ex_left_to_right.rotation[2][1], ex_left_to_right.rotation[2][2]);
cv::Mat T(3, 1, CV_64F, ex_left_to_right.translation);
(cv::Mat_<double>(3, 3) << ex_right_to_left.rotation[0][0],
ex_right_to_left.rotation[0][1], ex_right_to_left.rotation[0][2],
ex_right_to_left.rotation[1][0], ex_right_to_left.rotation[1][1],
ex_right_to_left.rotation[1][2], ex_right_to_left.rotation[2][0],
ex_right_to_left.rotation[2][1], ex_right_to_left.rotation[2][2]);
cv::Mat T(3, 1, CV_64F, ex_right_to_left.translation);
VLOG(2) << "InitParams size: " << size;
VLOG(2) << "M1: " << M1;

View File

@@ -29,7 +29,7 @@ class Device;
class RectifyProcessor : public Processor {
public:
static constexpr auto &&NAME = "RectifyProcessor";
static const char NAME[];
RectifyProcessor(
std::shared_ptr<Device> device, std::int32_t proc_period = 0);
@@ -47,7 +47,7 @@ class RectifyProcessor : public Processor {
private:
void InitParams(
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_left_to_right);
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left);
};
MYNTEYE_END_NAMESPACE

View File

@@ -13,12 +13,12 @@
// limitations under the License.
#include "api/synthetic.h"
#include <glog/logging.h>
#include <algorithm>
#include <functional>
#include <stdexcept>
#include "mynteye/logger.h"
#include "api/plugin.h"
#include "api/processor/depth_processor.h"
#include "api/processor/disparity_normalized_processor.h"
@@ -49,6 +49,15 @@ api::StreamData data2api(const device::StreamData &data) {
return {data.img, frame2mat(data.frame), data.frame};
}
void process_childs(
const std::shared_ptr<Processor> &proc, const std::string &name,
const Object &obj) {
auto &&processor = find_processor<Processor>(proc, name);
for (auto child : processor->GetChilds()) {
child->Process(obj);
}
}
} // namespace
Synthetic::Synthetic(API *api) : api_(api), plugin_(nullptr) {
@@ -146,30 +155,30 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
auto &&device = api_->device();
return data2api(device->GetLatestStreamData(stream));
} else if (mode == MODE_SYNTHETIC) {
switch (stream) {
case Stream::LEFT_RECTIFIED: {
auto &&processor = find_processor<RectifyProcessor>(processor_);
Object *out = processor->GetOutput();
if (out != nullptr) {
ObjMat2 *output = Object::Cast<ObjMat2>(out);
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) {
static std::shared_ptr<ObjMat2> output = nullptr;
auto &&processor = find_processor<RectifyProcessor>(processor_);
auto &&out = processor->GetOutput();
if (out != nullptr) {
// Obtain the output, out will be nullptr if get again immediately.
output = Object::Cast<ObjMat2>(out);
}
if (output != nullptr) {
if (stream == Stream::LEFT_RECTIFIED) {
return {nullptr, output->first, nullptr};
}
VLOG(2) << "Rectify not ready now";
} break;
case Stream::RIGHT_RECTIFIED: {
auto &&processor = find_processor<RectifyProcessor>(processor_);
Object *out = processor->GetOutput();
if (out != nullptr) {
ObjMat2 *output = Object::Cast<ObjMat2>(out);
} else {
return {nullptr, output->second, nullptr};
}
VLOG(2) << "Rectify not ready now";
} break;
}
VLOG(2) << "Rectify not ready now";
return {};
}
switch (stream) {
case Stream::DISPARITY: {
auto &&processor = find_processor<DisparityProcessor>(processor_);
Object *out = processor->GetOutput();
auto &&out = processor->GetOutput();
if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out);
auto &&output = Object::Cast<ObjMat>(out);
return {nullptr, output->value, nullptr};
}
VLOG(2) << "Disparity not ready now";
@@ -177,27 +186,27 @@ api::StreamData Synthetic::GetStreamData(const Stream &stream) {
case Stream::DISPARITY_NORMALIZED: {
auto &&processor =
find_processor<DisparityNormalizedProcessor>(processor_);
Object *out = processor->GetOutput();
auto &&out = processor->GetOutput();
if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out);
auto &&output = Object::Cast<ObjMat>(out);
return {nullptr, output->value, nullptr};
}
VLOG(2) << "Disparity normalized not ready now";
} break;
case Stream::POINTS: {
auto &&processor = find_processor<PointsProcessor>(processor_);
Object *out = processor->GetOutput();
auto &&out = processor->GetOutput();
if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out);
auto &&output = Object::Cast<ObjMat>(out);
return {nullptr, output->value, nullptr};
}
VLOG(2) << "Points not ready now";
} break;
case Stream::DEPTH: {
auto &&processor = find_processor<DepthProcessor>(processor_);
Object *out = processor->GetOutput();
auto &&out = processor->GetOutput();
if (out != nullptr) {
ObjMat *output = Object::Cast<ObjMat>(out);
auto &&output = Object::Cast<ObjMat>(out);
return {nullptr, output->value, nullptr};
}
VLOG(2) << "Depth not ready now";
@@ -437,60 +446,50 @@ void Synthetic::InitProcessors() {
void Synthetic::ProcessNativeStream(
const Stream &stream, const api::StreamData &data) {
bool done = false;
static api::StreamData left_data, right_data;
if (stream == Stream::LEFT) {
left_data = data;
done = true;
} else if (stream == Stream::RIGHT) {
right_data = data;
done = true;
}
if (done && left_data.img && right_data.img &&
left_data.img->frame_id == right_data.img->frame_id) {
auto &&processor = find_processor<RectifyProcessor>(processor_);
processor->Process(ObjMat2{left_data.frame, right_data.frame});
}
if (done)
return;
auto &&process_childs = [this, &stream](
const std::string &name, const Object &obj) {
auto &&processor = find_processor<Processor>(processor_, name);
for (auto child : processor->GetChilds()) {
child->Process(obj);
if (stream == Stream::LEFT || stream == Stream::RIGHT) {
static api::StreamData left_data, right_data;
if (stream == Stream::LEFT) {
left_data = data;
} else if (stream == Stream::RIGHT) {
right_data = data;
}
if (left_data.img && right_data.img &&
left_data.img->frame_id == right_data.img->frame_id) {
auto &&processor = find_processor<RectifyProcessor>(processor_);
processor->Process(ObjMat2{left_data.frame, right_data.frame});
}
};
static api::StreamData left_rect_data, right_rect_data;
if (stream == Stream::LEFT_RECTIFIED) {
left_rect_data = data;
done = true;
} else if (stream == Stream::RIGHT_RECTIFIED) {
right_rect_data = data;
done = true;
}
if (done && left_rect_data.img && right_rect_data.img &&
left_rect_data.img->frame_id == right_rect_data.img->frame_id) {
process_childs(
RectifyProcessor::NAME,
ObjMat2{left_rect_data.frame, right_rect_data.frame});
}
if (done)
return;
}
if (stream == Stream::LEFT_RECTIFIED || stream == Stream::RIGHT_RECTIFIED) {
static api::StreamData left_rect_data, right_rect_data;
if (stream == Stream::LEFT_RECTIFIED) {
left_rect_data = data;
} else if (stream == Stream::RIGHT_RECTIFIED) {
right_rect_data = data;
}
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});
}
return;
}
switch (stream) {
case Stream::DISPARITY: {
process_childs(DisparityProcessor::NAME, ObjMat{data.frame});
process_childs(processor_, DisparityProcessor::NAME, ObjMat{data.frame});
} break;
case Stream::DISPARITY_NORMALIZED: {
process_childs(DisparityNormalizedProcessor::NAME, ObjMat{data.frame});
process_childs(
processor_, DisparityNormalizedProcessor::NAME, ObjMat{data.frame});
} break;
case Stream::POINTS: {
process_childs(PointsProcessor::NAME, ObjMat{data.frame});
process_childs(processor_, PointsProcessor::NAME, ObjMat{data.frame});
} break;
case Stream::DEPTH: {
process_childs(DepthProcessor::NAME, ObjMat{data.frame});
process_childs(processor_, DepthProcessor::NAME, ObjMat{data.frame});
} break;
default:
break;
@@ -499,7 +498,7 @@ void Synthetic::ProcessNativeStream(
bool Synthetic::OnRectifyProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnRectifyProcess(in, out)) {
return true;
}
@@ -509,7 +508,7 @@ bool Synthetic::OnRectifyProcess(
bool Synthetic::OnDisparityProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDisparityProcess(in, out)) {
return true;
}
@@ -518,7 +517,7 @@ bool Synthetic::OnDisparityProcess(
bool Synthetic::OnDisparityNormalizedProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDisparityNormalizedProcess(in, out)) {
return true;
}
@@ -527,7 +526,7 @@ bool Synthetic::OnDisparityNormalizedProcess(
bool Synthetic::OnPointsProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnPointsProcess(in, out)) {
return true;
}
@@ -536,7 +535,7 @@ bool Synthetic::OnPointsProcess(
bool Synthetic::OnDepthProcess(
Object *const in, Object *const out, Processor *const parent) {
UNUSED(parent)
MYNTEYE_UNUSED(parent)
if (plugin_ && plugin_->OnDepthProcess(in, out)) {
return true;
}

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#include "device/context.h"
#include <glog/logging.h>
#include "mynteye/logger.h"
#include "device/device.h"
#include "uvc/uvc.h"

View File

@@ -13,12 +13,13 @@
// limitations under the License.
#include "device/device.h"
#include <glog/logging.h>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include <utility>
#include "mynteye/logger.h"
#include "device/device_s.h"
#include "internal/async_callback.h"
#include "internal/channels.h"
@@ -54,6 +55,27 @@ struct DeviceModel {
}
};
bool CheckSupports(
const Device *const device, const Stream &stream, bool fatal = true) {
if (device->Supports(stream)) {
return true;
} else {
auto &&supports = stream_supports_map.at(device->GetModel());
std::ostringstream ss;
std::copy(
supports.begin(), supports.end(),
std::ostream_iterator<Stream>(ss, ", "));
if (fatal) {
LOG(FATAL) << "Unsupported stream: " << stream
<< ". Please use these: " << ss.str();
} else {
LOG(WARNING) << "Unsupported stream: " << stream
<< ". Please use these: " << ss.str();
}
return false;
}
}
} // namespace
Device::Device(const Model &model, std::shared_ptr<uvc::device> device)
@@ -176,21 +198,47 @@ std::string Device::GetInfo(const Info &info) const {
}
Intrinsics Device::GetIntrinsics(const Stream &stream) const {
bool ok;
return GetIntrinsics(stream, &ok);
}
Extrinsics Device::GetExtrinsics(const Stream &from, const Stream &to) const {
bool ok;
return GetExtrinsics(from, to, &ok);
}
MotionIntrinsics Device::GetMotionIntrinsics() const {
bool ok;
return GetMotionIntrinsics(&ok);
}
Extrinsics Device::GetMotionExtrinsics(const Stream &from) const {
bool ok;
return GetMotionExtrinsics(from, &ok);
}
Intrinsics Device::GetIntrinsics(const Stream &stream, bool *ok) const {
try {
*ok = true;
return stream_intrinsics_.at(stream);
} catch (const std::out_of_range &e) {
*ok = false;
LOG(WARNING) << "Intrinsics of " << stream << " not found";
return {};
}
}
Extrinsics Device::GetExtrinsics(const Stream &from, const Stream &to) const {
Extrinsics Device::GetExtrinsics(
const Stream &from, const Stream &to, bool *ok) const {
try {
*ok = true;
return stream_from_extrinsics_.at(from).at(to);
} catch (const std::out_of_range &e) {
try {
*ok = true;
return stream_from_extrinsics_.at(to).at(from).Inverse();
} catch (const std::out_of_range &e) {
*ok = false;
LOG(WARNING) << "Extrinsics from " << from << " to " << to
<< " not found";
return {};
@@ -198,20 +246,24 @@ Extrinsics Device::GetExtrinsics(const Stream &from, const Stream &to) const {
}
}
MotionIntrinsics Device::GetMotionIntrinsics() const {
MotionIntrinsics Device::GetMotionIntrinsics(bool *ok) const {
if (motion_intrinsics_) {
*ok = true;
return *motion_intrinsics_;
} else {
LOG(WARNING) << "Motion intrinsics not found";
*ok = false;
VLOG(2) << "Motion intrinsics not found";
return {};
}
}
Extrinsics Device::GetMotionExtrinsics(const Stream &from) const {
Extrinsics Device::GetMotionExtrinsics(const Stream &from, bool *ok) const {
try {
*ok = true;
return motion_from_extrinsics_.at(from);
} catch (const std::out_of_range &e) {
LOG(WARNING) << "Motion extrinsics from " << from << " not found";
*ok = false;
VLOG(2) << "Motion extrinsics from " << from << " not found";
return {};
}
}
@@ -275,8 +327,7 @@ bool Device::RunOptionAction(const Option &option) const {
void Device::SetStreamCallback(
const Stream &stream, stream_callback_t callback, bool async) {
if (!Supports(stream)) {
LOG(WARNING) << "Unsupported stream: " << stream;
if (!CheckSupports(this, stream, false)) {
return;
}
if (callback) {
@@ -284,7 +335,7 @@ void Device::SetStreamCallback(
if (async)
stream_async_callbacks_[stream] =
std::make_shared<stream_async_callback_t>(
to_string(stream), callback);
to_string(stream), callback); // max_data_size = 1
} else {
stream_callbacks_.erase(stream);
stream_async_callbacks_.erase(stream);
@@ -296,7 +347,8 @@ void Device::SetMotionCallback(motion_callback_t callback, bool async) {
if (callback) {
if (async)
motion_async_callback_ =
std::make_shared<motion_async_callback_t>("motion", callback, true);
std::make_shared<motion_async_callback_t>("motion", callback, 1000);
// will drop old motion datas after callback cost > 2 s (1000 / 500 Hz)
} else {
motion_async_callback_ = nullptr;
}
@@ -351,6 +403,7 @@ void Device::WaitForStreams() {
std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
CHECK(video_streaming_);
CHECK_NOTNULL(streams_);
CheckSupports(this, stream);
std::lock_guard<std::mutex> _(mtx_streams_);
return streams_->GetStreamDatas(stream);
}
@@ -358,6 +411,7 @@ std::vector<device::StreamData> Device::GetStreamDatas(const Stream &stream) {
device::StreamData Device::GetLatestStreamData(const Stream &stream) {
CHECK(video_streaming_);
CHECK_NOTNULL(streams_);
CheckSupports(this, stream);
std::lock_guard<std::mutex> _(mtx_streams_);
return streams_->GetLatestStreamData(stream);
}
@@ -488,8 +542,13 @@ void Device::ReadAllInfos() {
Channels::img_params_t img_params;
Channels::imu_params_t imu_params;
if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) {
LOG(FATAL) << "Read device infos failed. Please upgrade your firmware to "
"the latest version.";
#if defined(WITH_DEVICE_INFO_REQUIRED)
LOG(FATAL)
#else
LOG(WARNING)
#endif
<< "Read device infos failed. Please upgrade your firmware to the "
"latest version.";
}
VLOG(2) << "Device info: {name: " << device_info_->name
<< ", serial_number: " << device_info_->serial_number
@@ -506,11 +565,11 @@ void Device::ReadAllInfos() {
if (img_params.ok) {
SetIntrinsics(Stream::LEFT, img_params.in_left);
SetIntrinsics(Stream::RIGHT, img_params.in_right);
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_left_to_right);
SetExtrinsics(Stream::RIGHT, Stream::LEFT, img_params.ex_right_to_left);
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
VLOG(2) << "Extrinsics left to right: {"
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
VLOG(2) << "Extrinsics right to left: {"
<< GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
} else {
LOG(WARNING) << "Intrinsics & extrinsics not exist";
}
@@ -521,7 +580,7 @@ void Device::ReadAllInfos() {
VLOG(2) << "Motion extrinsics left to imu: {"
<< GetMotionExtrinsics(Stream::LEFT) << "}";
} else {
LOG(WARNING) << "Motion intrinsics & extrinsics not exist";
VLOG(2) << "Motion intrinsics & extrinsics not exist";
}
}

View File

@@ -140,6 +140,24 @@ class MYNTEYE_API Device {
*/
Extrinsics GetMotionExtrinsics(const Stream &from) const;
/**
* Get the intrinsics of stream.
*/
Intrinsics GetIntrinsics(const Stream &stream, bool *ok) const;
/**
* Get the extrinsics from one stream to another.
*/
Extrinsics GetExtrinsics(
const Stream &from, const Stream &to, bool *ok) const;
/**
* Get the intrinsics of motion.
*/
MotionIntrinsics GetMotionIntrinsics(bool *ok) const;
/**
* Get the extrinsics from one stream to motion.
*/
Extrinsics GetMotionExtrinsics(const Stream &from, bool *ok) const;
/**
* Set the intrinsics of stream.
*/

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#include "device/device_s.h"
#include <glog/logging.h>
#include "mynteye/logger.h"
#include "internal/motions.h"

View File

@@ -31,7 +31,8 @@ class AsyncCallback {
public:
using callback_t = std::function<void(Data data)>;
AsyncCallback(std::string name, callback_t callback, bool concat = false);
AsyncCallback(
std::string name, callback_t callback, std::size_t max_data_size = 0);
~AsyncCallback();
void PushData(Data data);
@@ -50,8 +51,8 @@ class AsyncCallback {
std::thread thread_;
std::uint32_t count_;
bool concat_;
std::vector<Data> datas_;
std::size_t max_data_size_;
};
MYNTEYE_END_NAMESPACE

View File

@@ -15,20 +15,20 @@
#define MYNTEYE_INTERNAL_ASYNC_CALLBACK_IMPL_H_
#pragma once
#include <glog/logging.h>
#include <string>
#include <utility>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
template <class Data>
AsyncCallback<Data>::AsyncCallback(
std::string name, callback_t callback, bool concat)
std::string name, callback_t callback, std::size_t max_data_size)
: name_(std::move(name)),
callback_(std::move(callback)),
count_(0),
concat_(concat) {
max_data_size_(max_data_size) {
VLOG(2) << __func__;
running_ = true;
thread_ = std::thread(&AsyncCallback<Data>::Run, this);
@@ -51,8 +51,10 @@ AsyncCallback<Data>::~AsyncCallback() {
template <class Data>
void AsyncCallback<Data>::PushData(Data data) {
std::lock_guard<std::mutex> _(mtx_);
if (!concat_) {
if (max_data_size_ <= 0) {
datas_.clear();
} else if (max_data_size_ == datas_.size()) { // >= 1
datas_.erase(datas_.begin());
}
datas_.push_back(data);
++count_;

View File

@@ -13,8 +13,6 @@
// limitations under the License.
#include "internal/channels.h"
#include <glog/logging.h>
#include <bitset>
#include <chrono>
#include <iomanip>
@@ -22,6 +20,8 @@
#include <sstream>
#include <stdexcept>
#include "mynteye/logger.h"
#include "internal/strings.h"
#include "internal/times.h"
@@ -453,7 +453,7 @@ std::size_t from_data(
}
i += 40;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -484,7 +484,7 @@ std::size_t from_data(
}
i += 24;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -505,7 +505,7 @@ std::size_t from_data(
}
i += 24;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -515,7 +515,7 @@ std::size_t from_data(
std::size_t i = 0;
i += from_data(&img_params->in_left, data + i, spec_version);
i += from_data(&img_params->in_right, data + i, spec_version);
i += from_data(&img_params->ex_left_to_right, data + i, spec_version);
i += from_data(&img_params->ex_right_to_left, data + i, spec_version);
return i;
}
@@ -684,7 +684,7 @@ std::size_t to_data(
_to_data(info->nominal_baseline, data + i);
i += 2;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
// others
std::size_t size = i - 3;
@@ -725,7 +725,7 @@ std::size_t to_data(
}
i += 40;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -756,7 +756,7 @@ std::size_t to_data(
}
i += 24;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -777,7 +777,7 @@ std::size_t to_data(
}
i += 24;
UNUSED(spec_version)
MYNTEYE_UNUSED(spec_version)
return i;
}
@@ -787,7 +787,7 @@ std::size_t to_data(
std::size_t i = 3; // skip id, size
i += to_data(&img_params->in_left, data + i, spec_version);
i += to_data(&img_params->in_right, data + i, spec_version);
i += to_data(&img_params->ex_left_to_right, data + i, spec_version);
i += to_data(&img_params->ex_right_to_left, data + i, spec_version);
// others
std::size_t size = i - 3;
data[0] = Channels::FID_IMG_PARAMS;

View File

@@ -72,7 +72,7 @@ class MYNTEYE_API Channels {
bool ok;
Intrinsics in_left;
Intrinsics in_right;
Extrinsics ex_left_to_right;
Extrinsics ex_right_to_left;
} img_params_t;
typedef struct ImuParams {

View File

@@ -13,11 +13,12 @@
// limitations under the License.
#include "internal/dl.h"
#include <glog/logging.h>
#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();

View File

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

View File

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

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#include "internal/motions.h"
#include <glog/logging.h>
#include "mynteye/logger.h"
#include "internal/channels.h"

View File

@@ -13,13 +13,13 @@
// limitations under the License.
#include "internal/streams.h"
#include <glog/logging.h>
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <stdexcept>
#include "mynteye/logger.h"
#include "internal/types.h"
MYNTEYE_BEGIN_NAMESPACE
@@ -50,9 +50,9 @@ bool unpack_stereo_img_data(
// << ", checksum=0x" << std::hex << static_cast<int>(img_packet.checksum);
if (img_packet.header != 0x3B) {
LOG(WARNING) << "Image packet header must be 0x3B, but 0x" << std::hex
<< std::uppercase << std::setw(2) << std::setfill('0')
<< static_cast<int>(img_packet.header) << " now";
VLOG(2) << "Image packet header must be 0x3B, but 0x" << std::hex
<< std::uppercase << std::setw(2) << std::setfill('0')
<< static_cast<int>(img_packet.header) << " now";
return false;
}
@@ -61,11 +61,11 @@ bool unpack_stereo_img_data(
checksum = (checksum ^ packet[i]);
}
if (img_packet.checksum != checksum) {
LOG(WARNING) << "Image packet checksum should be 0x" << std::hex
<< std::uppercase << std::setw(2) << std::setfill('0')
<< static_cast<int>(img_packet.checksum) << ", but 0x"
<< std::setw(2) << std::setfill('0')
<< static_cast<int>(checksum) << " now";
VLOG(2) << "Image packet checksum should be 0x" << std::hex
<< std::uppercase << std::setw(2) << std::setfill('0')
<< static_cast<int>(img_packet.checksum) << ", but 0x"
<< std::setw(2) << std::setfill('0') << static_cast<int>(checksum)
<< " now";
return false;
}
@@ -160,7 +160,7 @@ bool Streams::PushStream(const Capabilities &capability, const void *data) {
} else {
// discard left
DiscardStreamData(Stream::LEFT);
LOG(WARNING) << "Image packet is unaccepted, frame dropped";
VLOG(2) << "Image packet is unaccepted, frame dropped";
pushed = false;
}
} break;

View File

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

View File

@@ -13,11 +13,11 @@
// limitations under the License.
#include "internal/types.h"
#include <glog/logging.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE

41
src/public/miniglog.cc Normal file
View File

@@ -0,0 +1,41 @@
// Ceres Solver - A fast non-linear least squares minimizer
// Copyright 2012 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: keir@google.com (Keir Mierle)
#include "mynteye/miniglog.h"
namespace google {
// This is the set of log sinks. This must be in a separate library to ensure
// that there is only one instance of this across the entire program.
std::set<google::LogSink *> log_sinks_global;
int log_severity_global(INFO);
} // namespace google

View File

@@ -0,0 +1,3 @@
miniglog:
* https://github.com/arpg/miniglog
* https://github.com/tzutalin/miniglog

View File

@@ -13,11 +13,11 @@
// limitations under the License.
#include "mynteye/types.h"
#include <glog/logging.h>
#include <iomanip>
#include <limits>
#include "mynteye/logger.h"
#define FULL_PRECISION \
std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10)

View File

@@ -13,7 +13,7 @@
// limitations under the License.
#include "mynteye/utils.h"
#include <glog/logging.h>
#include "mynteye/logger.h"
#include "device/context.h"
#include "device/device.h"
@@ -36,8 +36,9 @@ std::shared_ptr<Device> select() {
LOG(INFO) << "MYNT EYE devices:";
for (size_t i = 0; i < n; i++) {
auto &&device = devices[i];
auto &&name = device->GetInfo(Info::DEVICE_NAME);
LOG(INFO) << " index: " << i << ", name: " << name;
LOG(INFO) << " index: " << i
<< ", name: " << device->GetInfo(Info::DEVICE_NAME)
<< ", sn: " << device->GetInfo(Info::SERIAL_NUMBER);
}
std::shared_ptr<Device> device = nullptr;

View File

@@ -13,9 +13,10 @@
// limitations under the License.
#include "uvc/uvc.h" // NOLINT
#include <glog/logging.h>
#include <libuvc/libuvc.h>
#include "mynteye/logger.h"
// #define ENABLE_DEBUG_SPAM
MYNTEYE_BEGIN_NAMESPACE
@@ -112,13 +113,13 @@ int get_product_id(const device &device) {
std::string get_name(const device &device) {
// TODO(JohnZhao)
UNUSED(device)
MYNTEYE_UNUSED(device)
return "";
}
std::string get_video_name(const device &device) {
// TODO(JohnZhao)
UNUSED(device)
MYNTEYE_UNUSED(device)
return "";
}
@@ -126,21 +127,21 @@ bool pu_control_range(
const device &device, Option option, int32_t *min, int32_t *max,
int32_t *def) {
// TODO(JohnZhao)
UNUSED(device)
UNUSED(option)
UNUSED(min)
UNUSED(max)
UNUSED(def)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(option)
MYNTEYE_UNUSED(min)
MYNTEYE_UNUSED(max)
MYNTEYE_UNUSED(def)
return false;
}
bool pu_control_query(
const device &device, Option option, pu_query query, int32_t *value) {
// TODO(JohnZhao)
UNUSED(device)
UNUSED(option)
UNUSED(query)
UNUSED(value)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(option)
MYNTEYE_UNUSED(query)
MYNTEYE_UNUSED(value)
return false;
}
@@ -148,13 +149,13 @@ bool xu_control_range(
const device &device, const xu &xu, uint8_t selector, uint8_t id, int32_t *min,
int32_t *max, int32_t *def) {
// TODO(JohnZhao)
UNUSED(device)
UNUSED(xu)
UNUSED(selector)
UNUSED(id)
UNUSED(min)
UNUSED(max)
UNUSED(def)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(xu)
MYNTEYE_UNUSED(selector)
MYNTEYE_UNUSED(id)
MYNTEYE_UNUSED(min)
MYNTEYE_UNUSED(max)
MYNTEYE_UNUSED(def)
return false;
}
@@ -162,12 +163,12 @@ bool xu_control_query(
const device &device, const xu &xu, uint8_t selector, xu_query query,
uint16_t size, uint8_t *data) {
// TODO(JohnZhao)
UNUSED(device)
UNUSED(xu)
UNUSED(selector)
UNUSED(query)
UNUSED(size)
UNUSED(data)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(xu)
MYNTEYE_UNUSED(selector)
MYNTEYE_UNUSED(query)
MYNTEYE_UNUSED(size)
MYNTEYE_UNUSED(data)
return false;
}
@@ -175,23 +176,23 @@ void set_device_mode(
device &device, int width, int height, int fourcc, int fps, // NOLINT
video_channel_callback callback) {
// TODO(JohnZhao)
UNUSED(device)
UNUSED(width)
UNUSED(height)
UNUSED(fourcc)
UNUSED(fps)
UNUSED(callback)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(width)
MYNTEYE_UNUSED(height)
MYNTEYE_UNUSED(fourcc)
MYNTEYE_UNUSED(fps)
MYNTEYE_UNUSED(callback)
}
void start_streaming(device &device, int num_transfer_bufs) { // NOLINT
// TODO(JohnZhao)
UNUSED(device)
UNUSED(num_transfer_bufs)
MYNTEYE_UNUSED(device)
MYNTEYE_UNUSED(num_transfer_bufs)
}
void stop_streaming(device &device) { // NOLINT
// TODO(JohnZhao)
UNUSED(device)
MYNTEYE_UNUSED(device)
}
} // namespace uvc

View File

@@ -16,6 +16,9 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -25,13 +28,14 @@
#include <linux/uvcvideo.h>
#include <linux/videodev2.h>
#include <glog/logging.h>
#include <chrono>
#include <fstream>
#include <sstream>
#include <string>
#include <thread>
#include "mynteye/logger.h"
MYNTEYE_BEGIN_NAMESPACE
namespace uvc {
@@ -41,6 +45,10 @@ namespace uvc {
LOG(severity) << str << " error " << errno << ", " << strerror(errno); \
} while (0)
#define NO_DATA_MAX_COUNT 200
int no_data_count = 0;
/*
class device_error : public std::exception {
public:
@@ -194,6 +202,7 @@ struct device {
~device() {
VLOG(2) << __func__;
stop_streaming();
no_data_count = 0;
if (fd != -1 && close(fd) < 0) {
LOG_ERROR(WARNING, "close");
}
@@ -386,6 +395,14 @@ struct device {
throw_error("VIDIOC_QBUF");
});
}
no_data_count = 0;
} else {
no_data_count++;
}
if (no_data_count > NO_DATA_MAX_COUNT) {
throw_error("v4l2 get stream time out!");
}
}

Some files were not shown because too many files have changed in this diff Show More