Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
721ad22b0a | ||
|
|
4d644a1d71 | ||
|
|
1f96a6ee29 | ||
|
|
204fff2175 | ||
|
|
12f5a8f3cc | ||
|
|
6435bf04a2 | ||
|
|
2ae3116f0d | ||
|
|
a26dbec7b1 | ||
|
|
0bcd3c02b9 | ||
|
|
c6f195360f | ||
|
|
1b95e376a5 | ||
|
|
cf9e714626 | ||
|
|
5f233a35c0 | ||
|
|
36e90e3793 | ||
|
|
ca605d6114 | ||
|
|
89c798daa8 | ||
|
|
2784937ad1 | ||
|
|
d96797c835 | ||
|
|
94ecacef6c | ||
|
|
02856194a0 | ||
|
|
4d5ff16f82 | ||
|
|
30a9397602 | ||
|
|
55165b8878 | ||
|
|
12adc79096 | ||
|
|
4addab5cc0 | ||
|
|
92585a3b8d | ||
|
|
54f01eec1a | ||
|
|
d80d506360 | ||
|
|
692cbac8d8 | ||
|
|
d4343b574a | ||
|
|
1f003f505b | ||
|
|
a96246cc20 | ||
|
|
5f24d0857e |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -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
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(mynteye VERSION 2.0.1 LANGUAGES C CXX)
|
||||
project(mynteye VERSION 2.2.1 LANGUAGES C CXX)
|
||||
|
||||
include(cmake/Common.cmake)
|
||||
|
||||
@@ -44,9 +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)
|
||||
|
||||
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)
|
||||
|
||||
@@ -90,19 +97,28 @@ set(MYNTEYE_CMAKE_INSTALLDIR "${MYNTEYE_CMAKE_LIBDIR}/cmake/${MYNTEYE_NAME}")
|
||||
|
||||
## main
|
||||
|
||||
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
|
||||
@@ -119,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)
|
||||
@@ -163,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}
|
||||
|
||||
2
CPPLINT.cfg
Normal file
2
CPPLINT.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
set noparent
|
||||
filter=-build/c++11
|
||||
27
Makefile
27
Makefile
@@ -31,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"
|
||||
@@ -41,7 +41,7 @@ help:
|
||||
|
||||
.PHONY: help
|
||||
|
||||
all: test tools samples
|
||||
all: test samples tools
|
||||
|
||||
.PHONY: all
|
||||
|
||||
@@ -49,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
|
||||
@@ -70,12 +71,7 @@ cleandoc:
|
||||
submodules:
|
||||
@git submodule update --init
|
||||
|
||||
third_party: submodules
|
||||
@$(call echo,Make $@)
|
||||
@$(call echo,Make glog,33)
|
||||
@$(call cmake_build,./third_party/glog/_build)
|
||||
|
||||
.PHONY: submodules third_party
|
||||
.PHONY: submodules
|
||||
|
||||
# init
|
||||
|
||||
@@ -87,10 +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,..)
|
||||
@# @$(call cmake_build,./_build,..,-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/_install)
|
||||
endif
|
||||
|
||||
.PHONY: build
|
||||
|
||||
@@ -122,10 +121,14 @@ ifeq ($(HOST_OS),Win)
|
||||
ifneq ($(HOST_NAME),MinGW)
|
||||
@cd ./_build; msbuild.exe INSTALL.vcxproj /property:Configuration=Release
|
||||
else
|
||||
@cd ./_build; sudo make install
|
||||
@cd ./_build; make install
|
||||
endif
|
||||
else
|
||||
ifeq ($(HOST_OS),Linux)
|
||||
@cd ./_build; sudo make install
|
||||
else
|
||||
@cd ./_build; make install
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: install
|
||||
|
||||
10
README.md
10
README.md
@@ -1,6 +1,6 @@
|
||||
# MYNT® EYE SDK
|
||||
|
||||
[](https://github.com/slightech/MYNT-EYE-SDK-2)
|
||||
[](https://github.com/slightech/MYNT-EYE-SDK-2)
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -17,11 +17,11 @@ 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://github.com/slightech/MYNT-EYE-SDK-2/files/2203869/mynt-eye-sdk-apidoc-2.0.1-rc0-en.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203870/mynt-eye-sdk-apidoc-2.0.1-rc0-html-en.zip) [](https://slightech.github.io/MYNT-EYE-SDK-2/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203872/mynt-eye-sdk-apidoc-2.0.1-rc0-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2203874/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans.zip) [](http://doc.myntai.com/resource/api/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans/mynt-eye-sdk-apidoc-2.0.1-rc0-html-zh-Hans/index.html)
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422149/mynt-eye-sdk-apidoc-2.0.1-rc2-en.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422151/mynt-eye-sdk-apidoc-2.0.1-rc2-html-en.zip) [](https://slightech.github.io/MYNT-EYE-SDK-2/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422152/mynt-eye-sdk-apidoc-2.0.1-rc2-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2/files/2422153/mynt-eye-sdk-apidoc-2.0.1-rc2-html-zh-Hans.zip) [](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://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203877/mynt-eye-sdk-guide-2.0.1-rc0-en.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203879/mynt-eye-sdk-guide-2.0.1-rc0-html-en.zip) [](https://slightech.github.io/MYNT-EYE-SDK-2-Guide/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203880/mynt-eye-sdk-guide-2.0.1-rc0-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2203881/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans.zip) [](http://doc.myntai.com/resource/sdk/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans/mynt-eye-sdk-guide-2.0.1-rc0-html-zh-Hans/index.html )
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422160/mynt-eye-sdk-guide-2.0.1-rc2-en.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422161/mynt-eye-sdk-guide-2.0.1-rc2-html-en.zip) [](https://slightech.github.io/MYNT-EYE-SDK-2-Guide/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422162/mynt-eye-sdk-guide-2.0.1-rc2-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-SDK-2-Guide/files/2422164/mynt-eye-sdk-guide-2.0.1-rc2-html-zh-Hans.zip) [](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: `en`, `zh-Hans`.
|
||||
|
||||
|
||||
26
cmake/DetectGLog.cmake
Normal file
26
cmake/DetectGLog.cmake
Normal 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)
|
||||
@@ -28,6 +28,10 @@ option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON)
|
||||
|
||||
option(WITH_BOOST "Include Boost support" ON)
|
||||
|
||||
# How to install glog?
|
||||
# Ubuntu: `sudo apt-get install libgoogle-glog-dev`
|
||||
option(WITH_GLOG "Include glog support" OFF)
|
||||
|
||||
|
||||
# packages
|
||||
|
||||
@@ -59,6 +63,10 @@ if(NOT WITH_FILESYSTEM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_GLOG)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
find_package(CUDA QUIET)
|
||||
|
||||
# summary
|
||||
@@ -125,6 +133,16 @@ if(WITH_BOOST)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
status(" WITH_GLOG: ${WITH_GLOG}")
|
||||
if(WITH_GLOG)
|
||||
if(glog_FOUND)
|
||||
status(" glog: YES")
|
||||
status(" glog_VERSION: ${glog_VERSION}")
|
||||
else()
|
||||
status(" glog: NO")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
status("")
|
||||
status("Features:")
|
||||
status(" Filesystem: "
|
||||
|
||||
18
doc/build.sh
18
doc/build.sh
@@ -52,16 +52,30 @@ for lang in "${LANGS[@]}"; do
|
||||
_mkdir "$OUTPUT/$lang"
|
||||
_echo_i "doxygen $DOXYFILE"
|
||||
doxygen $DOXYFILE
|
||||
if [ $pdflatex_FOUND ] && [ -f "$OUTPUT/$lang/latex/Makefile" ]; then
|
||||
_echo_in "doxygen make latex"
|
||||
|
||||
version=`cat $DOXYFILE | grep -m1 "^PROJECT_NUMBER\s*=" | \
|
||||
sed -E "s/^.*=[[:space:]]*(.*)[[:space:]]*$/\1/g"`
|
||||
|
||||
# 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" "../$filename"
|
||||
fi
|
||||
|
||||
_echo_d "doxygen completed"
|
||||
else
|
||||
_echo_e "$DOXYFILE not found"
|
||||
|
||||
@@ -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.1-rc1
|
||||
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
|
||||
@@ -801,7 +801,7 @@ INPUT = mainpage.md \
|
||||
specs_ctrl.md \
|
||||
spec_control_api.md \
|
||||
spec_control_channel.md \
|
||||
../../_install/include
|
||||
/usr/local/include/mynteye
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@@ -884,7 +884,8 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE = /usr/local/include/mynteye/logger.h \
|
||||
/usr/local/include/mynteye/miniglog.h
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
||||
@@ -14,7 +14,7 @@ There are two control modes, one is through UVC standard protocol, the other is
|
||||
|
||||
| Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Channel | Note |
|
||||
| :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :------ | :----- |
|
||||
| Frame rate | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | values: {10,15,20,25,30,35,40,45,50,55} |
|
||||
| Frame rate | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | values: {10,15,20,25,30,35,40,45,50,55,60} |
|
||||
| IMU frequency | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | values: {100,200,250,333,500} |
|
||||
| Exposure mode | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0: enable auto-exposure; 1: manual-exposure |
|
||||
| Max gain | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | valid if auto-exposure |
|
||||
|
||||
@@ -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.1-rc1
|
||||
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
|
||||
@@ -801,7 +801,7 @@ INPUT = mainpage.md \
|
||||
specs_ctrl.md \
|
||||
spec_control_api.md \
|
||||
spec_control_channel.md \
|
||||
../../_install/include
|
||||
/usr/local/include/mynteye
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
@@ -884,7 +884,8 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
EXCLUDE =
|
||||
EXCLUDE = /usr/local/include/mynteye/logger.h \
|
||||
/usr/local/include/mynteye/miniglog.h
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
|
||||
@@ -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;` ,重新编译。
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----- |
|
||||
| 图像帧率 | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55} |
|
||||
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55,60} |
|
||||
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 有效值为{100,200,250,333,500} |
|
||||
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0:开启自动曝光; 1:关闭 |
|
||||
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
|
||||
@@ -16,72 +16,70 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#define OS_WIN
|
||||
#define MYNTEYE_OS_WIN
|
||||
#ifdef _WIN64
|
||||
#define OS_WIN64
|
||||
#define MYNTEYE_OS_WIN64
|
||||
#else
|
||||
#define OS_WIN32
|
||||
#define MYNTEYE_OS_WIN32
|
||||
#endif
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#define OS_MINGW
|
||||
#define MYNTEYE_OS_MINGW
|
||||
#ifdef __MINGW64__
|
||||
#define OS_MINGW64
|
||||
#define MYNTEYE_OS_MINGW64
|
||||
#else
|
||||
#define OS_MINGW32
|
||||
#define MYNTEYE_OS_MINGW32
|
||||
#endif
|
||||
#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
|
||||
#define OS_CYGWIN
|
||||
#define MYNTEYE_OS_CYGWIN
|
||||
#endif
|
||||
#elif __APPLE__
|
||||
#include "TargetConditionals.h"
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
#define OS_IPHONE
|
||||
#define OS_IPHONE_SIMULATOR
|
||||
#define MYNTEYE_OS_IPHONE
|
||||
#define MYNTEYE_OS_IPHONE_SIMULATOR
|
||||
#elif TARGET_OS_IPHONE
|
||||
#define OS_IPHONE
|
||||
#define MYNTEYE_OS_IPHONE
|
||||
#elif TARGET_OS_MAC
|
||||
#define 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"
|
||||
#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_
|
||||
|
||||
@@ -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. */
|
||||
@@ -43,7 +45,7 @@ struct glog_init {
|
||||
FLAGS_log_dir = ".";
|
||||
|
||||
// Sets the maximum log file size (in MB).
|
||||
FLAGS_max_log_size = 1024;
|
||||
FLAGS_max_log_size = 8;
|
||||
|
||||
// Sets whether to avoid logging to the disk if the disk is full.
|
||||
FLAGS_stop_logging_if_full_disk = true;
|
||||
@@ -62,4 +64,20 @@ struct glog_init {
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MYNTEYE_GLOG_INIT_H_ NOLINT
|
||||
#else
|
||||
|
||||
struct glog_init {
|
||||
glog_init(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
// Do nothing.
|
||||
}
|
||||
};
|
||||
|
||||
#define MYNTEYE_MAX_LOG_LEVEL google::INFO
|
||||
|
||||
#include "mynteye/miniglog.h"
|
||||
|
||||
#endif
|
||||
|
||||
#endif // MYNTEYE_LOGGER_H_
|
||||
469
include/mynteye/miniglog.h
Normal file
469
include/mynteye/miniglog.h
Normal 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_
|
||||
@@ -21,9 +21,9 @@
|
||||
# define MYNTEYE_API
|
||||
#else
|
||||
# ifdef MYNTEYE_EXPORTS
|
||||
# define MYNTEYE_API DECL_EXPORT
|
||||
# define MYNTEYE_API MYNTEYE_DECL_EXPORT
|
||||
# else
|
||||
# define MYNTEYE_API DECL_IMPORT
|
||||
# define MYNTEYE_API MYNTEYE_DECL_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -61,4 +61,11 @@ MYNTEYE_API_VERSION_CHECK( \
|
||||
const char MYNTEYE_SDK_ROOT_DIR[] = "@MYNTEYE_SDK_ROOT_DIR@";
|
||||
const char MYNTEYE_SDK_INSTALL_DIR[] = "@MYNTEYE_SDK_INSTALL_DIR@";
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
template <typename... T>
|
||||
void UNUSED(T &&...) {}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_MYNTEYE_H_
|
||||
|
||||
@@ -144,7 +144,7 @@ enum class Option : std::uint8_t {
|
||||
/**
|
||||
* Image frame rate, must set IMU_FREQUENCY together
|
||||
*
|
||||
* values: {10,15,20,25,30,35,40,45,50,55}, default: 25
|
||||
* values: {10,15,20,25,30,35,40,45,50,55,60}, default: 25
|
||||
*/
|
||||
FRAME_RATE,
|
||||
/**
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
namespace {
|
||||
@@ -31,7 +29,7 @@ class DepthRegion {
|
||||
* 鼠标事件:默认不选中区域,随鼠标移动而显示。单击后,则会选中区域来显示。你可以再单击已选中区域或双击未选中区域,取消选中。
|
||||
*/
|
||||
void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
|
||||
UNUSED(flags)
|
||||
MYNTEYE_UNUSED(flags)
|
||||
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
|
||||
return;
|
||||
}
|
||||
@@ -163,7 +161,7 @@ int main(int argc, char *argv[]) {
|
||||
DepthRegion depth_region(3);
|
||||
auto depth_info = [](
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
|
||||
UNUSED(depth)
|
||||
MYNTEYE_UNUSED(depth)
|
||||
std::ostringstream os;
|
||||
os << "depth pos: [" << point.y << ", " << point.x << "]"
|
||||
<< "±" << n << ", unit: mm";
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -30,7 +29,7 @@ int main(int argc, char *argv[]) {
|
||||
// Attention: must set FRAME_RATE and IMU_FREQUENCY together, otherwise won't
|
||||
// succeed.
|
||||
|
||||
// FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55
|
||||
// FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
|
||||
api->SetOptionValue(Option::FRAME_RATE, 25);
|
||||
// IMU_FREQUENCY values: 100, 200, 250, 333, 500
|
||||
api->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
#include "mynteye/context.h"
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
@@ -34,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;
|
||||
}
|
||||
@@ -166,7 +164,7 @@ int main(int argc, char *argv[]) {
|
||||
DepthRegion depth_region(3);
|
||||
auto depth_info = [](
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
|
||||
UNUSED(depth)
|
||||
MYNTEYE_UNUSED(depth)
|
||||
std::ostringstream os;
|
||||
os << "depth pos: [" << point.y << ", " << point.x << "]"
|
||||
<< "±" << n << ", unit: mm";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
// --------------------------------------------
|
||||
|
||||
@@ -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();
|
||||
|
||||
162
scripts/init.sh
162
scripts/init.sh
@@ -14,181 +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
|
||||
if ! _detect_cmd $PYTHON; then
|
||||
PYTHON="python2" # try python2 on MSYS
|
||||
fi
|
||||
fi
|
||||
|
||||
_detect $PYTHON 1
|
||||
|
||||
PYTHON_FOUND="${PYTHON}_FOUND"
|
||||
if [ -z "${!PYTHON_FOUND}" ]; then
|
||||
_echo_en "$PYTHON not found"
|
||||
fi
|
||||
|
||||
if [ "$HOST_OS" = "Linux" ]; then
|
||||
_detect_install() {
|
||||
_detect_cmd "$1" || [ $(dpkg-query -W -f='${Status}' "$1" 2> /dev/null \
|
||||
| grep -c "ok installed") -gt 0 ]
|
||||
}
|
||||
elif [ "$HOST_OS" = "Mac" ]; then
|
||||
_detect_install() {
|
||||
_detect_cmd "$1" || brew ls --versions "$1" > /dev/null
|
||||
}
|
||||
else
|
||||
_detect_install() {
|
||||
_detect_cmd "$1"
|
||||
}
|
||||
fi
|
||||
|
||||
_install_deps() {
|
||||
_cmd="$1"; shift; _deps_all=($@)
|
||||
_echo "Install cmd: $_cmd"
|
||||
_echo "Install deps: ${_deps_all[*]}"
|
||||
if [ -n "${_FORCE_INSRALL_}" ]; then
|
||||
_echo_d "$_cmd ${_deps_all[*]}"
|
||||
$_cmd ${_deps_all[@]}
|
||||
return
|
||||
fi
|
||||
_deps=()
|
||||
for _dep in "${_deps_all[@]}"; do
|
||||
_detect_install $_dep || _deps+=($_dep)
|
||||
done
|
||||
if [ ${#_deps[@]} -eq 0 ]; then
|
||||
_echo_i "All deps already exist"
|
||||
else
|
||||
_echo_d "$_cmd ${_deps[*]} (not exists)"
|
||||
$_cmd ${_deps[@]}
|
||||
fi
|
||||
}
|
||||
source "$BASE_DIR/init_tools.sh"
|
||||
|
||||
## deps
|
||||
|
||||
_echo_s "Init deps"
|
||||
|
||||
if [ "$HOST_OS" = "Linux" ]; then
|
||||
# detect apt-get
|
||||
_detect apt-get
|
||||
# apt-get install
|
||||
_install_deps "sudo apt-get install" build-essential curl cmake git clang-format
|
||||
_install_deps "sudo apt-get install" libv4l-dev
|
||||
if ! _detect_cmd clang-format; then
|
||||
# on Ubuntu 14.04, apt-cache search clang-format
|
||||
_install_deps "sudo apt-get install" clang-format-3.9
|
||||
sudo ln -sf clang-format-3.9 /usr/bin/clang-format
|
||||
sudo ln -sf clang-format-diff-3.9 /usr/bin/clang-format-diff
|
||||
fi
|
||||
# sudo
|
||||
SUDO="sudo"
|
||||
_install_deps "$SUDO apt-get install" libv4l-dev
|
||||
elif [ "$HOST_OS" = "Mac" ]; then
|
||||
# detect brew
|
||||
if ! _detect_cmd brew; then
|
||||
_echo_sn "Install brew"
|
||||
_detect curl
|
||||
_detect ruby
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
fi
|
||||
# brew install
|
||||
_install_deps "brew install" curl cmake git clang-format
|
||||
# link clang-format-diff (if not compatible with Python 3, fix it by yourself)
|
||||
[ -f "/usr/local/bin/clang-format-diff" ] || \
|
||||
ln -s /usr/local/share/clang/clang-format-diff.py /usr/local/bin/clang-format-diff
|
||||
_install_deps "brew install" libuvc
|
||||
elif [ "$HOST_OS" = "Win" ]; then
|
||||
# detect pacman on MSYS
|
||||
_detect pacman
|
||||
# pacman install (common)
|
||||
_install_deps "pacman -S" curl git clang-format
|
||||
if [ "$HOST_NAME" = "MINGW" ]; then
|
||||
# pacman install (MINGW)
|
||||
_deps=()
|
||||
if [ "$HOST_ARCH" = "x64" ]; then
|
||||
_deps+=(mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake)
|
||||
elif [ "$HOST_ARCH" = "x86" ]; then
|
||||
_deps+=(mingw-w64-i686-toolchain mingw-w64-i686-cmake)
|
||||
else
|
||||
_echo_e "Unknown host arch :("
|
||||
exit 1
|
||||
fi
|
||||
if ! [ ${#_deps[@]} -eq 0 ]; then
|
||||
_echo_d "pacman -S ${_deps[*]}"
|
||||
pacman -S ${_deps[@]}
|
||||
fi
|
||||
else
|
||||
# detect cmake on MSYS
|
||||
_detect cmake
|
||||
fi
|
||||
# update
|
||||
# pacman -Syu
|
||||
# search
|
||||
# pacman -Ss make
|
||||
# autoremove
|
||||
# pacman -Qtdq | pacman -Rs -
|
||||
# _install_deps "pacman -S" ?
|
||||
_echo
|
||||
else # unexpected
|
||||
_echo_e "Unknown host os :("
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## pip
|
||||
|
||||
# detect pip
|
||||
if ! _detect_cmd pip; then
|
||||
if [ -n "${!PYTHON_FOUND}" ]; then
|
||||
_echo_sn "Install pip"
|
||||
[ -f "get-pip.py" ] || curl -O https://bootstrap.pypa.io/get-pip.py
|
||||
$SUDO $PYTHON get-pip.py
|
||||
else
|
||||
_echo_en "Skipped install pip, as $PYTHON not found"
|
||||
fi
|
||||
fi
|
||||
# pip install
|
||||
if _detect_cmd pip; then
|
||||
_echo_d "pip install --upgrade autopep8 cpplint pylint requests"
|
||||
$SUDO pip install --upgrade autopep8 cpplint pylint requests
|
||||
else
|
||||
_echo_en "Skipped pip install packages, as pip not found"
|
||||
fi
|
||||
|
||||
## realpath
|
||||
|
||||
# detect realpath
|
||||
if ! _detect_cmd realpath; then
|
||||
_echo_sn "Install realpath"
|
||||
if [ "$HOST_OS" = "Linux" ]; then
|
||||
# How to install realpath on Ubuntu 14.04
|
||||
# https://www.howtoinstall.co/en/ubuntu/trusty/realpath
|
||||
sudo apt-get install coreutils realpath
|
||||
elif [ "$HOST_OS" = "Mac" ]; then
|
||||
brew install coreutils
|
||||
elif [ "$HOST_OS" = "Win" ]; then
|
||||
pacman -S coreutils
|
||||
else # unexpected
|
||||
_echo_e "Unknown host os :("
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ROOT_DIR=$(realpath "$BASE_DIR/..")
|
||||
|
||||
## init
|
||||
|
||||
if [ -n "${!PYTHON_FOUND}" ]; then
|
||||
_echo_s "Init git hooks"
|
||||
$PYTHON "$ROOT_DIR/tools/linter/init-git-hooks.py"
|
||||
else
|
||||
_echo_en "Skipped init git hooks, as $PYTHON not found"
|
||||
fi
|
||||
|
||||
## cmake version
|
||||
|
||||
_echo_s "Expect cmake version >= 3.0"
|
||||
|
||||
214
scripts/init_tools.sh
Normal file
214
scripts/init_tools.sh
Normal 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_
|
||||
@@ -18,12 +18,10 @@
|
||||
#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"
|
||||
@@ -33,7 +31,7 @@
|
||||
#include "internal/dl.h"
|
||||
|
||||
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
|
||||
#if defined(OS_WIN)
|
||||
#if defined(MYNTEYE_OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -70,7 +68,7 @@ bool dir_exists(const fs::path &p) {
|
||||
|
||||
#elif defined(WITH_NATIVE_FILESYSTEM)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#if defined(MYNTEYE_OS_WIN)
|
||||
|
||||
bool file_exists(const std::string &p) {
|
||||
DWORD attrs = GetFileAttributes(p.c_str());
|
||||
@@ -92,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()) {
|
||||
@@ -189,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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
#include "api/processor/depth_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -40,7 +40,7 @@ Object *DepthProcessor::OnCreateOutput() {
|
||||
|
||||
bool DepthProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
const ObjMat *input = Object::Cast<ObjMat>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
cv::Mat channels[3 /*input->value.channels()*/];
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char DisparityNormalizedProcessor::NAME[] =
|
||||
@@ -44,7 +44,7 @@ Object *DisparityNormalizedProcessor::OnCreateOutput() {
|
||||
|
||||
bool DisparityNormalizedProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
const ObjMat *input = Object::Cast<ObjMat>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
cv::normalize(input->value, output->value, 0, 255, cv::NORM_MINMAX, CV_8UC1);
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char DisparityProcessor::NAME[] = "DisparityProcessor";
|
||||
@@ -74,7 +74,7 @@ Object *DisparityProcessor::OnCreateOutput() {
|
||||
|
||||
bool DisparityProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
const ObjMat2 *input = Object::Cast<ObjMat2>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char PointsProcessor::NAME[] = "PointsProcessor";
|
||||
@@ -42,7 +42,7 @@ Object *PointsProcessor::OnCreateOutput() {
|
||||
|
||||
bool PointsProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
const ObjMat *input = Object::Cast<ObjMat>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
cv::reprojectImageTo3D(input->value, output->value, Q_, true);
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
// 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"
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
#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
|
||||
@@ -49,7 +49,7 @@ Object *RectifyProcessor::OnCreateOutput() {
|
||||
|
||||
bool RectifyProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
const ObjMat2 *input = Object::Cast<ObjMat2>(in);
|
||||
ObjMat2 *output = Object::Cast<ObjMat2>(out);
|
||||
cv::remap(input->first, output->first, map11, map12, cv::INTER_LINEAR);
|
||||
|
||||
@@ -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"
|
||||
@@ -498,7 +498,7 @@ void Synthetic::ProcessNativeStream(
|
||||
|
||||
bool Synthetic::OnRectifyProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
if (plugin_ && plugin_->OnRectifyProcess(in, out)) {
|
||||
return true;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ bool Synthetic::OnRectifyProcess(
|
||||
|
||||
bool Synthetic::OnDisparityProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
if (plugin_ && plugin_->OnDisparityProcess(in, out)) {
|
||||
return true;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ bool Synthetic::OnDisparityProcess(
|
||||
|
||||
bool Synthetic::OnDisparityNormalizedProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
if (plugin_ && plugin_->OnDisparityNormalizedProcess(in, out)) {
|
||||
return true;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ bool Synthetic::OnDisparityNormalizedProcess(
|
||||
|
||||
bool Synthetic::OnPointsProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
if (plugin_ && plugin_->OnPointsProcess(in, out)) {
|
||||
return true;
|
||||
}
|
||||
@@ -535,7 +535,7 @@ bool Synthetic::OnPointsProcess(
|
||||
|
||||
bool Synthetic::OnDepthProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
MYNTEYE_UNUSED(parent)
|
||||
if (plugin_ && plugin_->OnDepthProcess(in, out)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -13,13 +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"
|
||||
@@ -252,7 +252,7 @@ MotionIntrinsics Device::GetMotionIntrinsics(bool *ok) const {
|
||||
return *motion_intrinsics_;
|
||||
} else {
|
||||
*ok = false;
|
||||
LOG(WARNING) << "Motion intrinsics not found";
|
||||
VLOG(2) << "Motion intrinsics not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ Extrinsics Device::GetMotionExtrinsics(const Stream &from, bool *ok) const {
|
||||
return motion_from_extrinsics_.at(from);
|
||||
} catch (const std::out_of_range &e) {
|
||||
*ok = false;
|
||||
LOG(WARNING) << "Motion extrinsics from " << from << " not found";
|
||||
VLOG(2) << "Motion extrinsics from " << from << " not found";
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -580,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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -224,7 +224,7 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) {
|
||||
} break;
|
||||
case Option::FRAME_RATE: {
|
||||
if (!in_range() ||
|
||||
!in_values({10, 15, 20, 25, 30, 35, 40, 45, 50, 55}))
|
||||
!in_values({10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60}))
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
@@ -453,7 +453,7 @@ std::size_t from_data(
|
||||
}
|
||||
i += 40;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ std::size_t from_data(
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ std::size_t from_data(
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ std::size_t to_data(
|
||||
_to_data(info->nominal_baseline, data + i);
|
||||
i += 2;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
|
||||
// others
|
||||
std::size_t size = i - 3;
|
||||
@@ -725,7 +725,7 @@ std::size_t to_data(
|
||||
}
|
||||
i += 40;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ std::size_t to_data(
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ std::size_t to_data(
|
||||
}
|
||||
i += 24;
|
||||
|
||||
UNUSED(spec_version)
|
||||
MYNTEYE_UNUSED(spec_version)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 *;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
#include "internal/motions.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include "internal/channels.h"
|
||||
|
||||
|
||||
@@ -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,7 +50,7 @@ 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
|
||||
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
|
||||
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";
|
||||
<< 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
41
src/public/miniglog.cc
Normal 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
|
||||
3
src/public/miniglog.readme
Normal file
3
src/public/miniglog.readme
Normal file
@@ -0,0 +1,3 @@
|
||||
miniglog:
|
||||
* https://github.com/arpg/miniglog
|
||||
* https://github.com/tzutalin/miniglog
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -100,6 +100,9 @@ float get_real_exposure_time(
|
||||
case 55:
|
||||
real_max = 16.325;
|
||||
break;
|
||||
case 60:
|
||||
real_max = 15;
|
||||
break;
|
||||
default:
|
||||
LOG(ERROR) << "Invalid frame rate: " << frame_rate;
|
||||
return exposure_time;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
#include <strsafe.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#define VLOG_INFO VLOG(2)
|
||||
// #define VLOG_INFO LOG(INFO)
|
||||
|
||||
@@ -57,16 +57,16 @@ 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}")
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
if(mynteye_WITH_GLOG)
|
||||
include(${PRO_DIR}/cmake/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
|
||||
## gtest
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
glog_init _(argc, argv);
|
||||
|
||||
1
third_party/glog
vendored
1
third_party/glog
vendored
Submodule third_party/glog deleted from 8d7a107d68
@@ -43,16 +43,16 @@ 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}")
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
if(mynteye_WITH_GLOG)
|
||||
include(${PRO_DIR}/cmake/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
|
||||
# targets
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
#include <opencv2/imgcodecs/imgcodecs.hpp>
|
||||
#endif
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
#include "mynteye/files.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#define FULL_PRECISION \
|
||||
std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10)
|
||||
@@ -67,7 +66,7 @@ void Dataset::SaveStreamData(
|
||||
<< std::endl;
|
||||
if (data.frame) {
|
||||
std::stringstream ss;
|
||||
ss << writer->outdir << OS_SEP << std::dec
|
||||
ss << writer->outdir << MYNTEYE_OS_SEP << std::dec
|
||||
<< std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png";
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC1, data.frame->data());
|
||||
@@ -95,15 +94,15 @@ Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) {
|
||||
writer_t writer = std::make_shared<Writer>();
|
||||
switch (stream) {
|
||||
case Stream::LEFT: {
|
||||
writer->outdir = outdir_ + OS_SEP "left";
|
||||
writer->outdir = outdir_ + MYNTEYE_OS_SEP "left";
|
||||
} break;
|
||||
case Stream::RIGHT: {
|
||||
writer->outdir = outdir_ + OS_SEP "right";
|
||||
writer->outdir = outdir_ + MYNTEYE_OS_SEP "right";
|
||||
} break;
|
||||
default:
|
||||
LOG(FATAL) << "Unsupported stream: " << stream;
|
||||
}
|
||||
writer->outfile = writer->outdir + OS_SEP "stream.txt";
|
||||
writer->outfile = writer->outdir + MYNTEYE_OS_SEP "stream.txt";
|
||||
|
||||
files::mkdir(writer->outdir);
|
||||
writer->ofs.open(writer->outfile, std::ofstream::out);
|
||||
@@ -120,7 +119,7 @@ Dataset::writer_t Dataset::GetMotionWriter() {
|
||||
if (motion_writer_ == nullptr) {
|
||||
writer_t writer = std::make_shared<Writer>();
|
||||
writer->outdir = outdir_;
|
||||
writer->outfile = writer->outdir + OS_SEP "motion.txt";
|
||||
writer->outfile = writer->outdir + MYNTEYE_OS_SEP "motion.txt";
|
||||
|
||||
files::mkdir(writer->outdir);
|
||||
writer->ofs.open(writer->outfile, std::ofstream::out);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
---
|
||||
device_name: MYNT-EYE-S1000
|
||||
serial_number: "0386322C0009070E"
|
||||
firmware_version: "2.0"
|
||||
firmware_version: "2.2"
|
||||
hardware_version: "2.0"
|
||||
spec_version: "1.0"
|
||||
lens_type: "0000"
|
||||
|
||||
@@ -4,29 +4,29 @@ in_left:
|
||||
-
|
||||
width: 752
|
||||
height: 480
|
||||
fx: 7.3638305001095546e+02
|
||||
fy: 7.2350066150722432e+02
|
||||
cx: 3.5691961817119693e+02
|
||||
cy: 2.1727271340923883e+02
|
||||
fx: 3.6220059643202876e+02
|
||||
fy: 3.6350065250745848e+02
|
||||
cx: 4.0658699068023441e+02
|
||||
cy: 2.3435161110061483e+02
|
||||
model: 0
|
||||
coeffs: [ -5.4898645145016478e-01, 5.2837141203888638e-01, 0., 0.,
|
||||
0. ]
|
||||
coeffs: [ -2.5034765682756088e-01, 5.0579399202897619e-02,
|
||||
-7.0536676161976066e-04, -8.5255451307033846e-03, 0. ]
|
||||
in_right:
|
||||
-
|
||||
width: 752
|
||||
height: 480
|
||||
fx: 7.3638305001095546e+02
|
||||
fy: 7.2350066150722432e+02
|
||||
cx: 4.5668367112303980e+02
|
||||
cy: 2.5070083335536796e+02
|
||||
fx: 3.6514014888558478e+02
|
||||
fy: 3.6513385298966961e+02
|
||||
cx: 3.8932395100630907e+02
|
||||
cy: 2.3495160212312547e+02
|
||||
model: 0
|
||||
coeffs: [ -5.1012886039889305e-01, 3.8764476500996770e-01, 0., 0.,
|
||||
0. ]
|
||||
coeffs: [ -3.0377346762098512e-01, 7.9929693673999838e-02,
|
||||
5.1547517530716883e-05, -6.7345903740579250e-04, 0. ]
|
||||
ex_right_to_left:
|
||||
rotation: [ 9.9701893306553813e-01, -9.5378124886236681e-04,
|
||||
-7.7151392794850615e-02, 1.4493996762830500e-03,
|
||||
9.9997867219985104e-01, 6.3682325649414354e-03,
|
||||
7.7143673424555026e-02, -6.4610716411527686e-03,
|
||||
9.9699905125522237e-01 ]
|
||||
translation: [ -1.1888991734400047e+02, -4.5605803870530912e-02,
|
||||
-3.9531373691193386e+00 ]
|
||||
rotation: [ 9.9867908939669447e-01, -6.3445566137485428e-03,
|
||||
5.0988459509619687e-02, 5.9890316389333252e-03,
|
||||
9.9995670037792639e-01, 7.1224201868366971e-03,
|
||||
-5.1031440326695092e-02, -6.8076406092671274e-03,
|
||||
9.9867384471984544e-01 ]
|
||||
translation: [ -1.2002489764113250e+02, -1.1782637409050747e+00,
|
||||
-5.2058205159996538e+00 ]
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
%YAML:1.0
|
||||
---
|
||||
in_accel:
|
||||
scale: [ 0., 0., 0., 0., 0., 0., 0., 0., 0. ]
|
||||
drift: [ 0., 0., 0. ]
|
||||
noise: [ 0., 0., 0. ]
|
||||
bias: [ 0., 0., 0. ]
|
||||
scale: [ 1., 0., 0., 0., 1., 0., 0., 0., 1. ]
|
||||
drift: [ 0.0, 0.0, 0.0 ]
|
||||
noise: [ 0.016925432397973516, 0.016735310195561025, 0.017452487504590969 ]
|
||||
bias: [ 0.00019031356589714596, 0.00016996777864587261, 0.00054490537096493644 ]
|
||||
in_gyro:
|
||||
scale: [ 0., 0., 0., 0., 0., 0., 0., 0., 0. ]
|
||||
scale: [ 1., 0., 0., 0., 1., 0., 0., 0., 1. ]
|
||||
drift: [ 0., 0., 0. ]
|
||||
noise: [ 0., 0., 0. ]
|
||||
bias: [ 0., 0., 0. ]
|
||||
noise: [ 0.0010848026158819934, 0.0012466367883501759, 0.0011003229919806443 ]
|
||||
bias: [ 0.000023404834136742844, 0.000023596771567764949, 0.000014970418056326829 ]
|
||||
ex_left_to_imu:
|
||||
rotation: [ 0., 0., 0., 0., 0., 0., 0., 0., 0. ]
|
||||
translation: [ 0., 0., 0. ]
|
||||
rotation: [ -0.0064662, -0.99994994, -0.00763565, 0.99997909, -0.00646566, -0.00009558, 0.0000462, -0.00763611, 0.99997084 ]
|
||||
translation: [ 0.00533646, -0.04302922, 0.02303124 ]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/files.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
@@ -209,19 +208,19 @@ void DeviceWriter::SaveAllInfos(const std::string &dir) {
|
||||
if (!files::mkdir(dir)) {
|
||||
LOG(FATAL) << "Create directory failed: " << dir;
|
||||
}
|
||||
SaveDeviceInfo(*device_->GetInfo(), dir + OS_SEP "device.info");
|
||||
SaveDeviceInfo(*device_->GetInfo(), dir + MYNTEYE_OS_SEP "device.info");
|
||||
SaveImgParams(
|
||||
{false, device_->GetIntrinsics(Stream::LEFT),
|
||||
device_->GetIntrinsics(Stream::RIGHT),
|
||||
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT)},
|
||||
dir + OS_SEP "img.params");
|
||||
dir + MYNTEYE_OS_SEP "img.params");
|
||||
auto &&m_in = device_->GetMotionIntrinsics();
|
||||
SaveImuParams(
|
||||
{
|
||||
false, m_in.accel, m_in.gyro,
|
||||
device_->GetMotionExtrinsics(Stream::LEFT),
|
||||
},
|
||||
dir + OS_SEP "imu.params");
|
||||
dir + MYNTEYE_OS_SEP "imu.params");
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/utils.h"
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
|
||||
if (!device)
|
||||
return 1;
|
||||
|
||||
dir.append(OS_SEP "SN").append(device->GetInfo()->serial_number);
|
||||
dir.append(MYNTEYE_OS_SEP "SN").append(device->GetInfo()->serial_number);
|
||||
|
||||
tools::DeviceWriter writer(device);
|
||||
writer.SaveAllInfos(dir);
|
||||
|
||||
@@ -47,14 +47,6 @@ if(OS_MAC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# options
|
||||
|
||||
include(${PRO_DIR}/cmake/Option.cmake)
|
||||
|
||||
if(NOT WITH_API)
|
||||
message(FATAL_ERROR "Must with API layer :(")
|
||||
endif()
|
||||
|
||||
# flags
|
||||
|
||||
if(OS_WIN)
|
||||
@@ -77,14 +69,22 @@ 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}")
|
||||
|
||||
if(NOT mynteye_WITH_API)
|
||||
message(FATAL_ERROR "Must with API layer :(")
|
||||
endif()
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
if(mynteye_WITH_GLOG)
|
||||
include(${PRO_DIR}/cmake/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
## boost & python
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.10" OR CMAKE_VERSION VERSION_EQUAL "3.10")
|
||||
find_package(Boost ${BOOST_FIND_VERSION} REQUIRED
|
||||
COMPONENTS python${PYTHON_BOOST_CODE} # numpy${PYTHON_BOOST_CODE}
|
||||
@@ -103,8 +103,6 @@ message(STATUS "Found PythonLibs: ${PYTHONLIBS_VERSION_STRING}")
|
||||
message(STATUS " PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")
|
||||
message(STATUS " PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
|
||||
# targets
|
||||
|
||||
@@ -99,7 +99,7 @@ def main():
|
||||
# set_option_value
|
||||
|
||||
def set_rate(frame_rate=25, imu_frequency=500): # pylint: disable=unused-variable
|
||||
# FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55
|
||||
# FRAME_RATE values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
|
||||
api.set_option_value(mynteye.FRAME_RATE, frame_rate)
|
||||
# IMU_FREQUENCY values: 100, 200, 250, 333, 500
|
||||
api.set_option_value(mynteye.IMU_FREQUENCY, imu_frequency)
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
#include "array_indexing_suite.hpp"
|
||||
@@ -451,7 +451,7 @@ BOOST_PYTHON_MODULE(mynteye_py) {
|
||||
|
||||
bp::register_ptr_to_python<std::shared_ptr<APIWrap>>();
|
||||
|
||||
// glog_init.h - glog_init
|
||||
// logger.h - glog_init
|
||||
|
||||
bp::class_<glog_init, boost::noncopyable>("glog_init", bp::no_init)
|
||||
.def("create", &glog_init_create)
|
||||
|
||||
@@ -56,9 +56,6 @@ checkPackage("sensor_msgs" "")
|
||||
checkPackage("std_msgs" "")
|
||||
checkPackage("tf" "")
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
|
||||
|
||||
## messages
|
||||
|
||||
add_message_files(
|
||||
@@ -82,14 +79,20 @@ catkin_package(
|
||||
|
||||
get_filename_component(SDK_DIR "${PROJECT_SOURCE_DIR}/../../../.." ABSOLUTE)
|
||||
|
||||
LIST(APPEND CMAKE_PREFIX_PATH ${SDK_DIR}/third_party/glog/_build)
|
||||
find_package(glog REQUIRED)
|
||||
message(STATUS "Found glog: ${glog_VERSION}")
|
||||
|
||||
LIST(APPEND CMAKE_PREFIX_PATH ${SDK_DIR}/_install/lib/cmake)
|
||||
find_package(mynteye REQUIRED)
|
||||
message(STATUS "Found mynteye: ${mynteye_VERSION}")
|
||||
|
||||
if(NOT mynteye_WITH_API)
|
||||
message(FATAL_ERROR "Must with API layer :(")
|
||||
endif()
|
||||
|
||||
include(${SDK_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
if(mynteye_WITH_GLOG)
|
||||
include(${SDK_DIR}/cmake/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
# targets
|
||||
|
||||
add_compile_options(-std=c++11)
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
<arg name="left_topic" default="left/image_raw" />
|
||||
<arg name="right_topic" default="right/image_raw" />
|
||||
<arg name="left_rect_topic" default="left/image_rect" />
|
||||
<arg name="right_rect_topic" default="right/image_rect" />
|
||||
<arg name="left_rect_topic" default="left_rect/image_rect" />
|
||||
<arg name="right_rect_topic" default="right_rect/image_rect" />
|
||||
<arg name="disparity_topic" default="disparity/image_raw" />
|
||||
<arg name="disparity_norm_topic" default="disparity/image_norm" />
|
||||
<arg name="depth_topic" default="depth/image_raw" />
|
||||
@@ -38,7 +38,7 @@
|
||||
<arg name="enable_disparity" default="false" />
|
||||
<arg name="enable_disparity_norm" default="false" />
|
||||
<arg name="enable_points" default="false" />
|
||||
<arg name="enable_depth" default="true" />
|
||||
<arg name="enable_depth" default="false" />
|
||||
|
||||
<!-- device options, -1 will not set the value -->
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<arg name="contrast" default="-1" />
|
||||
<!-- <arg name="contrast" default="127" /> -->
|
||||
|
||||
<!-- frame_rate range: {10,15,20,25,30,35,40,45,50,55} -->
|
||||
<!-- frame_rate range: {10,15,20,25,30,35,40,45,50,55,60} -->
|
||||
<arg name="frame_rate" default="-1" />
|
||||
<!-- <arg name="frame_rate" default="25" /> -->
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <nodelet/loader.h>
|
||||
#include <ros/ros.h>
|
||||
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
glog_init _(argc, argv);
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <mynt_eye_ros_wrapper/GetInfo.h>
|
||||
#include <mynt_eye_ros_wrapper/Temp.h>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
@@ -38,6 +36,7 @@
|
||||
#include "mynteye/api.h"
|
||||
#include "mynteye/context.h"
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#define FULL_PRECISION \
|
||||
std::fixed << std::setprecision(std::numeric_limits<double>::max_digits10)
|
||||
@@ -45,6 +44,9 @@
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace enc = sensor_msgs::image_encodings;
|
||||
inline double compute_time(const double end, const double start) {
|
||||
return end - start;
|
||||
}
|
||||
|
||||
class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
public:
|
||||
@@ -57,15 +59,21 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
}
|
||||
if (time_beg_ != -1) {
|
||||
double time_end = ros::Time::now().toSec();
|
||||
double time_elapsed = time_end - time_beg_;
|
||||
|
||||
LOG(INFO) << "Time elapsed: " << time_elapsed << " s";
|
||||
LOG(INFO) << "Left count: " << left_count_
|
||||
<< ", fps: " << (left_count_ / time_elapsed);
|
||||
LOG(INFO) << "Right count: " << right_count_
|
||||
<< ", fps: " << (right_count_ / time_elapsed);
|
||||
LOG(INFO) << "Imu count: " << imu_count_
|
||||
<< ", hz: " << (imu_count_ / time_elapsed);
|
||||
LOG(INFO) << "Time elapsed: " << compute_time(time_end, time_beg_)
|
||||
<< " s";
|
||||
if (left_time_beg_ != -1) {
|
||||
LOG(INFO) << "Left count: " << left_count_ << ", fps: "
|
||||
<< (left_count_ / compute_time(time_end, left_time_beg_));
|
||||
}
|
||||
if (right_time_beg_ != -1) {
|
||||
LOG(INFO) << "Right count: " << right_count_ << ", fps: "
|
||||
<< (right_count_ / compute_time(time_end, right_time_beg_));
|
||||
}
|
||||
if (imu_time_beg_ != -1) {
|
||||
LOG(INFO) << "Imu count: " << imu_count_ << ", hz: "
|
||||
<< (imu_count_ / compute_time(time_end, imu_time_beg_));
|
||||
}
|
||||
|
||||
// ROS messages could not be reliably printed here, using glog instead :(
|
||||
// ros::Duration(1).sleep(); // 1s
|
||||
@@ -164,6 +172,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
}
|
||||
NODELET_INFO_STREAM(it->first << ": " << api_->GetOptionValue(it->first));
|
||||
}
|
||||
frame_rate_ = api_->GetOptionValue(Option::FRAME_RATE);
|
||||
|
||||
// publishers
|
||||
|
||||
@@ -218,8 +227,10 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
NODELET_INFO_STREAM("Advertized service " << DEVICE_INFO_SERVICE);
|
||||
|
||||
publishStaticTransforms();
|
||||
ros::Rate loop_rate(frame_rate_);
|
||||
while (private_nh_.ok()) {
|
||||
publishTopics();
|
||||
loop_rate.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +270,84 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetIsPublished(const Stream &stream) {
|
||||
is_published_[stream] = false;
|
||||
switch (stream) {
|
||||
case Stream::LEFT_RECTIFIED: {
|
||||
if (is_published_[Stream::RIGHT_RECTIFIED]) {
|
||||
SetIsPublished(Stream::RIGHT_RECTIFIED);
|
||||
}
|
||||
if (is_published_[Stream::DISPARITY]) {
|
||||
SetIsPublished(Stream::DISPARITY);
|
||||
}
|
||||
} break;
|
||||
case Stream::RIGHT_RECTIFIED: {
|
||||
if (is_published_[Stream::LEFT_RECTIFIED]) {
|
||||
SetIsPublished(Stream::RIGHT_RECTIFIED);
|
||||
}
|
||||
if (is_published_[Stream::DISPARITY]) {
|
||||
SetIsPublished(Stream::DISPARITY);
|
||||
}
|
||||
} break;
|
||||
case Stream::DISPARITY: {
|
||||
if (is_published_[Stream::DISPARITY_NORMALIZED]) {
|
||||
SetIsPublished(Stream::DISPARITY_NORMALIZED);
|
||||
}
|
||||
if (is_published_[Stream::POINTS]) {
|
||||
SetIsPublished(Stream::POINTS);
|
||||
}
|
||||
} break;
|
||||
case Stream::DISPARITY_NORMALIZED: {
|
||||
} break;
|
||||
case Stream::POINTS: {
|
||||
if (is_published_[Stream::DEPTH]) {
|
||||
SetIsPublished(Stream::DEPTH);
|
||||
}
|
||||
} break;
|
||||
case Stream::DEPTH: {
|
||||
} break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void publishPoint(const Stream &stream) {
|
||||
auto &&points_num = points_publisher_.getNumSubscribers();
|
||||
if (points_num == 0 && is_published_[stream]) {
|
||||
SetIsPublished(stream);
|
||||
api_->DisableStreamData(stream);
|
||||
} else if (points_num > 0 && !is_published_[Stream::POINTS]) {
|
||||
api_->EnableStreamData(Stream::POINTS);
|
||||
api_->SetStreamCallback(
|
||||
Stream::POINTS, [this](const api::StreamData &data) {
|
||||
static std::size_t count = 0;
|
||||
++count;
|
||||
publishPoints(data, count, ros::Time::now());
|
||||
});
|
||||
is_published_[Stream::POINTS] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void publishOthers(const Stream &stream) {
|
||||
auto stream_num = camera_publishers_[stream].getNumSubscribers();
|
||||
if (stream_num == 0 && is_published_[stream]) {
|
||||
// Stop computing when was not subcribed
|
||||
SetIsPublished(stream);
|
||||
api_->DisableStreamData(stream);
|
||||
} else if (stream_num > 0 && !is_published_[stream]) {
|
||||
// Start computing and publishing when was subcribed
|
||||
api_->EnableStreamData(stream);
|
||||
api_->SetStreamCallback(
|
||||
stream, [this, stream](const api::StreamData &data) {
|
||||
// data.img is null, not hard timestamp
|
||||
static std::size_t count = 0;
|
||||
++count;
|
||||
publishCamera(stream, data, count, ros::Time::now());
|
||||
});
|
||||
is_published_[stream] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void publishTopics() {
|
||||
if (camera_publishers_[Stream::LEFT].getNumSubscribers() > 0 &&
|
||||
!is_published_[Stream::LEFT]) {
|
||||
@@ -285,6 +374,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
<< ", timestamp: " << data.img->timestamp
|
||||
<< ", exposure_time: " << data.img->exposure_time);
|
||||
});
|
||||
left_time_beg_ = ros::Time::now().toSec();
|
||||
is_published_[Stream::LEFT] = true;
|
||||
}
|
||||
|
||||
@@ -302,37 +392,21 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
<< data.img->frame_id << ", timestamp: " << data.img->timestamp
|
||||
<< ", exposure_time: " << data.img->exposure_time);
|
||||
});
|
||||
right_time_beg_ = ros::Time::now().toSec();
|
||||
is_published_[Stream::RIGHT] = true;
|
||||
}
|
||||
|
||||
std::vector<Stream> other_streams{
|
||||
Stream::LEFT_RECTIFIED, Stream::RIGHT_RECTIFIED, Stream::DISPARITY,
|
||||
Stream::DISPARITY_NORMALIZED, Stream::DEPTH};
|
||||
Stream::LEFT_RECTIFIED, Stream::RIGHT_RECTIFIED,
|
||||
Stream::DISPARITY, Stream::DISPARITY_NORMALIZED,
|
||||
Stream::POINTS, Stream::DEPTH};
|
||||
|
||||
for (auto &&stream : other_streams) {
|
||||
if (camera_publishers_[stream].getNumSubscribers() == 0 &&
|
||||
is_published_[stream]) {
|
||||
continue;
|
||||
if (stream != Stream::POINTS) {
|
||||
publishOthers(stream);
|
||||
} else {
|
||||
publishPoint(stream);
|
||||
}
|
||||
api_->SetStreamCallback(
|
||||
stream, [this, stream](const api::StreamData &data) {
|
||||
// data.img is null, not hard timestamp
|
||||
static std::size_t count = 0;
|
||||
++count;
|
||||
publishCamera(stream, data, count, ros::Time::now());
|
||||
});
|
||||
is_published_[stream] = true;
|
||||
}
|
||||
|
||||
if (camera_publishers_[Stream::POINTS].getNumSubscribers() > 0 &&
|
||||
!is_published_[Stream::POINTS]) {
|
||||
api_->SetStreamCallback(
|
||||
Stream::POINTS, [this](const api::StreamData &data) {
|
||||
static std::size_t count = 0;
|
||||
++count;
|
||||
publishPoints(data, count, ros::Time::now());
|
||||
});
|
||||
is_published_[Stream::POINTS] = true;
|
||||
}
|
||||
|
||||
if (!is_motion_published_) {
|
||||
@@ -365,11 +439,12 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
// Sleep 1ms, otherwise publish may drop some datas.
|
||||
ros::Duration(0.001).sleep();
|
||||
});
|
||||
imu_time_beg_ = ros::Time::now().toSec();
|
||||
is_motion_published_ = true;
|
||||
}
|
||||
|
||||
time_beg_ = ros::Time::now().toSec();
|
||||
if (!is_started_) {
|
||||
time_beg_ = ros::Time::now().toSec();
|
||||
api_->Start(Source::ALL);
|
||||
is_started_ = true;
|
||||
}
|
||||
@@ -860,6 +935,9 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
cv::Rect left_roi_, right_roi_;
|
||||
|
||||
double time_beg_ = -1;
|
||||
double left_time_beg_ = -1;
|
||||
double right_time_beg_ = -1;
|
||||
double imu_time_beg_ = -1;
|
||||
std::size_t left_count_ = 0;
|
||||
std::size_t right_count_ = 0;
|
||||
std::size_t imu_count_ = 0;
|
||||
@@ -867,6 +945,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet {
|
||||
std::map<Stream, bool> is_published_;
|
||||
bool is_motion_published_;
|
||||
bool is_started_;
|
||||
int frame_rate_;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user