Compare commits
189 Commits
2.0.0-alph
...
2.0.1-rc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbf789b174 | ||
|
|
66c9af58fc | ||
|
|
375acb534c | ||
|
|
28204d5c0a | ||
|
|
c9483c2aca | ||
|
|
45b4fdeedf | ||
|
|
455b5b931e | ||
|
|
8ab9b42896 | ||
|
|
3258e969ee | ||
|
|
cc74b2663b | ||
|
|
e270e99340 | ||
|
|
0c92f770f2 | ||
|
|
5a9fffe3ed | ||
|
|
384ff028a8 | ||
|
|
0f9bdd5cf2 | ||
|
|
54165b1acb | ||
|
|
087ef28da1 | ||
|
|
b2bd1f389d | ||
|
|
6a82b06b84 | ||
|
|
518416ac4d | ||
|
|
c53dd50730 | ||
|
|
4892f52158 | ||
|
|
3dc21c0378 | ||
|
|
0153261447 | ||
|
|
25f72dd74f | ||
|
|
438ba6481d | ||
|
|
922bf624e7 | ||
|
|
9014f3df57 | ||
|
|
c2f04c487e | ||
|
|
725a8c2e57 | ||
|
|
d04078068a | ||
|
|
9567546894 | ||
|
|
27eb9e6cb2 | ||
|
|
c5b054c864 | ||
|
|
becccd9b8f | ||
|
|
1c1503aae2 | ||
|
|
d3a67b7d29 | ||
|
|
a119b36f72 | ||
|
|
24ca757c92 | ||
|
|
92b38291ee | ||
|
|
377f9b21f1 | ||
|
|
591bbdd3e6 | ||
|
|
68e413e5e2 | ||
|
|
3e42060ff1 | ||
|
|
40b7acd5c3 | ||
|
|
d5bdce4f75 | ||
|
|
7ed11b01ff | ||
|
|
9caf979d4c | ||
|
|
9b91304f0b | ||
|
|
0286da50c6 | ||
|
|
3e96e56d8b | ||
|
|
9451fdd90c | ||
|
|
1293757486 | ||
|
|
190c5d883c | ||
|
|
2fe6309994 | ||
|
|
dfb574c179 | ||
|
|
b7436e41b9 | ||
|
|
046661745d | ||
|
|
9d79526d6a | ||
|
|
7451b6417d | ||
|
|
9c20d62763 | ||
|
|
a0cf8fd902 | ||
|
|
c5dd47708e | ||
|
|
2fddba75e9 | ||
|
|
5a836b2ae3 | ||
|
|
e4fddf2b8d | ||
|
|
1da095f5c3 | ||
|
|
f447739488 | ||
|
|
84103d91bb | ||
|
|
8bf0d982ea | ||
|
|
7e55f78418 | ||
|
|
5be47846e7 | ||
|
|
425b181216 | ||
|
|
b96d7a1782 | ||
|
|
6c7b4e1fb2 | ||
|
|
240b18270b | ||
|
|
87470f29a9 | ||
|
|
b4f73dfa0b | ||
|
|
5daf4162e4 | ||
|
|
aed39f0942 | ||
|
|
3673324079 | ||
|
|
f17eff7e01 | ||
|
|
3112779174 | ||
|
|
1130a99c8d | ||
|
|
13939734a7 | ||
|
|
0b7375698d | ||
|
|
49771d5b8e | ||
|
|
d414182721 | ||
|
|
072fe4d397 | ||
|
|
2ff0ed504d | ||
|
|
25d3526086 | ||
|
|
3a49eec9c0 | ||
|
|
3547acc422 | ||
|
|
152af37138 | ||
|
|
dd2fc88846 | ||
|
|
de0f0d0639 | ||
|
|
58fdc4c01b | ||
|
|
276406dd1e | ||
|
|
a83be6bde6 | ||
|
|
9e7c2cfa68 | ||
|
|
aca1f8b183 | ||
|
|
abef84e8dc | ||
|
|
012ddb2ed0 | ||
|
|
994342ae3a | ||
|
|
42cf45a4c0 | ||
|
|
ff70cc47f3 | ||
|
|
02d78f132d | ||
|
|
76d12ccec7 | ||
|
|
8b7e43d76d | ||
|
|
806359e900 | ||
|
|
c74ebb3cd5 | ||
|
|
63105b5ae4 | ||
|
|
90bb1cdd9a | ||
|
|
4dc9108ae4 | ||
|
|
bbdc0ac178 | ||
|
|
40dc61d2b6 | ||
|
|
1fec1300a8 | ||
|
|
401c003906 | ||
|
|
ca0ae22aea | ||
|
|
9988c49060 | ||
|
|
b8f20c570c | ||
|
|
8ca90f3478 | ||
|
|
7f0fa15c06 | ||
|
|
b1b9b60626 | ||
|
|
113d2e5951 | ||
|
|
ff33770ca4 | ||
|
|
8d017f5e2d | ||
|
|
e041d43183 | ||
|
|
2e31a79b1a | ||
|
|
8b21989dcc | ||
|
|
fbc7c3b6ef | ||
|
|
c6586cf164 | ||
|
|
b0b12c2cc7 | ||
|
|
505b7df188 | ||
|
|
2d7ae598f0 | ||
|
|
54d5c85b48 | ||
|
|
f636ba3a86 | ||
|
|
f3d6fcdcb9 | ||
|
|
77837933bc | ||
|
|
96b5e20580 | ||
|
|
2111a183d0 | ||
|
|
c49342f9f7 | ||
|
|
c176f55af2 | ||
|
|
21f2f91343 | ||
|
|
9e497cfa80 | ||
|
|
cf80332e13 | ||
|
|
3467c822c9 | ||
|
|
a5ce17a987 | ||
|
|
81be95db12 | ||
|
|
b97baae06d | ||
|
|
8f10285773 | ||
|
|
1fd44f7f0c | ||
|
|
cd28fa58d3 | ||
|
|
2dc470e14f | ||
|
|
44364e7d82 | ||
|
|
f766f2df22 | ||
|
|
9cf58f6e70 | ||
|
|
145046249d | ||
|
|
cf15498994 | ||
|
|
cdd98925b5 | ||
|
|
045c94dda7 | ||
|
|
3899b020b8 | ||
|
|
a3f90d31c7 | ||
|
|
ad03d33d9c | ||
|
|
f6120d5ae6 | ||
|
|
e04a05f6f9 | ||
|
|
e50d9cec9b | ||
|
|
c473a1fef3 | ||
|
|
d99bc7bce5 | ||
|
|
7b288456a7 | ||
|
|
06b69da37a | ||
|
|
492b1063c3 | ||
|
|
185ffc2811 | ||
|
|
460c707253 | ||
|
|
03d6043c08 | ||
|
|
3c65958c10 | ||
|
|
9147458c3a | ||
|
|
080db4ae2a | ||
|
|
b42a9529f3 | ||
|
|
9bb99499a2 | ||
|
|
ddb5cb46b7 | ||
|
|
0af640015b | ||
|
|
064b536822 | ||
|
|
209617dd24 | ||
|
|
ac88a68ebc | ||
|
|
ee6d9f5a3b | ||
|
|
09fb4c04df | ||
|
|
22ea971407 | ||
|
|
87458482d9 |
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,5 +1,7 @@
|
||||
.DS_Store
|
||||
/.vscode/
|
||||
|
||||
.vs/
|
||||
.vscode/
|
||||
|
||||
_build/
|
||||
_install/
|
||||
@@ -12,12 +14,15 @@ _output/
|
||||
/*ERROR*
|
||||
/*FATAL*
|
||||
|
||||
/plugins/
|
||||
|
||||
# ros
|
||||
|
||||
/wrappers/ros/build
|
||||
/wrappers/ros/devel
|
||||
/wrappers/ros/install
|
||||
/wrappers/ros/.catkin_workspace
|
||||
/wrappers/ros/src/cv_bridge
|
||||
/wrappers/ros/src/CMakeLists.txt
|
||||
|
||||
# tools
|
||||
@@ -26,3 +31,8 @@ _output/
|
||||
/mynteye/
|
||||
/mynteye.bag
|
||||
/dataset*/
|
||||
|
||||
# wrappers
|
||||
|
||||
/wrappers/python/third_party/numpy-opencv-converter/
|
||||
/wrappers/python/third_party/pyboostcvconverter/
|
||||
|
||||
105
CMakeLists.txt
105
CMakeLists.txt
@@ -1,13 +1,36 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(mynteye VERSION 2.0.0 LANGUAGES C CXX)
|
||||
project(mynteye VERSION 2.0.1 LANGUAGES C CXX)
|
||||
|
||||
include(cmake/Common.cmake)
|
||||
|
||||
# options
|
||||
|
||||
include(cmake/Option.cmake)
|
||||
|
||||
# flags
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
if(OS_WIN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
endif()
|
||||
|
||||
include(cmake/DetectCXX11.cmake)
|
||||
|
||||
@@ -31,9 +54,19 @@ include(CMakePackageConfigHelpers)
|
||||
|
||||
# config
|
||||
|
||||
set(MYNTEYE_NAME ${PROJECT_NAME})
|
||||
|
||||
set(MYNTEYE_NAMESPACE "mynteye")
|
||||
message(STATUS "Namespace: ${MYNTEYE_NAMESPACE}")
|
||||
|
||||
if(MSVC)
|
||||
string(REPLACE "/" "\\\\" MYNTEYE_SDK_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
string(REPLACE "/" "\\\\" MYNTEYE_SDK_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
else()
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" MYNTEYE_SDK_ROOT_DIR)
|
||||
file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" MYNTEYE_SDK_INSTALL_DIR)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
include/mynteye/mynteye.h.in
|
||||
include/mynteye/mynteye.h @ONLY
|
||||
@@ -41,7 +74,7 @@ configure_file(
|
||||
|
||||
# targets
|
||||
|
||||
include(cmake/Common.cmake)
|
||||
add_definitions(-DMYNTEYE_EXPORTS)
|
||||
|
||||
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
|
||||
set_outdir(
|
||||
@@ -66,14 +99,26 @@ target_include_directories(main PRIVATE
|
||||
|
||||
## libmynteye
|
||||
|
||||
set(MYNTEYE_NAME ${PROJECT_NAME})
|
||||
|
||||
set(MYNTEYE_PUBLIC_H
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/callbacks.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/global.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/glog_init.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/mynteye/mynteye.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/types.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/utils.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/device/context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/device/device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/files.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/strings.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/internal/times.h
|
||||
)
|
||||
if(WITH_API)
|
||||
list(APPEND MYNTEYE_PUBLIC_H
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/api/api.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/api/plugin.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/api/processor/object.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OS_WIN)
|
||||
set(UVC_SRC src/uvc/uvc-wmf.cc)
|
||||
@@ -94,21 +139,41 @@ set(MYNTEYE_SRCS
|
||||
${UVC_SRC}
|
||||
src/internal/channels.cc
|
||||
src/internal/config.cc
|
||||
src/internal/dl.cc
|
||||
src/internal/files.cc
|
||||
src/internal/motions.cc
|
||||
src/internal/streams.cc
|
||||
src/internal/strings.cc
|
||||
src/internal/types.cc
|
||||
src/public/types.cc
|
||||
src/public/utils.cc
|
||||
src/device/context.cc
|
||||
src/device/device.cc
|
||||
src/device/device_s.cc
|
||||
)
|
||||
if(WITH_API)
|
||||
list(APPEND MYNTEYE_SRCS
|
||||
src/api/api.cc
|
||||
src/api/synthetic.cc
|
||||
src/api/processor/processor.cc
|
||||
src/api/processor/rectify_processor.cc
|
||||
src/api/processor/disparity_processor.cc
|
||||
src/api/processor/disparity_normalized_processor.cc
|
||||
src/api/processor/depth_processor.cc
|
||||
src/api/processor/points_processor.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
set(MYNTEYE_LINKLIBS
|
||||
glog::glog
|
||||
${UVC_LIB}
|
||||
)
|
||||
if(WITH_API)
|
||||
list(APPEND MYNTEYE_LINKLIBS ${OpenCV_LIBS})
|
||||
endif()
|
||||
if(WITH_BOOST_FILESYSTEM)
|
||||
list(APPEND MYNTEYE_LINKLIBS ${Boost_LIBRARIES})
|
||||
endif()
|
||||
#message(STATUS "MYNTEYE_LINKLIBS: ${MYNTEYE_LINKLIBS}")
|
||||
|
||||
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
|
||||
@@ -169,3 +234,31 @@ install(FILES
|
||||
install(EXPORT ${MYNTEYE_NAME}-targets
|
||||
DESTINATION ${MYNTEYE_CMAKE_INSTALLDIR}
|
||||
)
|
||||
|
||||
## build.info
|
||||
|
||||
# set default int values for yaml file (build.info)
|
||||
set_default_value(CMAKE_CXX_COMPILER_VERSION_MAJOR 0)
|
||||
set_default_value(CMAKE_CXX_COMPILER_VERSION_MINOR 0)
|
||||
set_default_value(CMAKE_CXX_COMPILER_VERSION_PATCH 0)
|
||||
set_default_value(CMAKE_CXX_COMPILER_VERSION_TWEAK 0)
|
||||
set_default_value(CUDA_VERSION_MAJOR 0)
|
||||
set_default_value(CUDA_VERSION_MINOR 0)
|
||||
set_default_value(OpenCV_VERSION_MAJOR 0)
|
||||
set_default_value(OpenCV_VERSION_MINOR 0)
|
||||
set_default_value(OpenCV_VERSION_PATCH 0)
|
||||
set_default_value(OpenCV_VERSION_TWEAK 0)
|
||||
set_default_value(${PROJECT_NAME}_VERSION_MAJOR 0)
|
||||
set_default_value(${PROJECT_NAME}_VERSION_MINOR 0)
|
||||
set_default_value(${PROJECT_NAME}_VERSION_PATCH 0)
|
||||
set_default_value(${PROJECT_NAME}_VERSION_TWEAK 0)
|
||||
|
||||
configure_file(
|
||||
cmake/templates/build.info.in
|
||||
build.info @ONLY
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/build.info
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/mynteye
|
||||
)
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
# 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.
|
||||
ifndef _COMMON_DEFS_MAKE_
|
||||
_COMMON_DEFS_MAKE_ := 1
|
||||
|
||||
@@ -150,7 +163,6 @@ ifneq ($(MAKE),)
|
||||
endif
|
||||
|
||||
CMAKE_OPTIONS :=
|
||||
CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX=$(shell pwd)/_install
|
||||
# CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
|
||||
CMAKE_OPTIONS_AFTER :=
|
||||
|
||||
@@ -159,23 +171,32 @@ ifeq ($(HOST_OS),Win)
|
||||
ifeq ($(HOST_NAME),MinGW)
|
||||
CMAKE += -G "MinGW Makefiles"
|
||||
else ifeq ($(HOST_ARCH),x64)
|
||||
VS_VERSION := $(shell echo "$(shell which cl)" | sed "s/.*Visual\sStudio\s\([0-9]\+\).*/\1/g")
|
||||
ifeq (15,$(VS_VERSION))
|
||||
ifeq ($(VS_CODE),)
|
||||
WHICH_CL := $(shell which cl)
|
||||
ifeq ($(WHICH_CL),)
|
||||
$(error "Visual Studio version is unknown. Could set VS_CODE to specify it, e.g. make [TARGET] VS_CODE=2017")
|
||||
endif
|
||||
# C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\...
|
||||
# C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\...
|
||||
VS_CODE := $(shell echo "$(WHICH_CL)" | grep -Po "(?<=Visual Studio[ /])[0-9]+")
|
||||
endif
|
||||
# $(call mkinfo,"VS_CODE: $(VS_CODE)")
|
||||
ifeq ($(filter $(VS_CODE),15 2017),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 15 2017 Win64"
|
||||
else ifeq (14,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),14 2015),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 14 2015 Win64"
|
||||
else ifeq (12,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),12 2013),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 12 2013 Win64"
|
||||
else ifeq (11,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),11 2012),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 11 2012 Win64"
|
||||
else ifeq (10,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),10 2010),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 10 2010 Win64"
|
||||
else ifeq (9,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),9 2008),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 9 2008 Win64"
|
||||
else ifeq (8,$(VS_VERSION))
|
||||
else ifeq ($(filter $(VS_CODE),8 2005),$(VS_CODE))
|
||||
CMAKE += -G "Visual Studio 8 2005 Win64"
|
||||
else
|
||||
$(call mkinfo,"Connot specify Visual Studio Win64")
|
||||
$(error "Visual Studio version is not proper, VS_CODE: $(VS_CODE)")
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
103
Makefile
103
Makefile
@@ -1,5 +1,27 @@
|
||||
# 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 CommonDefs.mk
|
||||
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
|
||||
# CMAKE_INSTALL_PREFIX:
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html
|
||||
#
|
||||
# UNIX: /usr/local
|
||||
# Windows: c:/Program Files/${PROJECT_NAME}
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
help:
|
||||
@@ -14,10 +36,15 @@ help:
|
||||
@echo " make samples build samples"
|
||||
@echo " make tools build tools"
|
||||
@echo " make ros build ros wrapper"
|
||||
@echo " make py build python wrapper"
|
||||
@echo " make clean|cleanall clean generated or useless things"
|
||||
|
||||
.PHONY: help
|
||||
|
||||
all: test tools samples
|
||||
|
||||
.PHONY: all
|
||||
|
||||
# doc
|
||||
|
||||
apidoc:
|
||||
@@ -33,7 +60,10 @@ opendoc: apidoc
|
||||
[ -f "$$html" ] && $(SH) ./scripts/open.sh $$html; \
|
||||
done
|
||||
|
||||
.PHONY: apidoc opendoc
|
||||
cleandoc:
|
||||
@$(call rm,./doc/_output/)
|
||||
|
||||
.PHONY: apidoc opendoc cleandoc
|
||||
|
||||
# deps
|
||||
|
||||
@@ -59,7 +89,8 @@ init: submodules
|
||||
|
||||
build: third_party
|
||||
@$(call echo,Make $@)
|
||||
@$(call cmake_build,./_build)
|
||||
@$(call cmake_build,./_build,..)
|
||||
@# @$(call cmake_build,./_build,..,-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/_install)
|
||||
|
||||
.PHONY: build
|
||||
|
||||
@@ -68,10 +99,18 @@ build: third_party
|
||||
test: install
|
||||
@$(call echo,Make $@)
|
||||
@$(call echo,Make gtest,33)
|
||||
ifeq ($(HOST_OS),Win)
|
||||
@$(call cmake_build,./test/gtest/_build,..,-Dgtest_force_shared_crt=ON)
|
||||
else
|
||||
@$(call cmake_build,./test/gtest/_build)
|
||||
endif
|
||||
@$(call echo,Make test,33)
|
||||
@$(call cmake_build,./test/_build)
|
||||
ifeq ($(HOST_OS),Win)
|
||||
@.\\\test\\\_output\\\bin\\\mynteye_test.bat
|
||||
else
|
||||
@./test/_output/bin/mynteye_test
|
||||
endif
|
||||
|
||||
.PHONY: test
|
||||
|
||||
@@ -79,7 +118,15 @@ test: install
|
||||
|
||||
install: build
|
||||
@$(call echo,Make $@)
|
||||
@cd ./_build; make install
|
||||
ifeq ($(HOST_OS),Win)
|
||||
ifneq ($(HOST_NAME),MinGW)
|
||||
@cd ./_build; msbuild.exe INSTALL.vcxproj /property:Configuration=Release
|
||||
else
|
||||
@cd ./_build; sudo make install
|
||||
endif
|
||||
else
|
||||
@cd ./_build; sudo make install
|
||||
endif
|
||||
|
||||
.PHONY: install
|
||||
|
||||
@@ -103,7 +150,11 @@ tools: install
|
||||
|
||||
ros: install
|
||||
@$(call echo,Make $@)
|
||||
ifeq ($(HOST_OS),Win)
|
||||
$(error "Can't make ros on win")
|
||||
else
|
||||
@cd ./wrappers/ros && catkin_make
|
||||
endif
|
||||
|
||||
.PHONY: ros
|
||||
|
||||
@@ -121,6 +172,44 @@ cleanros:
|
||||
|
||||
.PHONY: cleanros
|
||||
|
||||
# python
|
||||
|
||||
PBCVT_DIR := wrappers/python/third_party/pyboostcvconverter
|
||||
|
||||
$(PBCVT_DIR):
|
||||
@git clone https://github.com/Algomorph/pyboostcvconverter.git $@
|
||||
|
||||
pbcvt: $(PBCVT_DIR)
|
||||
@$(call cmake_build,$(PBCVT_DIR)/_build,.., \
|
||||
-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/wrappers/python/_install \
|
||||
-DPYTHON_DESIRED_VERSION=2.X)
|
||||
@cd $(PBCVT_DIR)/_build; make install
|
||||
|
||||
.PHONY: pbcvt
|
||||
|
||||
NPCV_DIR := wrappers/python/third_party/numpy-opencv-converter
|
||||
|
||||
$(NPCV_DIR):
|
||||
@git clone https://github.com/GarrickLin/numpy-opencv-converter.git $@
|
||||
|
||||
py: python
|
||||
|
||||
python: install $(NPCV_DIR)
|
||||
@$(call echo,Make $@)
|
||||
@$(call cmake_build,./wrappers/python/_build)
|
||||
@cd ./wrappers/python/_build; make install
|
||||
|
||||
.PHONY: py python
|
||||
|
||||
cleanpy:
|
||||
@$(call echo,Make $@)
|
||||
@$(call rm,./wrappers/python/_build/)
|
||||
@$(call rm,./wrappers/python/_output/)
|
||||
@$(call rm,./wrappers/python/_install/)
|
||||
@$(call rm,./$(PBCVT_DIR)/_build/)
|
||||
|
||||
.PHONY: cleanpy
|
||||
|
||||
# clean
|
||||
|
||||
clean:
|
||||
@@ -138,6 +227,7 @@ clean:
|
||||
ifeq ($(HOST_OS),Linux)
|
||||
@$(MAKE) cleanros
|
||||
endif
|
||||
@$(MAKE) cleanpy
|
||||
|
||||
cleanlog:
|
||||
@$(call rm_f,*INFO*)
|
||||
@@ -145,11 +235,12 @@ cleanlog:
|
||||
@$(call rm_f,*ERROR*)
|
||||
@$(call rm_f,*FATAL*)
|
||||
|
||||
cleanall: clean
|
||||
@$(call rm,./doc/_output/)
|
||||
cleanall: clean cleandoc
|
||||
@$(call rm,./test/gtest/_build/)
|
||||
@$(call rm,./third_party/glog/_build/)
|
||||
@$(FIND) . -type f -name ".DS_Store" -print0 | xargs -0 rm -f
|
||||
@$(call rm,./$(PBCVT_DIR)/)
|
||||
@$(call rm,./$(NPCV_DIR)/)
|
||||
|
||||
.PHONY: clean cleanlog cleanall
|
||||
|
||||
@@ -157,6 +248,8 @@ cleanall: clean
|
||||
|
||||
host:
|
||||
@$(call echo,Make $@)
|
||||
@echo MKFILE_PATH: $(MKFILE_PATH)
|
||||
@echo MKFILE_DIR: $(MKFILE_DIR)
|
||||
@echo HOST_OS: $(HOST_OS)
|
||||
@echo HOST_ARCH: $(HOST_ARCH)
|
||||
@echo HOST_NAME: $(HOST_NAME)
|
||||
|
||||
35
README.md
35
README.md
@@ -1,11 +1,40 @@
|
||||
# MYNT® EYE SDK
|
||||
|
||||
[](https://github.com/slightech/MYNT-EYE-SDK-2)
|
||||
|
||||
## Overview
|
||||
|
||||
MYNT® EYE SDK 2.0 is a cross-platform library for MYNT® EYE cameras.
|
||||
|
||||
The following platforms have been tested:
|
||||
|
||||
* Windows 10
|
||||
* Ubuntu 16.04 / 14.04
|
||||
* Jetson TX2
|
||||
|
||||
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)
|
||||
* [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 )
|
||||
|
||||
> Supported languages: `en`, `zh-Hans`.
|
||||
|
||||
## Firmwares
|
||||
|
||||
[MYNTEYE_BOX]: http://doc.myntai.com/mynteye/s/download
|
||||
|
||||
Get firmwares from our online disks: [MYNTEYE_BOX][]. The latest version is `2.0.1`.
|
||||
|
||||
## Usage
|
||||
|
||||
In short,
|
||||
|
||||
```bash
|
||||
$ make
|
||||
Usage:
|
||||
@@ -27,9 +56,13 @@ Init project, build samples and run someone.
|
||||
```bash
|
||||
make init
|
||||
make samples
|
||||
./samples/_output/bin/device/camera_d
|
||||
./samples/_output/bin/device/camera_d
|
||||
```
|
||||
|
||||
## Mirrors
|
||||
|
||||
国内镜像:[码云](https://gitee.com/mynt/MYNT-EYE-SDK-2)。
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the Apache License, Version 2.0. Copyright 2018 Slightech Co., Ltd.
|
||||
|
||||
@@ -1,15 +1,60 @@
|
||||
# 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()
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
set(CUR_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if(MSVC OR MSYS OR MINGW)
|
||||
set(OS_WIN TRUE)
|
||||
set(HOST_OS Win)
|
||||
elseif(APPLE)
|
||||
set(OS_MAC TRUE)
|
||||
set(HOST_OS Mac)
|
||||
elseif(UNIX)
|
||||
set(OS_LINUX TRUE)
|
||||
set(HOST_OS Linux)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported OS.")
|
||||
endif()
|
||||
|
||||
set(HOST_NAME "${HOST_OS}")
|
||||
|
||||
if(OS_LINUX)
|
||||
execute_process(COMMAND uname -a COMMAND tr -d '\n' OUTPUT_VARIABLE UNAME_A)
|
||||
string(TOLOWER "${UNAME_A}" UNAME_A)
|
||||
if(${UNAME_A} MATCHES ".*(tegra|jetsonbot).*")
|
||||
set(OS_TEGRA TRUE)
|
||||
set(HOST_NAME Tegra)
|
||||
elseif(${UNAME_A} MATCHES ".*ubuntu.*")
|
||||
set(OS_UBUNTU TRUE)
|
||||
set(HOST_NAME Ubuntu)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/TargetArch.cmake)
|
||||
target_architecture(HOST_ARCH)
|
||||
message(STATUS "HOST_ARCH: ${HOST_ARCH}")
|
||||
|
||||
# CMAKE_CXX_COMPILER_ID
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
|
||||
# CMAKE_CXX_COMPILER_VERSION
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_VERSION.html
|
||||
|
||||
# set_outdir(ARCHIVE_OUTPUT_DIRECTORY
|
||||
# LIBRARY_OUTPUT_DIRECTORY
|
||||
# RUNTIME_OUTPUT_DIRECTORY)
|
||||
@@ -24,3 +69,52 @@ macro(set_outdir ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPU
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
set(__exe2bat_relative_path false)
|
||||
|
||||
macro(exe2bat exe_name exe_dir dll_search_paths)
|
||||
message(STATUS "Generating ${exe_name}.bat")
|
||||
set(__exe_name ${exe_name})
|
||||
if(__exe2bat_relative_path)
|
||||
set(__dll_relative_search_paths "")
|
||||
foreach(path ${dll_search_paths})
|
||||
file(RELATIVE_PATH __relative_path "${exe_dir}" "${path}")
|
||||
file(TO_NATIVE_PATH ${__relative_path} __relative_path)
|
||||
list(APPEND __dll_relative_search_paths ${__relative_path})
|
||||
endforeach()
|
||||
set(__dll_search_paths "${__dll_relative_search_paths}")
|
||||
else()
|
||||
set(__dll_native_search_paths "")
|
||||
foreach(path ${dll_search_paths})
|
||||
file(TO_NATIVE_PATH ${path} __native_path)
|
||||
list(APPEND __dll_native_search_paths ${__native_path})
|
||||
endforeach()
|
||||
set(__dll_search_paths "${__dll_native_search_paths}")
|
||||
endif()
|
||||
configure_file(
|
||||
"${CUR_DIR}/templates/exe.bat.in"
|
||||
"${exe_dir}/${__exe_name}.bat"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
# target_create_scripts(NAME
|
||||
# [BIN_DIR bin_dir]
|
||||
# [DLL_SEARCH_PATHS path1 path2 ...])
|
||||
macro(target_create_scripts NAME)
|
||||
set(options)
|
||||
set(oneValueArgs BIN_DIR)
|
||||
set(multiValueArgs DLL_SEARCH_PATHS)
|
||||
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
if(NOT THIS_BIN_DIR)
|
||||
set(THIS_BIN_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
endif()
|
||||
|
||||
#message(STATUS "NAME: ${NAME}")
|
||||
#message(STATUS "THIS_BIN_DIR: ${THIS_BIN_DIR}")
|
||||
#message(STATUS "THIS_DLL_SEARCH_PATHS: ${THIS_DLL_SEARCH_PATHS}")
|
||||
|
||||
if(OS_WIN)
|
||||
exe2bat("${NAME}" "${THIS_BIN_DIR}" "${THIS_DLL_SEARCH_PATHS}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# 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()
|
||||
|
||||
if(MSVC)
|
||||
|
||||
|
||||
37
cmake/DetectOpenCV.cmake
Normal file
37
cmake/DetectOpenCV.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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()
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
|
||||
if(OpenCV_VERSION VERSION_LESS 3.0)
|
||||
add_definitions(-DUSE_OPENCV2)
|
||||
elseif(OpenCV_VERSION VERSION_LESS 4.0)
|
||||
add_definitions(-DUSE_OPENCV3)
|
||||
else()
|
||||
add_definitions(-DUSE_OPENCV4)
|
||||
endif()
|
||||
|
||||
list(FIND OpenCV_LIBS "opencv_world" __index)
|
||||
if(${__index} GREATER -1)
|
||||
set(WITH_OPENCV_WORLD TRUE)
|
||||
endif()
|
||||
|
||||
if(MSVC OR MSYS OR MINGW)
|
||||
get_filename_component(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}/../bin" ABSOLUTE)
|
||||
else()
|
||||
set(OpenCV_LIB_SEARCH_PATH "${OpenCV_LIB_PATH}")
|
||||
endif()
|
||||
1741
cmake/FindCUDA.cmake
Normal file
1741
cmake/FindCUDA.cmake
Normal file
File diff suppressed because it is too large
Load Diff
92
cmake/FindCUDA/make2cmake.cmake
Normal file
92
cmake/FindCUDA/make2cmake.cmake
Normal file
@@ -0,0 +1,92 @@
|
||||
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
|
||||
#
|
||||
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2007-2009
|
||||
# Scientific Computing and Imaging Institute, University of Utah
|
||||
#
|
||||
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||
# for the text of the license.
|
||||
|
||||
# The MIT License
|
||||
#
|
||||
# License for the specific language governing rights and limitations under
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# This converts a file written in makefile syntax into one that can be included
|
||||
# by CMake.
|
||||
|
||||
file(READ ${input_file} depend_text)
|
||||
|
||||
if (NOT "${depend_text}" STREQUAL "")
|
||||
|
||||
# message("FOUND DEPENDS")
|
||||
|
||||
string(REPLACE "\\ " " " depend_text ${depend_text})
|
||||
|
||||
# This works for the nvcc -M generated dependency files.
|
||||
string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
|
||||
string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
|
||||
|
||||
set(dependency_list "")
|
||||
|
||||
foreach(file ${depend_text})
|
||||
|
||||
string(REGEX REPLACE "^ +" "" file ${file})
|
||||
|
||||
# OK, now if we had a UNC path, nvcc has a tendency to only output the first '/'
|
||||
# instead of '//'. Here we will test to see if the file exists, if it doesn't then
|
||||
# try to prepend another '/' to the path and test again. If it still fails remove the
|
||||
# path.
|
||||
|
||||
if(NOT EXISTS "${file}")
|
||||
if (EXISTS "/${file}")
|
||||
set(file "/${file}")
|
||||
else()
|
||||
message(WARNING " Removing non-existent dependency file: ${file}")
|
||||
set(file "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT IS_DIRECTORY "${file}")
|
||||
# If softlinks start to matter, we should change this to REALPATH. For now we need
|
||||
# to flatten paths, because nvcc can generate stuff like /bin/../include instead of
|
||||
# just /include.
|
||||
get_filename_component(file_absolute "${file}" ABSOLUTE)
|
||||
list(APPEND dependency_list "${file_absolute}")
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
# message("FOUND NO DEPENDS")
|
||||
endif()
|
||||
|
||||
# Remove the duplicate entries and sort them.
|
||||
list(REMOVE_DUPLICATES dependency_list)
|
||||
list(SORT dependency_list)
|
||||
|
||||
foreach(file ${dependency_list})
|
||||
set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n")
|
||||
endforeach()
|
||||
|
||||
file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n")
|
||||
109
cmake/FindCUDA/parse_cubin.cmake
Normal file
109
cmake/FindCUDA/parse_cubin.cmake
Normal file
@@ -0,0 +1,109 @@
|
||||
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
|
||||
#
|
||||
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2007-2009
|
||||
# Scientific Computing and Imaging Institute, University of Utah
|
||||
#
|
||||
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||
# for the text of the license.
|
||||
|
||||
# The MIT License
|
||||
#
|
||||
# License for the specific language governing rights and limitations under
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Parses a .cubin file produced by nvcc and reports statistics about the file.
|
||||
|
||||
|
||||
file(READ ${input_file} file_text)
|
||||
|
||||
if (NOT "${file_text}" STREQUAL "")
|
||||
|
||||
string(REPLACE ";" "\\;" file_text ${file_text})
|
||||
string(REPLACE "\ncode" ";code" file_text ${file_text})
|
||||
|
||||
list(LENGTH file_text len)
|
||||
|
||||
foreach(line ${file_text})
|
||||
|
||||
# Only look at "code { }" blocks.
|
||||
if(line MATCHES "^code")
|
||||
|
||||
# Break into individual lines.
|
||||
string(REGEX REPLACE "\n" ";" line ${line})
|
||||
|
||||
foreach(entry ${line})
|
||||
|
||||
# Extract kernel names.
|
||||
if (${entry} MATCHES "[^g]name = ([^ ]+)")
|
||||
set(entry "${CMAKE_MATCH_1}")
|
||||
|
||||
# Check to see if the kernel name starts with "_"
|
||||
set(skip FALSE)
|
||||
# if (${entry} MATCHES "^_")
|
||||
# Skip the rest of this block.
|
||||
# message("Skipping ${entry}")
|
||||
# set(skip TRUE)
|
||||
# else ()
|
||||
message("Kernel: ${entry}")
|
||||
# endif ()
|
||||
|
||||
endif()
|
||||
|
||||
# Skip the rest of the block if necessary
|
||||
if(NOT skip)
|
||||
|
||||
# Registers
|
||||
if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
|
||||
set(entry "${CMAKE_MATCH_3}")
|
||||
message("Registers: ${entry}")
|
||||
endif()
|
||||
|
||||
# Local memory
|
||||
if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
|
||||
set(entry "${CMAKE_MATCH_3}")
|
||||
message("Local: ${entry}")
|
||||
endif()
|
||||
|
||||
# Shared memory
|
||||
if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
|
||||
set(entry "${CMAKE_MATCH_3}")
|
||||
message("Shared: ${entry}")
|
||||
endif()
|
||||
|
||||
if (${entry} MATCHES "^}")
|
||||
message("")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
else()
|
||||
# message("FOUND NO DEPENDS")
|
||||
endif()
|
||||
288
cmake/FindCUDA/run_nvcc.cmake
Normal file
288
cmake/FindCUDA/run_nvcc.cmake
Normal file
@@ -0,0 +1,288 @@
|
||||
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
|
||||
#
|
||||
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
|
||||
#
|
||||
# This code is licensed under the MIT License. See the FindCUDA.cmake script
|
||||
# for the text of the license.
|
||||
|
||||
# The MIT License
|
||||
#
|
||||
# License for the specific language governing rights and limitations under
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
##########################################################################
|
||||
# This file runs the nvcc commands to produce the desired output file along with
|
||||
# the dependency file needed by CMake to compute dependencies. In addition the
|
||||
# file checks the output of each command and if the command fails it deletes the
|
||||
# output files.
|
||||
|
||||
# Input variables
|
||||
#
|
||||
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
|
||||
# ON : Describe each step
|
||||
#
|
||||
# build_configuration:STRING=<> Typically one of Debug, MinSizeRel, Release, or
|
||||
# RelWithDebInfo, but it should match one of the
|
||||
# entries in CUDA_HOST_FLAGS. This is the build
|
||||
# configuration used when compiling the code. If
|
||||
# blank or unspecified Debug is assumed as this is
|
||||
# what CMake does.
|
||||
#
|
||||
# generated_file:STRING=<> File to generate. This argument must be passed in.
|
||||
#
|
||||
# generated_cubin_file:STRING=<> File to generate. This argument must be passed
|
||||
# in if build_cubin is true.
|
||||
|
||||
if(NOT generated_file)
|
||||
message(FATAL_ERROR "You must specify generated_file on the command line")
|
||||
endif()
|
||||
|
||||
# Set these up as variables to make reading the generated file easier
|
||||
set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path
|
||||
set(source_file "@source_file@") # path
|
||||
set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path
|
||||
set(cmake_dependency_file "@cmake_dependency_file@") # path
|
||||
set(CUDA_make2cmake "@CUDA_make2cmake@") # path
|
||||
set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path
|
||||
set(build_cubin @build_cubin@) # bool
|
||||
set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # path
|
||||
# We won't actually use these variables for now, but we need to set this, in
|
||||
# order to force this file to be run again if it changes.
|
||||
set(generated_file_path "@generated_file_path@") # path
|
||||
set(generated_file_internal "@generated_file@") # path
|
||||
set(generated_cubin_file_internal "@generated_cubin_file@") # path
|
||||
|
||||
set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
|
||||
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
|
||||
@CUDA_NVCC_FLAGS_CONFIG@
|
||||
set(nvcc_flags "@nvcc_flags@") # list
|
||||
set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
|
||||
set(format_flag "@format_flag@") # string
|
||||
|
||||
if(build_cubin AND NOT generated_cubin_file)
|
||||
message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
|
||||
endif()
|
||||
|
||||
# This is the list of host compilation flags. It C or CXX should already have
|
||||
# been chosen by FindCUDA.cmake.
|
||||
@CUDA_HOST_FLAGS@
|
||||
|
||||
# Take the compiler flags and package them up to be sent to the compiler via -Xcompiler
|
||||
set(nvcc_host_compiler_flags "")
|
||||
# If we weren't given a build_configuration, use Debug.
|
||||
if(NOT build_configuration)
|
||||
set(build_configuration Debug)
|
||||
endif()
|
||||
string(TOUPPER "${build_configuration}" build_configuration)
|
||||
#message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}")
|
||||
foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
|
||||
# Extra quotes are added around each flag to help nvcc parse out flags with spaces.
|
||||
set(nvcc_host_compiler_flags "${nvcc_host_compiler_flags},\"${flag}\"")
|
||||
endforeach()
|
||||
if (nvcc_host_compiler_flags)
|
||||
set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags})
|
||||
endif()
|
||||
#message("nvcc_host_compiler_flags = \"${nvcc_host_compiler_flags}\"")
|
||||
# Add the build specific configuration flags
|
||||
list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
|
||||
|
||||
# Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority
|
||||
list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 )
|
||||
list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 )
|
||||
if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER )
|
||||
if (CUDA_HOST_COMPILER STREQUAL "@_CUDA_MSVC_HOST_COMPILER@" AND DEFINED CCBIN)
|
||||
set(CCBIN -ccbin "${CCBIN}")
|
||||
else()
|
||||
set(CCBIN -ccbin "${CUDA_HOST_COMPILER}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# cuda_execute_process - Executes a command with optional command echo and status message.
|
||||
#
|
||||
# status - Status message to print if verbose is true
|
||||
# command - COMMAND argument from the usual execute_process argument structure
|
||||
# ARGN - Remaining arguments are the command with arguments
|
||||
#
|
||||
# CUDA_result - return value from running the command
|
||||
#
|
||||
# Make this a macro instead of a function, so that things like RESULT_VARIABLE
|
||||
# and other return variables are present after executing the process.
|
||||
macro(cuda_execute_process status command)
|
||||
set(_command ${command})
|
||||
if(NOT "x${_command}" STREQUAL "xCOMMAND")
|
||||
message(FATAL_ERROR "Malformed call to cuda_execute_process. Missing COMMAND as second argument. (command = ${command})")
|
||||
endif()
|
||||
if(verbose)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo -- ${status})
|
||||
# Now we need to build up our command string. We are accounting for quotes
|
||||
# and spaces, anything else is left up to the user to fix if they want to
|
||||
# copy and paste a runnable command line.
|
||||
set(cuda_execute_process_string)
|
||||
foreach(arg ${ARGN})
|
||||
# If there are quotes, excape them, so they come through.
|
||||
string(REPLACE "\"" "\\\"" arg ${arg})
|
||||
# Args with spaces need quotes around them to get them to be parsed as a single argument.
|
||||
if(arg MATCHES " ")
|
||||
list(APPEND cuda_execute_process_string "\"${arg}\"")
|
||||
else()
|
||||
list(APPEND cuda_execute_process_string ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
# Echo the command
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string})
|
||||
endif()
|
||||
# Run the command
|
||||
execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result )
|
||||
endmacro()
|
||||
|
||||
# Delete the target file
|
||||
cuda_execute_process(
|
||||
"Removing ${generated_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
|
||||
)
|
||||
|
||||
# For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag
|
||||
# for dependency generation and hope for the best.
|
||||
set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
|
||||
set(CUDA_VERSION @CUDA_VERSION@)
|
||||
if(CUDA_VERSION VERSION_LESS "3.0")
|
||||
cmake_policy(PUSH)
|
||||
# CMake policy 0007 NEW states that empty list elements are not
|
||||
# ignored. I'm just setting it to avoid the warning that's printed.
|
||||
cmake_policy(SET CMP0007 NEW)
|
||||
# Note that this will remove all occurrences of -G.
|
||||
list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G")
|
||||
cmake_policy(POP)
|
||||
endif()
|
||||
|
||||
# nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This
|
||||
# can cause incorrect dependencies when #including files based on this macro which is
|
||||
# defined in the generating passes of nvcc invocation. We will go ahead and manually
|
||||
# define this for now until a future version fixes this bug.
|
||||
set(CUDACC_DEFINE -D__CUDACC__)
|
||||
|
||||
# Generate the dependency file
|
||||
cuda_execute_process(
|
||||
"Generating dependency file: ${NVCC_generated_dependency_file}"
|
||||
COMMAND "${CUDA_NVCC_EXECUTABLE}"
|
||||
-M
|
||||
${CUDACC_DEFINE}
|
||||
"${source_file}"
|
||||
-o "${NVCC_generated_dependency_file}"
|
||||
${CCBIN}
|
||||
${nvcc_flags}
|
||||
${nvcc_host_compiler_flags}
|
||||
${depends_CUDA_NVCC_FLAGS}
|
||||
-DNVCC
|
||||
${CUDA_NVCC_INCLUDE_ARGS}
|
||||
)
|
||||
|
||||
if(CUDA_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Generate the cmake readable dependency file to a temp file. Don't put the
|
||||
# quotes just around the filenames for the input_file and output_file variables.
|
||||
# CMake will pass the quotes through and not be able to find the file.
|
||||
cuda_execute_process(
|
||||
"Generating temporary cmake readable file: ${cmake_dependency_file}.tmp"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "input_file:FILEPATH=${NVCC_generated_dependency_file}"
|
||||
-D "output_file:FILEPATH=${cmake_dependency_file}.tmp"
|
||||
-P "${CUDA_make2cmake}"
|
||||
)
|
||||
|
||||
if(CUDA_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Copy the file if it is different
|
||||
cuda_execute_process(
|
||||
"Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}"
|
||||
)
|
||||
|
||||
if(CUDA_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Delete the temporary file
|
||||
cuda_execute_process(
|
||||
"Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
|
||||
)
|
||||
|
||||
if(CUDA_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Generate the code
|
||||
cuda_execute_process(
|
||||
"Generating ${generated_file}"
|
||||
COMMAND "${CUDA_NVCC_EXECUTABLE}"
|
||||
"${source_file}"
|
||||
${format_flag} -o "${generated_file}"
|
||||
${CCBIN}
|
||||
${nvcc_flags}
|
||||
${nvcc_host_compiler_flags}
|
||||
${CUDA_NVCC_FLAGS}
|
||||
-DNVCC
|
||||
${CUDA_NVCC_INCLUDE_ARGS}
|
||||
)
|
||||
|
||||
if(CUDA_result)
|
||||
# Since nvcc can sometimes leave half done files make sure that we delete the output file.
|
||||
cuda_execute_process(
|
||||
"Removing ${generated_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
|
||||
)
|
||||
message(FATAL_ERROR "Error generating file ${generated_file}")
|
||||
else()
|
||||
if(verbose)
|
||||
message("Generated ${generated_file} successfully.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Cubin resource report commands.
|
||||
if( build_cubin )
|
||||
# Run with -cubin to produce resource usage report.
|
||||
cuda_execute_process(
|
||||
"Generating ${generated_cubin_file}"
|
||||
COMMAND "${CUDA_NVCC_EXECUTABLE}"
|
||||
"${source_file}"
|
||||
${CUDA_NVCC_FLAGS}
|
||||
${nvcc_flags}
|
||||
${CCBIN}
|
||||
${nvcc_host_compiler_flags}
|
||||
-DNVCC
|
||||
-cubin
|
||||
-o "${generated_cubin_file}"
|
||||
${CUDA_NVCC_INCLUDE_ARGS}
|
||||
)
|
||||
|
||||
# Execute the parser script.
|
||||
cuda_execute_process(
|
||||
"Executing the parser script"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "input_file:STRING=${generated_cubin_file}"
|
||||
-P "${CUDA_parse_cubin}"
|
||||
)
|
||||
|
||||
endif()
|
||||
23
cmake/IncludeGuard.cmake
Normal file
23
cmake/IncludeGuard.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# 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_guard: https://cmake.org/cmake/help/latest/command/include_guard.html
|
||||
|
||||
macro(cmake_include_guard)
|
||||
get_property(INCLUDE_GUARD GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}")
|
||||
if(INCLUDE_GUARD)
|
||||
return()
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY "_INCLUDE_GUARD_${CMAKE_CURRENT_LIST_FILE}" TRUE)
|
||||
endmacro()
|
||||
136
cmake/Option.cmake
Normal file
136
cmake/Option.cmake
Normal file
@@ -0,0 +1,136 @@
|
||||
# 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()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake)
|
||||
|
||||
|
||||
# build components
|
||||
|
||||
option(WITH_API "Build with API layer, need OpenCV" ON)
|
||||
|
||||
option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON)
|
||||
|
||||
# 3rdparty components
|
||||
|
||||
option(WITH_BOOST "Include Boost support" ON)
|
||||
|
||||
|
||||
# packages
|
||||
|
||||
if(WITH_API)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/DetectOpenCV.cmake)
|
||||
endif()
|
||||
|
||||
if(WITH_DEVICE_INFO_REQUIRED)
|
||||
add_definitions(-DWITH_DEVICE_INFO_REQUIRED)
|
||||
endif()
|
||||
|
||||
if(WITH_BOOST)
|
||||
find_package(Boost COMPONENTS filesystem)
|
||||
if(Boost_FOUND)
|
||||
set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
|
||||
set(WITH_FILESYSTEM TRUE)
|
||||
set(WITH_BOOST_FILESYSTEM TRUE)
|
||||
add_definitions(-DWITH_FILESYSTEM)
|
||||
add_definitions(-DWITH_BOOST_FILESYSTEM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WITH_FILESYSTEM)
|
||||
if(MSVC OR MSYS OR MINGW) # win
|
||||
set(WITH_FILESYSTEM TRUE)
|
||||
set(WITH_NATIVE_FILESYSTEM TRUE)
|
||||
add_definitions(-DWITH_FILESYSTEM)
|
||||
add_definitions(-DWITH_NATIVE_FILESYSTEM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(CUDA QUIET)
|
||||
|
||||
# summary
|
||||
|
||||
set_version_values(CMAKE_CXX_COMPILER_VERSION)
|
||||
|
||||
status("")
|
||||
status("Platform:")
|
||||
status(" HOST_OS: ${HOST_OS}")
|
||||
status(" HOST_NAME: ${HOST_NAME}")
|
||||
status(" HOST_ARCH: ${HOST_ARCH}")
|
||||
status(" HOST_COMPILER: ${CMAKE_CXX_COMPILER_ID}")
|
||||
status(" COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
status(" COMPILER_VERSION_MAJOR: ${CMAKE_CXX_COMPILER_VERSION_MAJOR}")
|
||||
status(" COMPILER_VERSION_MINOR: ${CMAKE_CXX_COMPILER_VERSION_MINOR}")
|
||||
status(" COMPILER_VERSION_PATCH: ${CMAKE_CXX_COMPILER_VERSION_PATCH}")
|
||||
status(" COMPILER_VERSION_TWEAK: ${CMAKE_CXX_COMPILER_VERSION_TWEAK}")
|
||||
if(CUDA_FOUND)
|
||||
status(" CUDA_VERSION: ${CUDA_VERSION}")
|
||||
status(" CUDA_VERSION_MAJOR: ${CUDA_VERSION_MAJOR}")
|
||||
status(" CUDA_VERSION_MINOR: ${CUDA_VERSION_MINOR}")
|
||||
status(" CUDA_VERSION_STRING: ${CUDA_VERSION_STRING}")
|
||||
endif()
|
||||
if(OpenCV_FOUND)
|
||||
status(" OpenCV_VERSION: ${OpenCV_VERSION}")
|
||||
status(" OpenCV_VERSION_MAJOR: ${OpenCV_VERSION_MAJOR}")
|
||||
status(" OpenCV_VERSION_MINOR: ${OpenCV_VERSION_MINOR}")
|
||||
status(" OpenCV_VERSION_PATCH: ${OpenCV_VERSION_PATCH}")
|
||||
status(" OpenCV_VERSION_TWEAK: ${OpenCV_VERSION_TWEAK}")
|
||||
status(" OpenCV_VERSION_STATUS: ${OpenCV_VERSION_STATUS}")
|
||||
status(" OpenCV_WITH_WORLD: ${WITH_OPENCV_WORLD}")
|
||||
endif()
|
||||
if(mynteye_VERSION)
|
||||
status(" MYNTEYE_VERSION: ${mynteye_VERSION}")
|
||||
status(" MYNTEYE_VERSION_MAJOR: ${mynteye_VERSION_MAJOR}")
|
||||
status(" MYNTEYE_VERSION_MINOR: ${mynteye_VERSION_MINOR}")
|
||||
status(" MYNTEYE_VERSION_PATCH: ${mynteye_VERSION_PATCH}")
|
||||
status(" MYNTEYE_VERSION_TWEAK: ${mynteye_VERSION_TWEAK}")
|
||||
endif()
|
||||
|
||||
status("")
|
||||
status("Options:")
|
||||
status(" WITH_API: ${WITH_API}")
|
||||
if(WITH_API)
|
||||
if(OpenCV_FOUND)
|
||||
status(" OpenCV: YES")
|
||||
status(" OpenCV_VERSION: ${OpenCV_VERSION}")
|
||||
status(" OpenCV_WORLD: " IF WITH_OPENCV_WORLD "YES" ELSE "NO")
|
||||
else()
|
||||
status(" OpenCV: NO")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
status(" WITH_DEVICE_INFO_REQUIRED: ${WITH_DEVICE_INFO_REQUIRED}")
|
||||
|
||||
status(" WITH_BOOST: ${WITH_BOOST}")
|
||||
if(WITH_BOOST)
|
||||
if(Boost_FOUND)
|
||||
status(" Boost: YES")
|
||||
status(" Boost_VERSION: ${Boost_VERSION_STRING}")
|
||||
#status(" Boost_LIBRARIES: ${Boost_LIBRARIES}")
|
||||
else()
|
||||
status(" Boost: NO")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
status("")
|
||||
status("Features:")
|
||||
status(" Filesystem: "
|
||||
IF WITH_BOOST_FILESYSTEM "boost"
|
||||
ELIF WITH_NATIVE_FILESYSTEM "native"
|
||||
ELSE "none"
|
||||
)
|
||||
|
||||
status("")
|
||||
167
cmake/TargetArch.cmake
Executable file
167
cmake/TargetArch.cmake
Executable file
@@ -0,0 +1,167 @@
|
||||
# Based on the Qt 5 processor detection code, so should be very accurate
|
||||
# http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/global/qprocessordetection.h
|
||||
# Currently handles arm (v5, v6, v7, v8), x86 (32/64), ia64, and ppc (32/64)
|
||||
|
||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) \\
|
||||
|| defined(__aarch64__) || defined(__ARM64__)
|
||||
#if defined(__aarch64__) || defined(__ARM64__)
|
||||
#define cmake_ARM_64
|
||||
#else
|
||||
#define cmake_ARM_32
|
||||
#endif
|
||||
#if defined(__ARM_ARCH) && __ARM_ARCH > 1
|
||||
#define cmake_ARM __ARM_ARCH
|
||||
#elif defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM > 1
|
||||
#define cmake_ARM __TARGET_ARCH_ARM
|
||||
#elif defined(_M_ARM) && _M_ARM > 1
|
||||
#define cmake_ARM _M_ARM
|
||||
#elif defined(__ARM64_ARCH_8__) \\
|
||||
|| defined(__aarch64__) \\
|
||||
|| defined(__ARMv8__) \\
|
||||
|| defined(__ARMv8_A__)
|
||||
#define cmake_ARM 8
|
||||
#elif defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|| defined(__ARM_ARCH_7M__) \\
|
||||
|| defined(__ARM_ARCH_7S__) \\
|
||||
|| defined(_ARM_ARCH_7) \\
|
||||
|| defined(__CORE_CORTEXA__)
|
||||
#define cmake_ARM 7
|
||||
#elif defined(__ARM_ARCH_6__) \\
|
||||
|| defined(__ARM_ARCH_6J__) \\
|
||||
|| defined(__ARM_ARCH_6T2__) \\
|
||||
|| defined(__ARM_ARCH_6Z__) \\
|
||||
|| defined(__ARM_ARCH_6K__) \\
|
||||
|| defined(__ARM_ARCH_6ZK__) \\
|
||||
|| defined(__ARM_ARCH_6M__)
|
||||
#define cmake_ARM 6
|
||||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
||||
|| defined(__ARM_ARCH_5TE__)
|
||||
#define cmake_ARM 5
|
||||
#else
|
||||
#define cmake_ARM 0
|
||||
#endif
|
||||
#if cmake_ARM >= 8
|
||||
#error cmake_ARCH armv8
|
||||
#elif cmake_ARM >= 7
|
||||
#error cmake_ARCH armv7
|
||||
#elif cmake_ARM >= 6
|
||||
#error cmake_ARCH armv6
|
||||
#elif cmake_ARM >= 5
|
||||
#error cmake_ARCH armv5
|
||||
#else
|
||||
#if defined(cmake_ARM_64)
|
||||
#error cmake_ARCH arm64
|
||||
#else
|
||||
#error cmake_ARCH arm
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
||||
#error cmake_ARCH i386
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
#error cmake_ARCH x86_64
|
||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
#error cmake_ARCH ia64
|
||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
||||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
||||
#error cmake_ARCH ppc64
|
||||
#else
|
||||
#error cmake_ARCH ppc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#error cmake_ARCH unknown
|
||||
")
|
||||
|
||||
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
||||
# will be treated as invalid architectures since they are no longer supported by Apple
|
||||
|
||||
function(target_architecture output_var)
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
||||
# First let's normalize the order of the values
|
||||
|
||||
# Note that it's not possible to compile PowerPC applications if you are using
|
||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
||||
# disable it by default
|
||||
# See this page for more information:
|
||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
||||
|
||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
||||
|
||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
||||
set(osx_arch_ppc TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "i386")
|
||||
set(osx_arch_i386 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "x86_64")
|
||||
set(osx_arch_x86_64 TRUE)
|
||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
||||
set(osx_arch_ppc64 TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Now add all the architectures in our normalized order
|
||||
if(osx_arch_ppc)
|
||||
list(APPEND ARCH ppc)
|
||||
endif()
|
||||
|
||||
if(osx_arch_i386)
|
||||
list(APPEND ARCH i386)
|
||||
endif()
|
||||
|
||||
if(osx_arch_x86_64)
|
||||
list(APPEND ARCH x86_64)
|
||||
endif()
|
||||
|
||||
if(osx_arch_ppc64)
|
||||
list(APPEND ARCH ppc64)
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
||||
|
||||
enable_language(C)
|
||||
|
||||
# Detect the architecture in a rather creative way...
|
||||
# This compiles a small C program which is a series of ifdefs that selects a
|
||||
# particular #error preprocessor directive whose message string contains the
|
||||
# target architecture. The program will always fail to compile (both because
|
||||
# file is not a valid C program, and obviously because of the presence of the
|
||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
||||
# way, we can detect the correct target architecture even when cross-compiling,
|
||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
||||
try_run(
|
||||
run_result_unused
|
||||
compile_result_unused
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/arch.c"
|
||||
COMPILE_OUTPUT_VARIABLE ARCH
|
||||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
||||
)
|
||||
|
||||
# Parse the architecture name from the compiler output
|
||||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
||||
|
||||
# Get rid of the value marker leaving just the architecture name
|
||||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
||||
|
||||
# If we are compiling with an unknown architecture this variable should
|
||||
# already be set to "unknown" but in the case that it's empty (i.e. due
|
||||
# to a typo in the code), then set it to unknown
|
||||
if (NOT ARCH)
|
||||
set(ARCH unknown)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
136
cmake/Utils.cmake
Normal file
136
cmake/Utils.cmake
Normal file
@@ -0,0 +1,136 @@
|
||||
# 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()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake)
|
||||
|
||||
# make_executable(NAME
|
||||
# [SRCS src1 src2 ...]
|
||||
# [LINK_LIBS lib1 lib2 ...]
|
||||
# [DLL_SEARCH_PATHS path1 path2 ...]
|
||||
# [WITH_THREAD])
|
||||
macro(make_executable NAME)
|
||||
set(options WITH_THREAD)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs SRCS LINK_LIBS DLL_SEARCH_PATHS)
|
||||
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
|
||||
add_executable(${NAME} ${THIS_SRCS})
|
||||
target_link_libraries(${NAME} ${THIS_LINK_LIBS})
|
||||
target_create_scripts(${NAME} DLL_SEARCH_PATHS ${THIS_DLL_SEARCH_PATHS})
|
||||
|
||||
if(OS_WIN)
|
||||
target_compile_definitions(${NAME}
|
||||
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
)
|
||||
endif()
|
||||
|
||||
if(THIS_WITH_THREAD)
|
||||
#find_package(Threads REQUIRED)
|
||||
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()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# set_default_value(VARIABLE DEFAULT)
|
||||
macro(set_default_value VARIABLE DEFAULT)
|
||||
if(NOT ${VARIABLE})
|
||||
set(${VARIABLE} ${DEFAULT})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# set_version_values(VARIABLE)
|
||||
macro(set_version_values VARIABLE)
|
||||
string(REPLACE "." ";" __version_list "${${VARIABLE}}")
|
||||
list(LENGTH __version_list __len)
|
||||
if(${__len} GREATER 0)
|
||||
list(GET __version_list 0 ${VARIABLE}_MAJOR)
|
||||
endif()
|
||||
if(${__len} GREATER 1)
|
||||
list(GET __version_list 1 ${VARIABLE}_MINOR)
|
||||
endif()
|
||||
if(${__len} GREATER 2)
|
||||
list(GET __version_list 2 ${VARIABLE}_PATCH)
|
||||
endif()
|
||||
if(${__len} GREATER 3)
|
||||
list(GET __version_list 3 ${VARIABLE}_TWEAK)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# status(TEXT [IF cond text [ELIF cond text] [ELSE cond text]])
|
||||
macro(status TEXT)
|
||||
set(options)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs IF ELIF ELSE)
|
||||
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
|
||||
#message(STATUS "TEXT: ${TEXT}")
|
||||
#message(STATUS "THIS_IF: ${THIS_IF}")
|
||||
#message(STATUS "THIS_ELIF: ${THIS_ELIF}")
|
||||
#message(STATUS "THIS_ELSE: ${THIS_ELSE}")
|
||||
|
||||
set(__msg_list "${TEXT}")
|
||||
set(__continue TRUE)
|
||||
|
||||
if(__continue AND DEFINED THIS_IF)
|
||||
#message(STATUS "-- THIS_IF: ${THIS_IF}")
|
||||
list(LENGTH THIS_IF __if_len)
|
||||
if(${__if_len} GREATER 1)
|
||||
list(GET THIS_IF 0 __if_cond)
|
||||
if(${__if_cond})
|
||||
list(REMOVE_AT THIS_IF 0)
|
||||
list(APPEND __msg_list ${THIS_IF})
|
||||
set(__continue FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "status() IF must have cond and text, >= 2 items")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(__continue AND DEFINED THIS_ELIF)
|
||||
#message(STATUS "-- THIS_ELIF: ${THIS_ELIF}")
|
||||
list(LENGTH THIS_ELIF __elif_len)
|
||||
if(${__elif_len} GREATER 1)
|
||||
list(GET THIS_ELIF 0 __elif_cond)
|
||||
if(${__elif_cond})
|
||||
list(REMOVE_AT THIS_ELIF 0)
|
||||
list(APPEND __msg_list ${THIS_ELIF})
|
||||
set(__continue FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "status() ELIF must have cond and text, >= 2 items")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(__continue AND DEFINED THIS_ELSE)
|
||||
#message(STATUS "-- THIS_ELSE: ${THIS_ELSE}")
|
||||
list(LENGTH THIS_ELSE __else_len)
|
||||
if(${__else_len} GREATER 0)
|
||||
list(APPEND __msg_list ${THIS_ELSE})
|
||||
else()
|
||||
message(FATAL_ERROR "status() ELSE must have text, >= 1 items")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "" __msg_list "${__msg_list}")
|
||||
message(STATUS "${__msg_list}")
|
||||
endmacro()
|
||||
27
cmake/templates/build.info.in
Normal file
27
cmake/templates/build.info.in
Normal file
@@ -0,0 +1,27 @@
|
||||
%YAML:1.0
|
||||
---
|
||||
HOST_OS: "@HOST_OS@"
|
||||
HOST_NAME: "@HOST_NAME@"
|
||||
HOST_ARCH: "@HOST_ARCH@"
|
||||
HOST_COMPILER: "@CMAKE_CXX_COMPILER_ID@"
|
||||
COMPILER_VERSION: "@CMAKE_CXX_COMPILER_VERSION@"
|
||||
COMPILER_VERSION_MAJOR: @CMAKE_CXX_COMPILER_VERSION_MAJOR@
|
||||
COMPILER_VERSION_MINOR: @CMAKE_CXX_COMPILER_VERSION_MINOR@
|
||||
COMPILER_VERSION_PATCH: @CMAKE_CXX_COMPILER_VERSION_PATCH@
|
||||
COMPILER_VERSION_TWEAK: @CMAKE_CXX_COMPILER_VERSION_TWEAK@
|
||||
CUDA_VERSION: "@CUDA_VERSION@"
|
||||
CUDA_VERSION_MAJOR: @CUDA_VERSION_MAJOR@
|
||||
CUDA_VERSION_MINOR: @CUDA_VERSION_MINOR@
|
||||
CUDA_VERSION_STRING: "@CUDA_VERSION_STRING@"
|
||||
OpenCV_VERSION: "@OpenCV_VERSION@"
|
||||
OpenCV_VERSION_MAJOR: @OpenCV_VERSION_MAJOR@
|
||||
OpenCV_VERSION_MINOR: @OpenCV_VERSION_MINOR@
|
||||
OpenCV_VERSION_PATCH: @OpenCV_VERSION_PATCH@
|
||||
OpenCV_VERSION_TWEAK: @OpenCV_VERSION_TWEAK@
|
||||
OpenCV_VERSION_STATUS: "@OpenCV_VERSION_STATUS@"
|
||||
OpenCV_WITH_WORLD: "@WITH_OPENCV_WORLD@"
|
||||
MYNTEYE_VERSION: "@mynteye_VERSION@"
|
||||
MYNTEYE_VERSION_MAJOR: @mynteye_VERSION_MAJOR@
|
||||
MYNTEYE_VERSION_MINOR: @mynteye_VERSION_MINOR@
|
||||
MYNTEYE_VERSION_PATCH: @mynteye_VERSION_PATCH@
|
||||
MYNTEYE_VERSION_TWEAK: @mynteye_VERSION_TWEAK@
|
||||
13
cmake/templates/exe.bat.in
Normal file
13
cmake/templates/exe.bat.in
Normal file
@@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
set "MY_DIR=%~dp0"
|
||||
set "MY_PWD=%cd%"
|
||||
|
||||
if "%MY_PATH_SET_@__exe_name@%"=="" (
|
||||
set "MY_PATH_SET_@__exe_name@=1"
|
||||
set "PATH=@__dll_search_paths@;%PATH%"
|
||||
)
|
||||
|
||||
::cd "%MY_DIR%"
|
||||
"%MY_DIR%@__exe_name@.exe" %*
|
||||
::cd "%MY_PWD%"
|
||||
::pause >nul
|
||||
25
doc/build.sh
25
doc/build.sh
@@ -1,4 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# _VERBOSE_=1
|
||||
# _TEST_=1
|
||||
|
||||
@@ -26,8 +40,8 @@ OUTPUT="$BASE_DIR/_output"
|
||||
_texcjk() {
|
||||
tex="$1"; shift;
|
||||
_echo_in "add cjk to $tex"
|
||||
sed -i "" -e $'s/^\\\\begin{document}$/\\\\usepackage{CJKutf8}\\\n\\\\begin{document}\\\n\\\\begin{CJK}{UTF8}{gbsn}/g' $tex
|
||||
sed -i "" -e $'s/^\\\\end{document}$/\\\\end{CJK}\\\n\\\\end{document}/g' $tex
|
||||
sed -i "" -E $'s/^\\\\begin{document}$/\\\\usepackage{CJKutf8}\\\n\\\\begin{document}\\\n\\\\begin{CJK}{UTF8}{gbsn}/g' $tex
|
||||
sed -i "" -E $'s/^\\\\end{document}$/\\\\end{CJK}\\\n\\\\end{document}/g' $tex
|
||||
}
|
||||
|
||||
for lang in "${LANGS[@]}"; do
|
||||
@@ -40,8 +54,13 @@ for lang in "${LANGS[@]}"; do
|
||||
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"`
|
||||
filename="mynt-eye-sdk-apidoc"; \
|
||||
[ -n "$version" ] && filename="$filename-$version"; \
|
||||
filename="$filename-$lang.pdf"
|
||||
cd "$OUTPUT/$lang/latex" && _texcjk refman.tex && make
|
||||
[ -f "refman.pdf" ] && mv "refman.pdf" "../mynteye-apidoc.pdf"
|
||||
[ -f "refman.pdf" ] && mv "refman.pdf" "../$filename"
|
||||
fi
|
||||
_echo_d "doxygen completed"
|
||||
else
|
||||
|
||||
2494
doc/en/api.doxyfile
Normal file
2494
doc/en/api.doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
11
doc/en/mainpage.md
Normal file
11
doc/en/mainpage.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# MYNT EYE SDK {#mainpage}
|
||||
|
||||
* <a class="el" href="annotated.html">API Classes</a>
|
||||
* <a class="el" href="modules.html">API Modules</a>
|
||||
* \link enumerations Enumerations\endlink
|
||||
* \link datatypes Datatypes\endlink
|
||||
* \link utils Utiliities\endlink
|
||||
* \link calibration Intrinsics & Extrinsics\endlink
|
||||
* <span style="font-weight:bold">Device Specifications</span>
|
||||
* @subpage specs_data
|
||||
* @subpage specs_ctrl
|
||||
26
doc/en/spec_control_api.md
Normal file
26
doc/en/spec_control_api.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Control Protocols {#spec_control_api}
|
||||
|
||||
There are two control modes, one is through UVC standard protocol, the other is through UVC custom protocol with extension unit.
|
||||
|
||||
## Standard Protocol
|
||||
|
||||
| Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Note |
|
||||
| :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :--- |
|
||||
| Gain | gain | 2 | 24 | 0 | 48 | √ | 0x12 | valid if manual-exposure |
|
||||
| Brightness | brightness/exposure_time | 2 | 120 | 0 | 240 | √ | 0x14 | valid if manual-exposure |
|
||||
| Contrast | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | valid if manual-exposure |
|
||||
|
||||
## Custom Protocol
|
||||
|
||||
| Name | Field | Bytes | Default | Min | Max | Stored | Flash Address | Channel | Note |
|
||||
| :--- | :---- | :---- | :------ | :-- | :-- | :----- | :------------ | :------ | :----- |
|
||||
| Frame rate | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | values: {10,15,20,25,30,35,40,45,50,55} |
|
||||
| IMU frequency | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | values: {100,200,250,333,500} |
|
||||
| Exposure mode | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0: enable auto-exposure; 1: manual-exposure |
|
||||
| Max gain | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | valid if auto-exposure |
|
||||
| Max exposure time | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | valid if auto-exposure |
|
||||
| Desired brightness | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | valid if auto-exposure |
|
||||
| IR control | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | |
|
||||
| HDR mode | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0: 10-bit; 1: 12-bit |
|
||||
| Zero drift calibration | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
| Erase chip | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
53
doc/en/spec_control_channel.md
Normal file
53
doc/en/spec_control_channel.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Control Channels {#spec_control_channel}
|
||||
|
||||
| Name | Field | Address | Bandwidth | Node |
|
||||
| :----- | :----- | :----- | :----- | :----- |
|
||||
| Camera control channel | XU_CAM_CTRL_CHANNEL | 1 | 3 | |
|
||||
| Half-Duplex channel | XU_HALF_DUPLEX_CHANNEL | 2 | 20 | |
|
||||
| IMU write channel | XU_IMUDATA_WRITE_CHANNEL | 3 | 5 | |
|
||||
| IMU read channel | XU_IMUDATA_READ_CHANNEL | 4 | 2000 | |
|
||||
| File channel | XU_FILE_CHANNEL | 5 | 2000 | |
|
||||
|
||||
## Camera Control Channel
|
||||
|
||||
The channel provides get, set and query (min, max, default).
|
||||
|
||||
## Half-Duplex Channel
|
||||
|
||||
The channel only provides set, such as zero drift correction.
|
||||
|
||||
## IMU Channel
|
||||
|
||||
The channel is used to request and response IMU data, see @ref spec_imu_data.
|
||||
|
||||
## File Channel
|
||||
|
||||
The channel is used to read and write device information, image params, and IMU params.
|
||||
|
||||
| Name | Header | Size | File | Checksum |
|
||||
| :--- | :- | :--- | :--- | :-------- |
|
||||
| Bytes | 1 | 2 | - | 1 |
|
||||
| Type | uint8_t | uint16_t | - | uint8_t |
|
||||
| Description | Flags | Content size | Content data | Checksum, XOR of all content bytes |
|
||||
|
||||
| Header Bit Subscript | Description |
|
||||
| :------------------- | :---------- |
|
||||
| 0 | Device information |
|
||||
| 1 | Image params |
|
||||
| 2 | IMU params |
|
||||
| 3~6 | Undefined |
|
||||
| 7 | 0: Get; 1: Set |
|
||||
|
||||
### File Content Packet
|
||||
|
||||
| Name | ID | Size | Content |
|
||||
| :--- | :- | :--- | :------ |
|
||||
| Bytes | 1 | 2 | - |
|
||||
| Type | uint8_t | uint16_t | - |
|
||||
| Description | Content ID | Content size | Content data |
|
||||
|
||||
| File | ID | Max Size |
|
||||
| :--- | :- | :------- |
|
||||
| Device information | 1 | 250 |
|
||||
| Image params | 2 | 250 |
|
||||
| IMU params | 4 | 500 |
|
||||
14
doc/en/spec_hardware_info.md
Normal file
14
doc/en/spec_hardware_info.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Device Information {#spec_hardware_info}
|
||||
|
||||
| Name | Field | Fixed Value | USB Descriptor | UVC Extension Unit | Bytes | Note |
|
||||
| :----- | :----- | :-------- | :-------------- | :----------------- | :-------- | :----- |
|
||||
| VID | vid | 0x04B4 | √ | × | 2 | |
|
||||
| PID | pid | 0x00F9 | √ | × | 2 | |
|
||||
| Device name | name | MYNT-EYE-? | √ | √ Get | 16 | MYNT-EYE-S1000 |
|
||||
| Serial number | serial_number | - | √ | √ Get | 16 | |
|
||||
| Firmware version | firmware_version | - | √ | √ Get | 2 | major,minor |
|
||||
| Hardware version | hardware_version | - | × | √ Get | 3 | major,minor,flag |
|
||||
| Spec version | spec_version | - | × | √ Get | 2 | major,minor |
|
||||
| Lens type | lens_type | - | × | √ Get/Set | 4 | vendor(2),product(2); default: 0 |
|
||||
| IMU type | imu_type | - | × | √ Get/Set | 4 | vendor(2),product(2); default: 0 |
|
||||
| Nominal baseline | nominal_baseline | - | × | √ Get/Set | 2 | unit: mm; default: 0 |
|
||||
20
doc/en/spec_image_data.md
Normal file
20
doc/en/spec_image_data.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Image Data {#spec_image_data}
|
||||
|
||||
| Name | Field | Unit | Bytes | Note |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| Frame ID | frame_id | - | 2 | uint16_t; [0,65535] |
|
||||
| Timestamp | timestamp | 10 us | 4 | uint32_t |
|
||||
| Exposure Time | exposure_time | 10 us | 2 | uint16_t |
|
||||
|
||||
## Image Packet
|
||||
|
||||
| Name | Header | Size | Frame ID | Timestamp | Exposure Time | Checksum |
|
||||
| :--- | :----- | :--- | :------- | :-------- | :------------ | :------- |
|
||||
| Bytes | 1 | 1 | 2 | 4 | 2 | 1 |
|
||||
| Type | uint8_t | uint8_t | uint16_t | uint32_t | uint16_t | uint8_t |
|
||||
| Description | 0x3B | 0x08, content size | Frame ID | Timestamp | Exposure time | Checksum, XOR of all content bytes |
|
||||
|
||||
* The image packet will be dropped, if checksum is incorrect.
|
||||
* The accuracy of the time unit: 0.01 ms / 10 us.
|
||||
* The timestamp could indicate 11.9 hours, it will accumulate again after overflow.
|
||||
* The timestamp accumulation starts from the time of power-on, instead of opening.
|
||||
23
doc/en/spec_image_params.md
Normal file
23
doc/en/spec_image_params.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Image Params {#spec_image_params}
|
||||
|
||||
## Image Intrinsics
|
||||
|
||||
| Name | Field | Unit | Bytes | Note |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| Image width | width | px | 2 | uint16_t; [0,65535] |
|
||||
| Image height | height | px | 2 | uint16_t; [0,65535] |
|
||||
| Focal length | fx | - | 8 | double |
|
||||
| ^ | fy | - | 8 | double |
|
||||
| Principal point | cx | - | 8 | double |
|
||||
| ^ | cy | - | 8 | double |
|
||||
| Distortion model | model | - | 1 | uint8_t; pinhole,... |
|
||||
| Distortion coefficients | coeffs[5] | - | 40 | double; k1,k2,p1,p2,k3 |
|
||||
|
||||
## Image Extrinsics
|
||||
|
||||
Transformation matrix from left image to right image.
|
||||
|
||||
| Name | Field | Unit | Bytes | Note |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| Rotation matrix | rotation[3][3] | - | 72 | double |
|
||||
| Translation vector | translation[3] | - | 24 | double |
|
||||
42
doc/en/spec_imu_data.md
Normal file
42
doc/en/spec_imu_data.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# IMU Data {#spec_imu_data}
|
||||
|
||||
## IMU Request Packet
|
||||
|
||||
| Name | Header | Serial Number |
|
||||
| :--- | :----- | :------------ |
|
||||
| Bytes | 1 | 4 |
|
||||
| Type | uint8_t | uint32_t |
|
||||
| Description | 0x5A | First request should be 0, otherwise the last one |
|
||||
|
||||
## IMU Response Packet
|
||||
|
||||
The IMU response packet contains multiple IMU packets, and each IMU packet contains multiple IMU segments.
|
||||
|
||||
| Name | Header | State | Size | IMU Packets | Checksum |
|
||||
| :--- | :----- | :---- | :--- | :---------- | :------- |
|
||||
| Bytes | 1 | 1 | 2 | ... | 1 |
|
||||
| Type | uint8_t | uint8_t | uint16_t | - | uint8_t |
|
||||
| Description | 0x5B | 0 is success, others are failed | Content size | IMU packets | Checksum, XOR of all content bytes |
|
||||
|
||||
### IMU Packet
|
||||
|
||||
The IMU packet is an array of IMU datas.
|
||||
|
||||
| Name | Serial Number | Timestamp | Count | IMU Datas |
|
||||
| :--- | :------------ | :-------- | :---- | :-------- |
|
||||
| Bytes | 4 | 4 | 1 | ... |
|
||||
| Type | uint32_t | uint32_t | uint8_t | - |
|
||||
| Description | Serial number | IMU basic timestamp | The number of IMU datas | IMU datas |
|
||||
|
||||
### IMU Segment
|
||||
|
||||
| Name | Offset | Frame ID | Accelerometer | Temperature | Gyroscope |
|
||||
| :--- | :----- | :------- | :------------ | :---------- | :-------- |
|
||||
| Bytes | 2 | 2 | 6 | 2 | 6 |
|
||||
| Type | int16_t | uint16_t | int16_t * 3 | int16_t | int16_t * 3 |
|
||||
| Description | The timestamp offset | Image frame ID | Accel x,y,z values | IMU temperature | Gyro x,y,z values |
|
||||
|
||||
* Formula for converting the accel & gyro values to real ones: **real = data * range / 0x10000** .
|
||||
* ``accel`` default ``range`` is **8 g**, ``gyro`` default ``range`` is **1000 deg/s**.
|
||||
* Formula for converting the temperature to real value: **real = data / ratio + offset** .
|
||||
* default ``ratio`` is **326.8**, default ``offset`` is **25℃**.
|
||||
23
doc/en/spec_imu_params.md
Normal file
23
doc/en/spec_imu_params.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# IMU Params {#spec_imu_params}
|
||||
|
||||
## IMU Intrinsics
|
||||
|
||||
| Name | Field | Unit | Bytes | Note |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| Scale matrix | acc_scale[3][3] | - | 72 | double |
|
||||
| ^ | gyro_scale[3][3] | - | 72 | double |
|
||||
| Zero-drift | acc_drift[3] | - | 24 | double |
|
||||
| ^ | gyro_drift[3] | - | 24 | double |
|
||||
| Noise density | acc_noise[3] | - | 24 | double |
|
||||
| ^ | gyro_noise[3] | - | 24 | double |
|
||||
| Random walk | acc_bias[3] | - | 24 | double |
|
||||
| ^ | gyro_bias[3] | - | 24 | double |
|
||||
|
||||
## IMU Extrinsics
|
||||
|
||||
Transformation matrix from left image to IMU.
|
||||
|
||||
| Name | Field | Unit | Bytes | Note |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| Rotation matrix | rotation[3][3] | - | 72 | double |
|
||||
| Translation vector | translation[3] | - | 24 | double |
|
||||
4
doc/en/specs_ctrl.md
Normal file
4
doc/en/specs_ctrl.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Device Control Specification {#specs_ctrl}
|
||||
|
||||
* @subpage spec_control_api
|
||||
* @subpage spec_control_channel
|
||||
7
doc/en/specs_data.md
Normal file
7
doc/en/specs_data.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Device Data Specification {#specs_data}
|
||||
|
||||
* @subpage spec_hardware_info
|
||||
* @subpage spec_image_params
|
||||
* @subpage spec_imu_params
|
||||
* @subpage spec_image_data
|
||||
* @subpage spec_imu_data
|
||||
14
doc/langs.sh
14
doc/langs.sh
@@ -1,4 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LANGS=(
|
||||
en
|
||||
zh-Hans
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.8.13
|
||||
# Doxyfile 1.8.14
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# doxygen (www.doxygen.org) for a project.
|
||||
@@ -20,8 +20,8 @@
|
||||
# This tag specifies the encoding used for all characters in the config file
|
||||
# that follow. The default is UTF-8 which is also the encoding used for all text
|
||||
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
|
||||
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
|
||||
# for the list of possible encodings.
|
||||
# built into libc) for the transcoding. See
|
||||
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
|
||||
# The default value is: UTF-8.
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
@@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE SDK"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = v2.0
|
||||
PROJECT_NUMBER = 2.0.1-rc1
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
@@ -236,7 +236,8 @@ TAB_SIZE = 2
|
||||
# will allow you to put the command \sideeffect (or @sideeffect) in the
|
||||
# documentation, which will result in a user-defined paragraph with heading
|
||||
# "Side Effects:". You can put \n's in the value part of an alias to insert
|
||||
# newlines.
|
||||
# newlines (in the resulting output). You can put ^^ in the value part of an
|
||||
# alias to insert a newline as if a physical newline was in the original file.
|
||||
|
||||
ALIASES =
|
||||
|
||||
@@ -337,7 +338,7 @@ BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
|
||||
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
|
||||
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
|
||||
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
|
||||
# will parse them like normal C++ but will assume all classes use public instead
|
||||
# of private inheritance when no explicit protection keyword is present.
|
||||
# The default value is: NO.
|
||||
@@ -708,7 +709,7 @@ LAYOUT_FILE =
|
||||
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
||||
# the reference definitions. This must be a list of .bib files. The .bib
|
||||
# extension is automatically appended if omitted. This requires the bibtex tool
|
||||
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
|
||||
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
|
||||
# For LaTeX the style of the bibliography can be controlled using
|
||||
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
|
||||
# search path. See also \cite for info how to create references.
|
||||
@@ -791,13 +792,6 @@ WARN_LOGFILE =
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = mainpage.md \
|
||||
guides.md \
|
||||
guide_build_linux.md \
|
||||
guide_samples.md \
|
||||
guide_tools.md \
|
||||
guide_log.md \
|
||||
guide_opencv.md \
|
||||
guide_ros.md \
|
||||
specs_data.md \
|
||||
spec_hardware_info.md \
|
||||
spec_image_params.md \
|
||||
@@ -812,7 +806,7 @@ INPUT = mainpage.md \
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
|
||||
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
|
||||
# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
|
||||
# possible encodings.
|
||||
# The default value is: UTF-8.
|
||||
|
||||
@@ -1060,7 +1054,7 @@ SOURCE_TOOLTIPS = YES
|
||||
# If the USE_HTAGS tag is set to YES then the references to source code will
|
||||
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
|
||||
# source browser. The htags tool is part of GNU's global source tagging system
|
||||
# (see http://www.gnu.org/software/global/global.html). You will need version
|
||||
# (see https://www.gnu.org/software/global/global.html). You will need version
|
||||
# 4.8.6 or higher.
|
||||
#
|
||||
# To use it do the following:
|
||||
@@ -1205,7 +1199,7 @@ HTML_EXTRA_FILES =
|
||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||
# will adjust the colors in the style sheet and background images according to
|
||||
# this color. Hue is specified as an angle on a colorwheel, see
|
||||
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
||||
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
||||
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
|
||||
# purple, and 360 is red again.
|
||||
# Minimum value: 0, maximum value: 359, default value: 220.
|
||||
@@ -1241,6 +1235,17 @@ HTML_COLORSTYLE_GAMMA = 80
|
||||
|
||||
HTML_TIMESTAMP = NO
|
||||
|
||||
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||
# documentation will contain a main index with vertical navigation menus that
|
||||
# are dynamically created via Javascript. If disabled, the navigation index will
|
||||
# consists of multiple levels of tabs that are statically embedded in every HTML
|
||||
# page. Disable this option to support browsers that do not have Javascript,
|
||||
# like the Qt help browser.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_DYNAMIC_MENUS = YES
|
||||
|
||||
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
|
||||
# documentation will contain sections that can be hidden and shown after the
|
||||
# page has loaded.
|
||||
@@ -1264,12 +1269,12 @@ HTML_INDEX_NUM_ENTRIES = 100
|
||||
|
||||
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
|
||||
# generated that can be used as input for Apple's Xcode 3 integrated development
|
||||
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
|
||||
# environment (see: https://developer.apple.com/tools/xcode/), introduced with
|
||||
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
|
||||
# Makefile in the HTML output directory. Running make will produce the docset in
|
||||
# that directory and running make install will install the docset in
|
||||
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
|
||||
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
||||
# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
||||
# for more information.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
@@ -1385,7 +1390,7 @@ QCH_FILE =
|
||||
|
||||
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
|
||||
# Project output. For more information please see Qt Help Project / Namespace
|
||||
# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
|
||||
# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
|
||||
# The default value is: org.doxygen.Project.
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
@@ -1393,8 +1398,7 @@ QHP_NAMESPACE = com.slightech.mynteye
|
||||
|
||||
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
|
||||
# Help Project output. For more information please see Qt Help Project / Virtual
|
||||
# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
|
||||
# folders).
|
||||
# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
|
||||
# The default value is: doc.
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
@@ -1402,23 +1406,21 @@ QHP_VIRTUAL_FOLDER = doc
|
||||
|
||||
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
|
||||
# filter to add. For more information please see Qt Help Project / Custom
|
||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
||||
# filters).
|
||||
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_CUST_FILTER_NAME =
|
||||
|
||||
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
|
||||
# custom filter to add. For more information please see Qt Help Project / Custom
|
||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
||||
# filters).
|
||||
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
|
||||
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
|
||||
# project's filter section matches. Qt Help Project / Filter Attributes (see:
|
||||
# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
|
||||
# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
@@ -1511,7 +1513,7 @@ EXT_LINKS_IN_WINDOW = NO
|
||||
|
||||
FORMULA_FONTSIZE = 10
|
||||
|
||||
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
|
||||
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
|
||||
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
||||
# supported properly for IE 6.0, but are supported on all modern browsers.
|
||||
#
|
||||
@@ -1523,7 +1525,7 @@ FORMULA_FONTSIZE = 10
|
||||
FORMULA_TRANSPARENT = YES
|
||||
|
||||
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
|
||||
# http://www.mathjax.org) which uses client side Javascript for the rendering
|
||||
# https://www.mathjax.org) which uses client side Javascript for the rendering
|
||||
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
|
||||
# installed or if you want to formulas look prettier in the HTML output. When
|
||||
# enabled you may also need to install MathJax separately and configure the path
|
||||
@@ -1550,11 +1552,11 @@ MATHJAX_FORMAT = HTML-CSS
|
||||
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
|
||||
# Content Delivery Network so you can quickly see the result without installing
|
||||
# MathJax. However, it is strongly recommended to install a local copy of
|
||||
# MathJax from http://www.mathjax.org before deployment.
|
||||
# The default value is: http://cdn.mathjax.org/mathjax/latest.
|
||||
# MathJax from https://www.mathjax.org before deployment.
|
||||
# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/.
|
||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/
|
||||
|
||||
# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
|
||||
# extension names that should be enabled during MathJax rendering. For example
|
||||
@@ -1612,7 +1614,7 @@ SERVER_BASED_SEARCH = NO
|
||||
#
|
||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||
# (doxysearch.cgi) which are based on the open source search engine library
|
||||
# Xapian (see: http://xapian.org/).
|
||||
# Xapian (see: https://xapian.org/).
|
||||
#
|
||||
# See the section "External Indexing and Searching" for details.
|
||||
# The default value is: NO.
|
||||
@@ -1625,7 +1627,7 @@ EXTERNAL_SEARCH = NO
|
||||
#
|
||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||
# (doxysearch.cgi) which are based on the open source search engine library
|
||||
# Xapian (see: http://xapian.org/). See the section "External Indexing and
|
||||
# Xapian (see: https://xapian.org/). See the section "External Indexing and
|
||||
# Searching" for details.
|
||||
# This tag requires that the tag SEARCHENGINE is set to YES.
|
||||
|
||||
@@ -1814,7 +1816,7 @@ LATEX_SOURCE_CODE = NO
|
||||
|
||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||
# bibliography, e.g. plainnat, or ieeetr. See
|
||||
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||
# The default value is: plain.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
@@ -1997,9 +1999,9 @@ DOCBOOK_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
|
||||
# AutoGen Definitions (see http://autogen.sf.net) file that captures the
|
||||
# structure of the code including all documentation. Note that this feature is
|
||||
# still experimental and incomplete at the moment.
|
||||
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
|
||||
# the structure of the code including all documentation. Note that this feature
|
||||
# is still experimental and incomplete at the moment.
|
||||
# The default value is: NO.
|
||||
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
@@ -2099,7 +2101,9 @@ INCLUDE_FILE_PATTERNS =
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
PREDEFINED = DOXYGEN_WORKING
|
||||
PREDEFINED = DOXYGEN_WORKING \
|
||||
"MYNTEYE_BEGIN_NAMESPACE=namespace mynteye {" \
|
||||
"MYNTEYE_END_NAMESPACE=}"
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# 编译 on Linux {#guide_build_linux}
|
||||
|
||||
> Ubuntu 16.04, Ubuntu 14.04
|
||||
|
||||
## 获取代码
|
||||
|
||||
```bash
|
||||
@@ -13,6 +15,18 @@ cd mynt-eye-sdk-2/
|
||||
make init
|
||||
```
|
||||
|
||||
### [OpenCV](https://opencv.org/)
|
||||
|
||||
编译前,可在系统终端(Windows 命令提示符)里如下指定 OpenCV 路径,其为 `OpenCVConfig.cmake` 目录:
|
||||
|
||||
```bash
|
||||
# Linux, macOS
|
||||
export OpenCV_DIR=~/opencv
|
||||
|
||||
# Windows
|
||||
set OpenCV_DIR=C:\opencv
|
||||
```
|
||||
|
||||
## 编译代码
|
||||
|
||||
```bash
|
||||
|
||||
113
doc/zh-Hans/guide_build_win.md
Normal file
113
doc/zh-Hans/guide_build_win.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# 编译 on Windows {#guide_build_win}
|
||||
|
||||
> Windows 10
|
||||
|
||||
## 前提条件
|
||||
|
||||
* [Git](https://git-scm.com/downloads),用于获取代码。
|
||||
* [CMake](https://cmake.org/download/),用于构建编译。
|
||||
* [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html),用于生成文档。
|
||||
|
||||
最终,命令提示符(Command Prompt, cmd)里可找到如下命令:
|
||||
|
||||
```cmd
|
||||
>cmake --version
|
||||
cmake version 3.10.1
|
||||
|
||||
>git --version
|
||||
git version 2.11.1.windows.1
|
||||
|
||||
>doxygen --version
|
||||
1.8.13
|
||||
```
|
||||
|
||||
* [Visual Studio](https://www.visualstudio.com/)
|
||||
* [Visual Studio 2015](https://my.visualstudio.com/Downloads?q=Visual Studio 2015)
|
||||
* [Visual Studio 2017](https://my.visualstudio.com/Downloads?q=Visual Studio 2017)
|
||||
* [Windows 10 SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk)
|
||||
|
||||
以 Visual Studio 2015 举例,请在系统环境变量 `PATH` 里添加上如下路径:
|
||||
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
|
||||
C:\Program Files (x86)\MSBuild\14.0\Bin
|
||||
|
||||
最终,命令提示符(Command Prompt, cmd)里可找到如下命令:
|
||||
|
||||
```cmd
|
||||
>cl
|
||||
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
|
||||
|
||||
>link
|
||||
Microsoft (R) Incremental Linker Version 14.00.24215.1
|
||||
|
||||
>lib
|
||||
Microsoft (R) Library Manager Version 14.00.24215.1
|
||||
|
||||
>msbuild
|
||||
Microsoft (R) 生成引擎版本 14.0.25420.1
|
||||
```
|
||||
|
||||
* [MSYS2](http://www.msys2.org/)
|
||||
* [国内镜像](https://lug.ustc.edu.cn/wiki/mirrors/help/msys2)
|
||||
* [pacman](https://wiki.archlinux.org/index.php/pacman)
|
||||
|
||||
打开 MSYS2 MSYS ,然后执行:
|
||||
|
||||
```msys
|
||||
$ pacman -Syu
|
||||
$ pacman -S make
|
||||
```
|
||||
|
||||
并在系统环境变量 `PATH` 里添加上如下路径:
|
||||
|
||||
C:\msys64\usr\bin
|
||||
|
||||
最终,命令提示符(Command Prompt, cmd)里可找到如下命令:
|
||||
|
||||
```cmd
|
||||
>make --version
|
||||
GNU Make 4.2.1
|
||||
```
|
||||
|
||||
## 获取代码
|
||||
|
||||
```cmd
|
||||
>git clone https://github.com/slightech/MYNT-EYE-SDK-2.git
|
||||
```
|
||||
|
||||
## 准备依赖
|
||||
|
||||
```cmd
|
||||
>cd mynt-eye-sdk-2
|
||||
>make init
|
||||
Make init
|
||||
Init deps
|
||||
Install cmd: pacman -S
|
||||
Install deps: git clang-format
|
||||
pacman -S clang-format (not exists)
|
||||
error: target not found: clang-format
|
||||
pip install --upgrade autopep8 cpplint pylint requests
|
||||
...
|
||||
Init git hooks
|
||||
ERROR: clang-format-diff is not installed!
|
||||
Expect cmake version >= 3.0
|
||||
cmake version 3.10.1
|
||||
```
|
||||
|
||||
### [OpenCV](https://opencv.org/)
|
||||
|
||||
编译前,可在系统终端(Windows 命令提示符)里如下指定 OpenCV 路径,其为 `OpenCVConfig.cmake` 目录:
|
||||
|
||||
```bash
|
||||
# Linux, macOS
|
||||
export OpenCV_DIR=~/opencv
|
||||
|
||||
# Windows
|
||||
set OpenCV_DIR=C:\opencv
|
||||
```
|
||||
|
||||
## 编译代码
|
||||
|
||||
```cmd
|
||||
>make install
|
||||
```
|
||||
@@ -1,3 +1,13 @@
|
||||
# OpenCV 依赖 {#guide_opencv}
|
||||
|
||||
目前 SDK 本身未依赖 OpenCV ,仅是样例依赖其显示图像。
|
||||
SDK 提供了三层接口,其 OpenCV 依赖情况如下:
|
||||
|
||||
* `api`, 上层接口,依赖 OpenCV 。
|
||||
* `device`,中间层接口,不依赖 OpenCV 。
|
||||
* `uvc`,底层接口,不依赖 OpenCV 。
|
||||
|
||||
如果不想使用 OpenCV ,你可编辑 `<sdk>/cmake/Option.cmake` 里的 `WITH_API` 选项,设为 `OFF` 就能关闭 `api` 层代码编译:
|
||||
|
||||
```cmake
|
||||
option(WITH_API "Build with API layer, need OpenCV" ON)
|
||||
```
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
|
||||
样例在 `<sdk>/samples` 目录,其提供了不同接口层的使用范例。
|
||||
|
||||
* `api`, API 层接口,依赖 OpenCV 。
|
||||
* `device`,中间层接口,不依赖 OpenCV 。
|
||||
* `uvc`,底层接口。
|
||||
|
||||
> 目前 API 层接口,正在实现中。
|
||||
|
||||
## 依赖
|
||||
|
||||
* [OpenCV](https://opencv.org/),用于显示图像。
|
||||
* 编译前,可在系统终端(Windows 命令提示符)里如下指定 OpenCV 路径,其为 `OpenCVConfig.cmake` 目录:
|
||||
|
||||
```bash
|
||||
# Linux, macOS
|
||||
export OpenCV_DIR=~/opencv
|
||||
|
||||
# Windows
|
||||
set OpenCV_DIR=C:\opencv
|
||||
```
|
||||
|
||||
## 编译
|
||||
|
||||
@@ -20,8 +23,24 @@ make samples
|
||||
|
||||
## 运行
|
||||
|
||||
运行 `api` 层接口样例,显示图像并输出 IMU 。
|
||||
|
||||
```bash
|
||||
./samples/_output/bin/api/camera_a
|
||||
|
||||
# Windows
|
||||
.\samples\_output\bin\api\camera_a.bat
|
||||
```
|
||||
|
||||
运行 `device` 层接口样例,显示图像并输出 IMU 。
|
||||
|
||||
```bash
|
||||
./samples/_output/bin/device/camera_d
|
||||
|
||||
# Windows
|
||||
.\samples\_output\bin\device\camera_d.bat
|
||||
```
|
||||
|
||||
## 结语
|
||||
|
||||
更多样例的说明,请见 `samples/README.md` 。
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
# 工具 {#guide_tools}
|
||||
|
||||
样例在 `<sdk>/tools` 目录,其提供一些有用的工具。
|
||||
工具在 `<sdk>/tools` 目录,其提供一些有用的脚本和程序。
|
||||
|
||||
## 准备
|
||||
## 依赖
|
||||
|
||||
* [OpenCV](https://opencv.org/),部分工具需要。
|
||||
* 编译前,可在系统终端(Windows 命令提示符)里如下指定 OpenCV 路径,其为 `OpenCVConfig.cmake` 目录:
|
||||
|
||||
```bash
|
||||
# Linux, macOS
|
||||
export OpenCV_DIR=~/opencv
|
||||
|
||||
# Windows
|
||||
set OpenCV_DIR=C:\opencv
|
||||
```
|
||||
|
||||
* Python 第三方库,脚本需要。
|
||||
|
||||
```bash
|
||||
cd tools/
|
||||
sudo pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## 编译
|
||||
|
||||
```bash
|
||||
make tools
|
||||
|
||||
cd tools/
|
||||
sudo pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## 录制数据集
|
||||
|
||||
```bash
|
||||
./tools/_output/bin/dataset/record
|
||||
|
||||
# Windows
|
||||
.\tools\_output\bin\dataset\record.bat
|
||||
```
|
||||
|
||||
默认录制进 `dataset` 目录,加参数可指定该目录。
|
||||
@@ -46,6 +66,8 @@ python tools/analytics/stamp_analytics.py -i dataset -c tools/config/mynteye/myn
|
||||
\includegraphics[width=0.6\textwidth,keepaspectratio]{stamp_analytics.png}
|
||||
\endlatexonly
|
||||
|
||||
> 如果用 ROS ,分析脚本也支持 ROS Bag 格式。
|
||||
|
||||
## 结语
|
||||
|
||||
如果用 ROS ,分析脚本也支持 ROS Bag 格式。关于 ROS 的录制和分析,请见 `tools/README.md` 。
|
||||
设备信息读写、校验码等更多工具的说明,请见 `tools/README.md` 。
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# SDK 指导 {#guides}
|
||||
|
||||
* @subpage guide_build_linux
|
||||
* @subpage guide_build_win
|
||||
* @subpage guide_samples
|
||||
* @subpage guide_tools
|
||||
* @subpage guide_log
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# MYNT EYE SDK {#mainpage}
|
||||
|
||||
* API 模块
|
||||
* <a class="el" href="annotated.html">API 类</a>
|
||||
* <a class="el" href="modules.html">API 模块</a>
|
||||
* \link enumerations 枚举类型\endlink
|
||||
* \link datatypes 数据类型\endlink
|
||||
* \link utils 工具函数\endlink
|
||||
* \link calibration 内参与外参\endlink
|
||||
* 设备说明
|
||||
* <span style="font-weight:bold">设备说明</span>
|
||||
* @subpage specs_data
|
||||
* @subpage specs_ctrl
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 控制 API 说明 {#spec_contorl_api}
|
||||
# 控制 API 说明 {#spec_control_api}
|
||||
|
||||
控制有两种实现方式,一是通过 UVC 标准协议,二是通过 UVC 拓展通道自定义协议。
|
||||
|
||||
@@ -8,21 +8,21 @@
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----- |
|
||||
| 增益 | gain | 2 | 24 | 0 | 48 | √ | 0x12 | 关闭自动曝光,手动设定的参数 |
|
||||
| 亮度 | brightness/exposure_time | 2 | 120 | 0 | 240 | √ | 0x14 | 关闭自动曝光,手动设定的参数 |
|
||||
| 对比度 | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | |
|
||||
| 对比度 | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | 关闭自动曝光,手动设定的参数 |
|
||||
|
||||
> UVC 标准协议实现的控制,有现成的 API 进行 Get & Set ,包括 Min, Max, Default 。
|
||||
|
||||
## 自定义协议
|
||||
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 通道地址 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----------- | :----- |
|
||||
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 0x0100 | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55,60} |
|
||||
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 0x0100 | 有效值为{100,200,250,333,500} |
|
||||
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0x0100 | 0:开启自动曝光; 1:关闭 |
|
||||
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
|
||||
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
|
||||
| 期望亮度 | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | 0x0100 | |
|
||||
| IR 控制 | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | 0x0100 | |
|
||||
| HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0x0100 | 0:10-bit;1:12-bit |
|
||||
| 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | 0x0200 | |
|
||||
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | 0x0200 | |
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----- |
|
||||
| 图像帧率 | frame_rate | 2 | 25 | 10 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55} |
|
||||
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 有效值为{100,200,250,333,500} |
|
||||
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0:开启自动曝光; 1:关闭 |
|
||||
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| 期望亮度 | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| IR 控制 | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | |
|
||||
| HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0:10-bit;1:12-bit |
|
||||
| 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# 拓展通道说明 {#spec_contorl_channel}
|
||||
# 拓展通道说明 {#spec_control_channel}
|
||||
|
||||
| 名称 | 字段 | 地址 | 带宽 | 说明 |
|
||||
| :----- | :----- | :----- | :----- | :----- |
|
||||
| 相机控制通道 | XU_CAM_CTRL_CHANNEL | 0x0100 | 3 | |
|
||||
| 半双工通道 | XU_HALF_DUPLEX_CHANNEL | 0x0200 | 20 | |
|
||||
| IMU 请求通道 | XU_IMUDATA_WRITE_CHANNEL | 0x0300 | 5 | |
|
||||
| IMU 响应通道 | XU_IMUDATA_READ_CHANNEL | 0x0400 | 2000 | |
|
||||
| 文件通道 | XU_FILE_CHANNEL | 0x0500 | 2000 | |
|
||||
| 相机控制通道 | XU_CAM_CTRL_CHANNEL | 1 | 3 | |
|
||||
| 半双工通道 | XU_HALF_DUPLEX_CHANNEL | 2 | 20 | |
|
||||
| IMU 请求通道 | XU_IMUDATA_WRITE_CHANNEL | 3 | 5 | |
|
||||
| IMU 响应通道 | XU_IMUDATA_READ_CHANNEL | 4 | 2000 | |
|
||||
| 文件通道 | XU_FILE_CHANNEL | 5 | 2000 | |
|
||||
|
||||
## 相机控制通道
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
## 半双工通道
|
||||
|
||||
半双工通道是那些仅需 Get 或 Set 的控制通道,如请求零漂矫正。
|
||||
半双工通道是那些仅需 Set 的控制通道,如请求零漂矫正。
|
||||
|
||||
## IMU 通道
|
||||
|
||||
@@ -25,18 +25,18 @@
|
||||
用来读写硬件信息、图像参数、 IMU 参数的通道。
|
||||
|
||||
| Name | Header | Size | File | Checksum |
|
||||
| :--- | :- | :--- | :--- | :-------- |
|
||||
| :--- | :----- | :--- | :--- | :-------- |
|
||||
| 字节数 | 1 | 2 | - | 1 |
|
||||
| 类型 | uint8_t | uint16_t | - | uint8_t |
|
||||
| 描述 | 标识 | 文件内容大小 | 文件内容 | 校验码(文件内容所有字节异或) |
|
||||
|
||||
| Header bit | Description |
|
||||
| :--------- | :---------- |
|
||||
| 0 | 0: get; 1: set |
|
||||
| 1~4 | 未定义 |
|
||||
| 5 | IMU 参数 |
|
||||
| 6 | 图像参数 |
|
||||
| 7 | 硬件信息 |
|
||||
| Header Bit Subscript | Description |
|
||||
| :------------------- | :---------- |
|
||||
| 0 | 硬件信息 |
|
||||
| 1 | 图像参数 |
|
||||
| 2 | IMU 参数 |
|
||||
| 3~6 | 未定义 |
|
||||
| 7 | 0: Get; 1: Set |
|
||||
|
||||
### 文件内容包
|
||||
|
||||
@@ -48,6 +48,6 @@
|
||||
|
||||
| File | ID | Max Size |
|
||||
| :--- | :- | :------- |
|
||||
| 硬件信息 | 0 | 256 |
|
||||
| 图像参数 | 1 | 256 |
|
||||
| IMU 参数 | 2 | 512 |
|
||||
| 硬件信息 | 1 | 250 |
|
||||
| 图像参数 | 2 | 250 |
|
||||
| IMU 参数 | 4 | 500 |
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
| :----- | :----- | :-------- | :-------------- | :----------------- | :-------- | :----- |
|
||||
| VID | vid | 0x04B4 | √ | × | 2 | |
|
||||
| PID | pid | 0x00F9 | √ | × | 2 | |
|
||||
| 设备名称 | name | MYNT-EYE-? | √ | √ | 16 | MYNT-EYE-S1000 |
|
||||
| 序列号 | serial_number | - | √ | √ | 16 | |
|
||||
| 固件版本 | firmware_version | - | √ | √ | 2 | major,minor |
|
||||
| 硬件版本 | hardware_version | - | × | √ | 3 | major,minor,flag |
|
||||
| 协议版本 | spec_version | - | × | √ | 2 | major,minor |
|
||||
| 镜头类型 | lens_type | - | × | √ | 4 | vendor(2),product(2) |
|
||||
| IMU 类型 | imu_type | - | × | √ | 4 | vendor(2),product(2) |
|
||||
| 基线长度 | nominal_baseline | - | × | √ | 2 | 单位 mm |
|
||||
| 设备名称 | name | MYNT-EYE-? | √ | √ Get | 16 | MYNT-EYE-S1000 |
|
||||
| 序列号 | serial_number | - | √ | √ Get | 16 | |
|
||||
| 固件版本 | firmware_version | - | √ | √ Get | 2 | major,minor |
|
||||
| 硬件版本 | hardware_version | - | × | √ Get | 3 | major,minor,flag |
|
||||
| 协议版本 | spec_version | - | × | √ Get | 2 | major,minor |
|
||||
| 镜头类型 | lens_type | - | × | √ Get/Set | 4 | vendor(2),product(2) ,未 Set 默认 0 |
|
||||
| IMU 类型 | imu_type | - | × | √ Get/Set | 4 | vendor(2),product(2) ,未 Set 默认 0 |
|
||||
| 基线长度 | nominal_baseline | - | × | √ Get/Set | 2 | 单位 mm ,未 set 默认 0 |
|
||||
|
||||
* 描述符获取:指通用 USB 设备信息,可用工具查看。
|
||||
* 拓展通道获取:指通过拓展通道(UVC Extension Unit)问硬件获取到的信息,需要读取。
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
## 图像数据包
|
||||
|
||||
| Name | Header | Size | FrameID | Timestamp | ExposureTime | Checksum |
|
||||
| :--- | :----- | :--- | :------ | :-------- | :----------- | :------- |
|
||||
| Name | Header | Size | Frame ID | Timestamp | Exposure Time | Checksum |
|
||||
| :--- | :----- | :--- | :------- | :-------- | :------------ | :------- |
|
||||
| 字节数 | 1 | 1 | 2 | 4 | 2 | 1 |
|
||||
| 类型 | uint8_t | uint8_t | uint16_t | uint32_t | uint16_t | uint8_t |
|
||||
| 描述 | 0x3B | 0x08 (数据内容大小) | 帧 ID | 时间戳 | 曝光时间 | 校验码(数据内容所有字节异或) |
|
||||
|
||||
* 数据包校验不过,会丢弃该帧。
|
||||
* 时间的单位精度为: 0.01 ms / 10 us 。
|
||||
* 时间单位的精度为: 0.01 ms / 10 us 。
|
||||
* 4 字节能表示的最大时间约是 11.9 小时,溢出后将重累计。
|
||||
* 时间累计是从上电时从开始,而不是从打开时开始。
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
| 畸变模型 | model | - | 1 | uint8_t; pinhole,... |
|
||||
| 畸变参数 | coeffs[5] | - | 40 | double; k1,k2,p1,p2,k3 |
|
||||
|
||||
> 图像内参不同分辨率会不同。如果多分辨率的话,就会有多个。
|
||||
> 图像分辨率不同,内参不同。多分辨率的话,需有多个内参。
|
||||
|
||||
## 图像外参
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ IMU 包/小包,是一组 IMU 数据。
|
||||
|
||||
### IMU 段
|
||||
|
||||
| Name | Offset | FrameID | Accelerometer | Temperature | Gyroscope |
|
||||
| :--- | :----- | :------ | :------------ | :---------- | :-------- |
|
||||
| Name | Offset | Frame ID | Accelerometer | Temperature | Gyroscope |
|
||||
| :--- | :----- | :------- | :------------ | :---------- | :-------- |
|
||||
| 字节数 | 2 | 2 | 6 | 2 | 6 |
|
||||
| 类型 | int16_t | uint16_t | int16_t * 3 | int16_t | int16_t * 3 |
|
||||
| Description | 相对基准时间戳的偏移量 | 图像帧 ID | 加速度计 x y z 三轴的值 | IMU 的温度 | 陀螺仪 x y z 三轴的值 |
|
||||
| 描述 | 相对基准时间戳的偏移量 | 图像帧 ID | 加速度计 x y z 三轴的值 | IMU 的温度 | 陀螺仪 x y z 三轴的值 |
|
||||
|
||||
* 加速度计和陀螺仪的计量值换算成物理值公式: **real = data * range / 0x10000** 。
|
||||
* 加速度计量程默认值为 **8 g** ,陀螺仪量程默认值为 **1000 deg/s^2** 。
|
||||
* 加速度计量程默认值为 **8 g** ,陀螺仪量程默认值为 **1000 deg/s** 。
|
||||
* 温度计量值换算成物理值公式: **real = data / ratio + offset** 。
|
||||
* ``ratio`` 默认值为 **326.8** , ``offset`` 默认值为 **25℃** 。
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 设备控制说明 {#specs_ctrl}
|
||||
|
||||
* @subpage spec_contorl_api
|
||||
* @subpage spec_contorl_channel
|
||||
* @subpage spec_control_api
|
||||
* @subpage spec_control_channel
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
#ifndef MYNTEYE_INTERNAL_CALLBACKS_H_ // NOLINT
|
||||
#define MYNTEYE_INTERNAL_CALLBACKS_H_
|
||||
// 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.
|
||||
#ifndef MYNTEYE_CALLBACKS_H_ // NOLINT
|
||||
#define MYNTEYE_CALLBACKS_H_
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
@@ -16,13 +29,23 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace device {
|
||||
|
||||
class Frame {
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Frame with raw data.
|
||||
*/
|
||||
class MYNTEYE_API Frame {
|
||||
public:
|
||||
using data_t = std::vector<std::uint8_t>;
|
||||
|
||||
/**
|
||||
* Construct the frame with StreamRequest and raw data.
|
||||
*/
|
||||
Frame(const StreamRequest &request, const void *data)
|
||||
: Frame(request.width, request.height, request.format, data) {}
|
||||
|
||||
/**
|
||||
* Construct the frame with stream info and raw data.
|
||||
*/
|
||||
Frame(
|
||||
std::uint16_t width, std::uint16_t height, Format format,
|
||||
const void *data)
|
||||
@@ -36,30 +59,37 @@ class Frame {
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the width. */
|
||||
std::uint16_t width() const {
|
||||
return width_;
|
||||
}
|
||||
|
||||
/** Get the height. */
|
||||
std::uint16_t height() const {
|
||||
return height_;
|
||||
}
|
||||
|
||||
/** Get the format. */
|
||||
Format format() const {
|
||||
return format_;
|
||||
}
|
||||
|
||||
/** Get the data. */
|
||||
std::uint8_t *data() {
|
||||
return data_.data();
|
||||
}
|
||||
|
||||
/** Get the const data. */
|
||||
const std::uint8_t *data() const {
|
||||
return data_.data();
|
||||
}
|
||||
|
||||
/** Get the size of data. */
|
||||
std::size_t size() const {
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
/** Clone a new frame. */
|
||||
Frame clone() const {
|
||||
Frame frame(width_, height_, format_, nullptr);
|
||||
std::copy(data_.begin(), data_.end(), frame.data_.begin());
|
||||
@@ -74,12 +104,23 @@ class Frame {
|
||||
data_t data_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Device stream data.
|
||||
*/
|
||||
struct MYNTEYE_API StreamData {
|
||||
/** ImgData. */
|
||||
std::shared_ptr<ImgData> img;
|
||||
/** Frame. */
|
||||
std::shared_ptr<Frame> frame;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Device motion data.
|
||||
*/
|
||||
struct MYNTEYE_API MotionData {
|
||||
/** ImuData. */
|
||||
std::shared_ptr<ImuData> imu;
|
||||
};
|
||||
|
||||
@@ -90,4 +131,4 @@ using MotionCallback = std::function<void(const MotionData &data)>;
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_INTERNAL_CALLBACKS_H_ NOLINT
|
||||
#endif // MYNTEYE_CALLBACKS_H_ NOLINT
|
||||
@@ -1,3 +1,16 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_GLOBAL_H_
|
||||
#define MYNTEYE_GLOBAL_H_
|
||||
#pragma once
|
||||
|
||||
@@ -1,19 +1,54 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_GLOG_INIT_H_ // NOLINT
|
||||
#define MYNTEYE_GLOG_INIT_H_
|
||||
#pragma once
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
/** Helper to init glog with args. */
|
||||
struct glog_init {
|
||||
glog_init(int /*argc*/, char *argv[]) {
|
||||
// FLAGS_logtostderr = true;
|
||||
FLAGS_alsologtostderr = true;
|
||||
/**
|
||||
* Init glog with args in constructor, and shutdown it in destructor.
|
||||
*/
|
||||
glog_init(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
|
||||
// Set whether log messages go to stderr instead of logfiles
|
||||
FLAGS_logtostderr = true;
|
||||
|
||||
// Set whether log messages go to stderr in addition to logfiles.
|
||||
// FLAGS_alsologtostderr = true;
|
||||
|
||||
// Set color messages logged to stderr (if supported by terminal).
|
||||
FLAGS_colorlogtostderr = true;
|
||||
|
||||
// Log suppression level: messages logged at a lower level than this
|
||||
// are suppressed.
|
||||
FLAGS_minloglevel = google::GLOG_INFO;
|
||||
|
||||
// If specified, logfiles are written into this directory instead of the
|
||||
// default logging directory.
|
||||
FLAGS_log_dir = ".";
|
||||
|
||||
// Sets the maximum log file size (in MB).
|
||||
FLAGS_max_log_size = 1024;
|
||||
|
||||
// Sets whether to avoid logging to the disk if the disk is full.
|
||||
FLAGS_stop_logging_if_full_disk = true;
|
||||
|
||||
// Show all VLOG(m) messages for m <= this.
|
||||
// FLAGS_v = 2;
|
||||
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_MYNTEYE_H_
|
||||
#define MYNTEYE_MYNTEYE_H_
|
||||
#pragma once
|
||||
@@ -45,4 +58,7 @@ MYNTEYE_API_VERSION_CHECK( \
|
||||
# define MYNTEYE_USE_NAMESPACE
|
||||
#endif
|
||||
|
||||
const char MYNTEYE_SDK_ROOT_DIR[] = "@MYNTEYE_SDK_ROOT_DIR@";
|
||||
const char MYNTEYE_SDK_INSTALL_DIR[] = "@MYNTEYE_SDK_INSTALL_DIR@";
|
||||
|
||||
#endif // MYNTEYE_MYNTEYE_H_
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_TYPES_H_ // NOLINT
|
||||
#define MYNTEYE_TYPES_H_
|
||||
#pragma once
|
||||
@@ -59,21 +72,21 @@ enum class Stream : std::uint8_t {
|
||||
* might provide.
|
||||
*/
|
||||
enum class Capabilities : std::uint8_t {
|
||||
/** Provices stereo stream */
|
||||
/** Provides stereo stream */
|
||||
STEREO,
|
||||
/** Provices color stream */
|
||||
/** Provides color stream */
|
||||
COLOR,
|
||||
/** Provices depth stream */
|
||||
/** Provides depth stream */
|
||||
DEPTH,
|
||||
/** Provices point cloud stream */
|
||||
/** Provides point cloud stream */
|
||||
POINTS,
|
||||
/** Provices fisheye stream */
|
||||
/** Provides fisheye stream */
|
||||
FISHEYE,
|
||||
/** Provices infrared stream */
|
||||
/** Provides infrared stream */
|
||||
INFRARED,
|
||||
/** Provices second infrared stream */
|
||||
/** Provides second infrared stream */
|
||||
INFRARED2,
|
||||
/** Provices IMU (accelerometer, gyroscope) data */
|
||||
/** Provides IMU (accelerometer, gyroscope) data */
|
||||
IMU,
|
||||
/** Last guard */
|
||||
LAST
|
||||
@@ -110,15 +123,35 @@ enum class Info : std::uint8_t {
|
||||
* @brief Camera control options define general configuration controls.
|
||||
*/
|
||||
enum class Option : std::uint8_t {
|
||||
/** Image gain, setting it if manual-exposure */
|
||||
/**
|
||||
* Image gain, valid if manual-exposure
|
||||
*
|
||||
* range: [0,48], default: 24
|
||||
*/
|
||||
GAIN,
|
||||
/** Image brightness, setting it if manual-exposure */
|
||||
/**
|
||||
* Image brightness, valid if manual-exposure
|
||||
*
|
||||
* range: [0,240], default: 120
|
||||
*/
|
||||
BRIGHTNESS,
|
||||
/** Image contrast */
|
||||
/**
|
||||
* Image contrast, valid if manual-exposure
|
||||
*
|
||||
* range: [0,255], default: 127
|
||||
*/
|
||||
CONTRAST,
|
||||
/** Image frame rate */
|
||||
/**
|
||||
* Image frame rate, must set IMU_FREQUENCY together
|
||||
*
|
||||
* values: {10,15,20,25,30,35,40,45,50,55}, default: 25
|
||||
*/
|
||||
FRAME_RATE,
|
||||
/** IMU frequency */
|
||||
/**
|
||||
* IMU frequency, must set FRAME_RATE together
|
||||
*
|
||||
* values: {100,200,250,333,500}, default: 200
|
||||
*/
|
||||
IMU_FREQUENCY,
|
||||
/**
|
||||
* Exposure mode
|
||||
@@ -127,13 +160,29 @@ enum class Option : std::uint8_t {
|
||||
* 1: disable auto-exposure (manual-exposure)
|
||||
*/
|
||||
EXPOSURE_MODE,
|
||||
/** Max gain, setting it if auto-exposure */
|
||||
/**
|
||||
* Max gain, valid if auto-exposure
|
||||
*
|
||||
* range: [0,48], default: 48
|
||||
*/
|
||||
MAX_GAIN,
|
||||
/** Max exposure time, setting it if auto-exposure */
|
||||
/**
|
||||
* Max exposure time, valid if auto-exposure
|
||||
*
|
||||
* range: [0,240], default: 240
|
||||
*/
|
||||
MAX_EXPOSURE_TIME,
|
||||
/** Desired brightness */
|
||||
/**
|
||||
* Desired brightness, valid if auto-exposure
|
||||
*
|
||||
* range: [0,255], default: 192
|
||||
*/
|
||||
DESIRED_BRIGHTNESS,
|
||||
/** IR control */
|
||||
/**
|
||||
* IR control
|
||||
*
|
||||
* range: [0,160], default: 0
|
||||
*/
|
||||
IR_CONTROL,
|
||||
/**
|
||||
* HDR mode
|
||||
@@ -165,8 +214,21 @@ enum class Source : std::uint8_t {
|
||||
LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup enumerations
|
||||
* @brief Add-Ons are peripheral modules of our hardware.
|
||||
*/
|
||||
enum class AddOns : std::uint8_t {
|
||||
/** Infrared */
|
||||
INFRARED,
|
||||
/** Second infrared */
|
||||
INFRARED2,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
|
||||
#define MYNTEYE_ENUM_HELPERS(TYPE) \
|
||||
const char *to_string(const TYPE &value); \
|
||||
MYNTEYE_API const char *to_string(const TYPE &value); \
|
||||
inline bool is_valid(const TYPE &value) { \
|
||||
using utype = std::underlying_type<TYPE>::type; \
|
||||
utype val = static_cast<utype>(value); \
|
||||
@@ -187,6 +249,7 @@ MYNTEYE_ENUM_HELPERS(Capabilities)
|
||||
MYNTEYE_ENUM_HELPERS(Info)
|
||||
MYNTEYE_ENUM_HELPERS(Option)
|
||||
MYNTEYE_ENUM_HELPERS(Source)
|
||||
MYNTEYE_ENUM_HELPERS(AddOns)
|
||||
|
||||
#undef MYNTEYE_ENUM_HELPERS
|
||||
|
||||
@@ -209,25 +272,25 @@ enum class Format : std::uint32_t {
|
||||
|
||||
#undef MYNTEYE_FOURCC
|
||||
|
||||
const char *to_string(const Format &value);
|
||||
MYNTEYE_API const char *to_string(const Format &value);
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &os, const Format &value) {
|
||||
return os << to_string(value);
|
||||
}
|
||||
|
||||
std::size_t bytes_per_pixel(const Format &value);
|
||||
MYNTEYE_API std::size_t bytes_per_pixel(const Format &value);
|
||||
|
||||
/**
|
||||
* Stream request.
|
||||
*/
|
||||
struct MYNTEYE_API StreamRequest {
|
||||
/** width in pixels */
|
||||
/** Stream width in pixels */
|
||||
std::uint16_t width;
|
||||
/** height in pixels */
|
||||
/** Stream height in pixels */
|
||||
std::uint16_t height;
|
||||
/** stream pixel format */
|
||||
/** Stream pixel format */
|
||||
Format format;
|
||||
/** frames per second (unused) */
|
||||
/** Stream frames per second (unused) */
|
||||
std::uint16_t fps;
|
||||
|
||||
bool operator==(const StreamRequest &other) const {
|
||||
@@ -239,6 +302,7 @@ struct MYNTEYE_API StreamRequest {
|
||||
}
|
||||
};
|
||||
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
|
||||
|
||||
/**
|
||||
@@ -248,36 +312,42 @@ std::ostream &operator<<(std::ostream &os, const StreamRequest &request);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* Image intrinsics.
|
||||
* Stream intrinsics,
|
||||
*/
|
||||
struct MYNTEYE_API ImgIntrinsics {
|
||||
/** width of the image in pixels */
|
||||
struct MYNTEYE_API Intrinsics {
|
||||
/** The width of the image in pixels */
|
||||
std::uint16_t width;
|
||||
/** height of the image in pixels */
|
||||
/** The height of the image in pixels */
|
||||
std::uint16_t height;
|
||||
/** focal length of the image plane, as a multiple of pixel width */
|
||||
/** The focal length of the image plane, as a multiple of pixel width */
|
||||
double fx;
|
||||
/** focal length of the image plane, as a multiple of pixel height */
|
||||
/** The focal length of the image plane, as a multiple of pixel height */
|
||||
double fy;
|
||||
/** horizontal coordinate of the principal point of the image */
|
||||
/** The horizontal coordinate of the principal point of the image */
|
||||
double cx;
|
||||
/** vertical coordinate of the principal point of the image */
|
||||
/** The vertical coordinate of the principal point of the image */
|
||||
double cy;
|
||||
/** distortion model of the image */
|
||||
/** The distortion model of the image */
|
||||
std::uint8_t model;
|
||||
/** distortion coefficients: k1,k2,p1,p2,k3 */
|
||||
/** The distortion coefficients: k1,k2,p1,p2,k3 */
|
||||
double coeffs[5];
|
||||
};
|
||||
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const Intrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU sensor intrinsics: scale, drift and variances.
|
||||
* IMU intrinsics: scale, drift and variances.
|
||||
*/
|
||||
struct MYNTEYE_API ImuSensorIntrinsics {
|
||||
struct MYNTEYE_API ImuIntrinsics {
|
||||
/**
|
||||
* Scale X cross axis cross axis
|
||||
* cross axis Scale Y cross axis
|
||||
* cross axis cross axis Scale Z
|
||||
* Scale matrix.
|
||||
* \code
|
||||
* Scale X cross axis cross axis
|
||||
* cross axis Scale Y cross axis
|
||||
* cross axis cross axis Scale Z
|
||||
* \endcode
|
||||
*/
|
||||
double scale[3][3];
|
||||
/* Zero-drift: X, Y, Z */
|
||||
@@ -289,39 +359,43 @@ struct MYNTEYE_API ImuSensorIntrinsics {
|
||||
double bias[3];
|
||||
};
|
||||
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const ImuIntrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU intrinsics, including accelerometer and gyroscope.
|
||||
* Motion intrinsics, including accelerometer and gyroscope.
|
||||
*/
|
||||
struct MYNTEYE_API ImuIntrinsics {
|
||||
ImuSensorIntrinsics accel;
|
||||
ImuSensorIntrinsics gyro;
|
||||
struct MYNTEYE_API MotionIntrinsics {
|
||||
ImuIntrinsics accel; /**< Accelerometer intrinsics */
|
||||
ImuIntrinsics gyro; /**< Gyroscope intrinsics */
|
||||
};
|
||||
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const MotionIntrinsics &in);
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* Extrinsics, represent how the different datas are connected.
|
||||
*/
|
||||
struct MYNTEYE_API Extrinsics {
|
||||
double rotation[3][3]; /**< rotation matrix */
|
||||
double translation[3]; /**< translation vector */
|
||||
double rotation[3][3]; /**< Rotation matrix */
|
||||
double translation[3]; /**< Translation vector */
|
||||
|
||||
/**
|
||||
* Inverse this extrinsics.
|
||||
* @return the inversed extrinsics.
|
||||
*/
|
||||
Extrinsics Inverse() const {
|
||||
return {{{rotation[0][0], rotation[1][0], rotation[2][0]},
|
||||
{rotation[0][1], rotation[1][1], rotation[2][1]},
|
||||
{rotation[0][2], rotation[1][2], rotation[2][2]}},
|
||||
{-translation[0], -translation[1], -translation[2]}};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* Image extrinsics.
|
||||
*/
|
||||
struct MYNTEYE_API ImgExtrinsics {
|
||||
Extrinsics left_to_right;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup calibration
|
||||
* IMU extrinsics.
|
||||
*/
|
||||
struct MYNTEYE_API ImuExtrinsics {
|
||||
Extrinsics left_to_imu;
|
||||
};
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
|
||||
|
||||
/**
|
||||
* @defgroup datatypes Datatypes
|
||||
@@ -337,7 +411,7 @@ struct MYNTEYE_API ImgData {
|
||||
std::uint16_t frame_id;
|
||||
/** Image timestamp in 0.01ms */
|
||||
std::uint32_t timestamp;
|
||||
/** Image exposure time in 0.01ms */
|
||||
/** Image exposure time, virtual value in [1, 480] */
|
||||
std::uint16_t exposure_time;
|
||||
|
||||
void Reset() {
|
||||
@@ -396,11 +470,17 @@ struct MYNTEYE_API ImuData {
|
||||
* Option info.
|
||||
*/
|
||||
struct MYNTEYE_API OptionInfo {
|
||||
/** Minimum value */
|
||||
std::int32_t min;
|
||||
/** Maximum value */
|
||||
std::int32_t max;
|
||||
/** Default value */
|
||||
std::int32_t def;
|
||||
};
|
||||
|
||||
MYNTEYE_API
|
||||
std::ostream &operator<<(std::ostream &os, const OptionInfo &info);
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_TYPES_H_ NOLINT
|
||||
|
||||
62
include/mynteye/utils.h
Normal file
62
include/mynteye/utils.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_UTILS_H_ // NOLINT
|
||||
#define MYNTEYE_UTILS_H_
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
/**
|
||||
* @defgroup utils Utiliities
|
||||
*/
|
||||
|
||||
class Device;
|
||||
|
||||
namespace device {
|
||||
|
||||
/**
|
||||
* @ingroup utils
|
||||
*
|
||||
* Detecting MYNT EYE devices and prompt user to select one.
|
||||
*
|
||||
* @return the selected device, or `nullptr` if none.
|
||||
*/
|
||||
MYNTEYE_API std::shared_ptr<Device> select();
|
||||
|
||||
} // namespace device
|
||||
|
||||
namespace utils {
|
||||
|
||||
/**
|
||||
* @ingroup utils
|
||||
*
|
||||
* Get real exposure time in ms from virtual value, according to its frame rate.
|
||||
*
|
||||
* @param frame_rate the frame rate of the device.
|
||||
* @param exposure_time the virtual exposure time.
|
||||
* @return the real exposure time in ms, or the virtual value if frame rate is
|
||||
* invalid.
|
||||
*/
|
||||
MYNTEYE_API float get_real_exposure_time(
|
||||
std::int32_t frame_rate, std::uint16_t exposure_time);
|
||||
|
||||
} // namespace utils
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_UTILS_H_ NOLINT
|
||||
@@ -1,3 +1,17 @@
|
||||
# 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.
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/mynteye-targets.cmake")
|
||||
|
||||
@@ -1,13 +1,39 @@
|
||||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(mynteye_samples VERSION 2.0.0 LANGUAGES C CXX)
|
||||
|
||||
get_filename_component(PRO_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
|
||||
|
||||
include(${PRO_DIR}/cmake/Common.cmake)
|
||||
include(${PRO_DIR}/cmake/Utils.cmake)
|
||||
|
||||
# options
|
||||
|
||||
include(${PRO_DIR}/cmake/Option.cmake)
|
||||
|
||||
# flags
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
if(OS_WIN)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
endif()
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectCXX11.cmake)
|
||||
|
||||
@@ -29,17 +55,20 @@ LIST(APPEND CMAKE_PREFIX_PATH ${PRO_DIR}/_install/lib/cmake)
|
||||
find_package(mynteye REQUIRED)
|
||||
message(STATUS "Found mynteye: ${mynteye_VERSION}")
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
message(STATUS "Found OpenCV: ${OpenCV_VERSION}")
|
||||
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
|
||||
# targets
|
||||
|
||||
include(${PRO_DIR}/cmake/Common.cmake)
|
||||
|
||||
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/_output")
|
||||
|
||||
# samples above api layer
|
||||
|
||||
if(WITH_API)
|
||||
add_subdirectory(api)
|
||||
endif()
|
||||
|
||||
# samples above device layer
|
||||
|
||||
add_subdirectory(device)
|
||||
@@ -47,3 +76,9 @@ add_subdirectory(device)
|
||||
# samples above uvc layer
|
||||
|
||||
add_subdirectory(uvc)
|
||||
|
||||
# tutorials
|
||||
|
||||
if(WITH_API)
|
||||
add_subdirectory(tutorials)
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# Samples for MYNT® EYE cameras
|
||||
|
||||
## Prerequisites
|
||||
|
||||
[OpenCV](https://opencv.org/),
|
||||
|
||||
```bash
|
||||
# Linux, macOS
|
||||
export OpenCV_DIR=~/opencv
|
||||
|
||||
# Windows
|
||||
set OpenCV_DIR=C:\opencv
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
@@ -9,6 +21,20 @@ make samples
|
||||
|
||||
## Run
|
||||
|
||||
Camera with api layer,
|
||||
|
||||
```bash
|
||||
./samples/_output/bin/device/camera_d
|
||||
./samples/_output/bin/api/camera_a
|
||||
|
||||
# Windows
|
||||
.\samples\_output\bin\api\camera_a.bat
|
||||
```
|
||||
|
||||
Camera with device layer,
|
||||
|
||||
```bash
|
||||
./samples/_output/bin/device/camera_d
|
||||
|
||||
# Windows
|
||||
.\samples\_output\bin\device\camera_d.bat
|
||||
```
|
||||
|
||||
41
samples/api/CMakeLists.txt
Normal file
41
samples/api/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
|
||||
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
set_outdir(
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
"${OUT_DIR}/bin/${DIR_NAME}"
|
||||
)
|
||||
|
||||
## camera_a
|
||||
|
||||
make_executable(camera_a
|
||||
SRCS camera.cc
|
||||
LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
)
|
||||
|
||||
## get_depth_with_region
|
||||
|
||||
if(OpenCV_VERSION VERSION_LESS 4.0)
|
||||
|
||||
make_executable(get_depth_with_region
|
||||
SRCS get_depth_with_region.cc
|
||||
LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
)
|
||||
|
||||
endif()
|
||||
144
samples/api/camera.cc
Normal file
144
samples/api/camera.cc
Normal file
@@ -0,0 +1,144 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
#include "mynteye/times.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// api->SetOptionValue(Option::FRAME_RATE, 25);
|
||||
// api->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
api->LogOptionInfos();
|
||||
|
||||
std::size_t left_count = 0;
|
||||
api->SetStreamCallback(
|
||||
Stream::LEFT, [&left_count](const api::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++left_count;
|
||||
VLOG(2) << Stream::LEFT << ", count: " << left_count;
|
||||
VLOG(2) << " frame_id: " << data.img->frame_id
|
||||
<< ", timestamp: " << data.img->timestamp
|
||||
<< ", exposure_time: " << data.img->exposure_time;
|
||||
});
|
||||
std::size_t right_count = 0;
|
||||
api->SetStreamCallback(
|
||||
Stream::RIGHT, [&right_count](const api::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++right_count;
|
||||
VLOG(2) << Stream::RIGHT << ", count: " << right_count;
|
||||
VLOG(2) << " frame_id: " << data.img->frame_id
|
||||
<< ", timestamp: " << data.img->timestamp
|
||||
<< ", exposure_time: " << data.img->exposure_time;
|
||||
});
|
||||
|
||||
std::size_t imu_count = 0;
|
||||
api->SetMotionCallback([&imu_count](const api::MotionData &data) {
|
||||
CHECK_NOTNULL(data.imu);
|
||||
++imu_count;
|
||||
VLOG(2) << "Imu count: " << imu_count;
|
||||
VLOG(2) << " frame_id: " << data.imu->frame_id
|
||||
<< ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
<< ", gyro_x: " << data.imu->gyro[0]
|
||||
<< ", gyro_y: " << data.imu->gyro[1]
|
||||
<< ", gyro_z: " << data.imu->gyro[2]
|
||||
<< ", temperature: " << data.imu->temperature;
|
||||
});
|
||||
|
||||
// api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||
// api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
// Enable this will cache the motion datas until you get them.
|
||||
api->EnableMotionDatas();
|
||||
api->Start(Source::ALL);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("disparity");
|
||||
cv::namedWindow("depth");
|
||||
|
||||
std::size_t motion_count = 0;
|
||||
auto &&time_beg = times::now();
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
// auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
// auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT_RECTIFIED);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT_RECTIFIED);
|
||||
if (!left_data.frame.empty() && !right_data.frame.empty()) {
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
}
|
||||
|
||||
auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
if (!disp_data.frame.empty()) {
|
||||
cv::imshow("disparity", disp_data.frame); // CV_8UC1
|
||||
}
|
||||
|
||||
auto &&depth_data = api->GetStreamData(Stream::DEPTH);
|
||||
if (!depth_data.frame.empty()) {
|
||||
cv::imshow("depth", depth_data.frame); // CV_16UC1
|
||||
}
|
||||
|
||||
auto &&motion_datas = api->GetMotionDatas();
|
||||
motion_count += motion_datas.size();
|
||||
for (auto &&data : motion_datas) {
|
||||
LOG(INFO) << "Imu frame_id: " << data.imu->frame_id
|
||||
<< ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
<< ", gyro_x: " << data.imu->gyro[0]
|
||||
<< ", gyro_y: " << data.imu->gyro[1]
|
||||
<< ", gyro_z: " << data.imu->gyro[2]
|
||||
<< ", temperature: " << data.imu->temperature;
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto &&time_end = times::now();
|
||||
|
||||
api->Stop(Source::ALL);
|
||||
|
||||
float elapsed_ms =
|
||||
times::count<times::microseconds>(time_end - time_beg) * 0.001f;
|
||||
LOG(INFO) << "Time beg: " << times::to_local_string(time_beg)
|
||||
<< ", end: " << times::to_local_string(time_end)
|
||||
<< ", cost: " << elapsed_ms << "ms";
|
||||
LOG(INFO) << "Left count: " << left_count
|
||||
<< ", fps: " << (1000.f * left_count / elapsed_ms);
|
||||
LOG(INFO) << "Right count: " << right_count
|
||||
<< ", fps: " << (1000.f * right_count / elapsed_ms);
|
||||
LOG(INFO) << "Imu count: " << imu_count
|
||||
<< ", hz: " << (1000.f * imu_count / elapsed_ms);
|
||||
// LOG(INFO) << "Motion count: " << motion_count
|
||||
// << ", hz: " << (1000.f * motion_count / elapsed_ms);
|
||||
return 0;
|
||||
}
|
||||
224
samples/api/get_depth_with_region.cc
Normal file
224
samples/api/get_depth_with_region.cc
Normal file
@@ -0,0 +1,224 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class DepthRegion {
|
||||
public:
|
||||
explicit DepthRegion(std::uint32_t n)
|
||||
: n_(std::move(n)), show_(false), selected_(false), point_(0, 0) {}
|
||||
|
||||
~DepthRegion() = default;
|
||||
|
||||
/**
|
||||
* 鼠标事件:默认不选中区域,随鼠标移动而显示。单击后,则会选中区域来显示。你可以再单击已选中区域或双击未选中区域,取消选中。
|
||||
*/
|
||||
void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
|
||||
UNUSED(flags)
|
||||
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
|
||||
return;
|
||||
}
|
||||
show_ = true;
|
||||
|
||||
if (event == CV_EVENT_MOUSEMOVE) {
|
||||
if (!selected_) {
|
||||
point_.x = x;
|
||||
point_.y = y;
|
||||
}
|
||||
} else if (event == CV_EVENT_LBUTTONDOWN) {
|
||||
if (selected_) {
|
||||
if (x >= static_cast<int>(point_.x - n_) &&
|
||||
x <= static_cast<int>(point_.x + n_) &&
|
||||
y >= static_cast<int>(point_.y - n_) &&
|
||||
y <= static_cast<int>(point_.y + n_)) {
|
||||
selected_ = false;
|
||||
}
|
||||
} else {
|
||||
selected_ = true;
|
||||
}
|
||||
point_.x = x;
|
||||
point_.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ShowElems(
|
||||
const cv::Mat &depth,
|
||||
std::function<std::string(const T &elem)> elem2string,
|
||||
int elem_space = 40,
|
||||
std::function<std::string(
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n)>
|
||||
getinfo = nullptr) {
|
||||
if (!show_)
|
||||
return;
|
||||
|
||||
int space = std::move(elem_space);
|
||||
int n = 2 * n_ + 1;
|
||||
cv::Mat im(space * n, space * n, CV_8UC3, cv::Scalar(255, 255, 255));
|
||||
|
||||
int x, y;
|
||||
std::string str;
|
||||
int baseline = 0;
|
||||
for (int i = -n_; i <= n; ++i) {
|
||||
x = point_.x + i;
|
||||
if (x < 0 || x >= depth.cols)
|
||||
continue;
|
||||
for (int j = -n_; j <= n; ++j) {
|
||||
y = point_.y + j;
|
||||
if (y < 0 || y >= depth.rows)
|
||||
continue;
|
||||
|
||||
str = elem2string(depth.at<T>(y, x));
|
||||
|
||||
cv::Scalar color(0, 0, 0);
|
||||
if (i == 0 && j == 0)
|
||||
color = cv::Scalar(0, 0, 255);
|
||||
|
||||
cv::Size sz =
|
||||
cv::getTextSize(str, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline);
|
||||
|
||||
cv::putText(
|
||||
im, str, cv::Point(
|
||||
(i + n_) * space + (space - sz.width) / 2,
|
||||
(j + n_) * space + (space + sz.height) / 2),
|
||||
cv::FONT_HERSHEY_PLAIN, 1, color, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (getinfo) {
|
||||
std::string info = getinfo(depth, point_, n_);
|
||||
if (!info.empty()) {
|
||||
cv::Size sz =
|
||||
cv::getTextSize(info, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline);
|
||||
|
||||
cv::putText(
|
||||
im, info, cv::Point(5, 5 + sz.height), cv::FONT_HERSHEY_PLAIN, 1,
|
||||
cv::Scalar(255, 0, 255), 1);
|
||||
}
|
||||
}
|
||||
|
||||
cv::imshow("region", im);
|
||||
}
|
||||
|
||||
void DrawRect(cv::Mat &image) { // NOLINT
|
||||
if (!show_)
|
||||
return;
|
||||
std::uint32_t n = (n_ > 1) ? n_ : 1;
|
||||
n += 1; // outside the region
|
||||
cv::rectangle(
|
||||
image, cv::Point(point_.x - n, point_.y - n),
|
||||
cv::Point(point_.x + n, point_.y + n),
|
||||
selected_ ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 0, 255), 1);
|
||||
}
|
||||
|
||||
private:
|
||||
std::uint32_t n_;
|
||||
bool show_;
|
||||
bool selected_;
|
||||
cv::Point point_;
|
||||
};
|
||||
|
||||
void OnDepthMouseCallback(int event, int x, int y, int flags, void *userdata) {
|
||||
DepthRegion *region = reinterpret_cast<DepthRegion *>(userdata);
|
||||
region->OnMouse(event, x, y, flags);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("depth");
|
||||
cv::namedWindow("region");
|
||||
|
||||
DepthRegion depth_region(3);
|
||||
auto depth_info = [](
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
|
||||
UNUSED(depth)
|
||||
std::ostringstream os;
|
||||
os << "depth pos: [" << point.y << ", " << point.x << "]"
|
||||
<< "±" << n << ", unit: mm";
|
||||
return os.str();
|
||||
};
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
auto &&depth_data = api->GetStreamData(Stream::DEPTH);
|
||||
if (!disp_data.frame.empty() && !depth_data.frame.empty()) {
|
||||
// Show disparity instead of depth, but show depth values in region.
|
||||
auto &&depth_frame = disp_data.frame;
|
||||
|
||||
#ifdef USE_OPENCV3
|
||||
// ColormapTypes
|
||||
// http://docs.opencv.org/master/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65
|
||||
cv::applyColorMap(depth_frame, depth_frame, cv::COLORMAP_JET);
|
||||
#endif
|
||||
|
||||
cv::setMouseCallback("depth", OnDepthMouseCallback, &depth_region);
|
||||
// Note: DrawRect will change some depth values to show the rect.
|
||||
depth_region.DrawRect(depth_frame);
|
||||
|
||||
cv::imshow("depth", depth_frame);
|
||||
|
||||
depth_region.ShowElems<ushort>(
|
||||
depth_data.frame,
|
||||
[](const ushort &elem) {
|
||||
if (elem >= 10000) {
|
||||
// Filter errors, or limit to valid range.
|
||||
//
|
||||
// reprojectImageTo3D(), missing values will set to 10000
|
||||
// https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga1bc1152bd57d63bc524204f21fde6e02
|
||||
return std::string("invalid");
|
||||
}
|
||||
return std::to_string(elem);
|
||||
},
|
||||
80, depth_info);
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,3 +1,17 @@
|
||||
# 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.
|
||||
|
||||
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
set_outdir(
|
||||
@@ -6,17 +20,10 @@ set_outdir(
|
||||
"${OUT_DIR}/bin/${DIR_NAME}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PRO_DIR}/src
|
||||
)
|
||||
|
||||
## camera_d
|
||||
|
||||
add_executable(camera_d camera.cc)
|
||||
target_link_libraries(camera_d mynteye ${OpenCV_LIBS})
|
||||
|
||||
if(OS_WIN)
|
||||
target_compile_definitions(camera_d
|
||||
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
)
|
||||
endif()
|
||||
make_executable(camera_d
|
||||
SRCS camera.cc
|
||||
LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
)
|
||||
|
||||
@@ -1,50 +1,34 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "mynteye/glog_init.h"
|
||||
|
||||
#include "device/context.h"
|
||||
#include "device/device.h"
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
#include "internal/times.h"
|
||||
#include "mynteye/times.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
glog_init _(argc, argv);
|
||||
|
||||
LOG(INFO) << "Detecting MYNT EYE devices";
|
||||
Context context;
|
||||
auto &&devices = context.devices();
|
||||
|
||||
size_t n = devices.size();
|
||||
LOG_IF(FATAL, n <= 0) << "No MYNT EYE devices :(";
|
||||
|
||||
LOG(INFO) << "MYNT EYE devices:";
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
auto &&device = devices[i];
|
||||
auto &&name = device->GetInfo(Info::DEVICE_NAME);
|
||||
LOG(INFO) << " index: " << i << ", name: " << name;
|
||||
}
|
||||
|
||||
std::shared_ptr<Device> device = nullptr;
|
||||
if (n <= 1) {
|
||||
device = devices[0];
|
||||
LOG(INFO) << "Only one MYNT EYE device, select index: 0";
|
||||
} else {
|
||||
while (true) {
|
||||
size_t i;
|
||||
LOG(INFO) << "There are " << n << " MYNT EYE devices, select index: ";
|
||||
std::cin >> i;
|
||||
if (i >= n) {
|
||||
LOG(WARNING) << "Index out of range :(";
|
||||
continue;
|
||||
}
|
||||
device = devices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
/*
|
||||
{ // auto-exposure
|
||||
device->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
|
||||
144
samples/tutorials/CMakeLists.txt
Normal file
144
samples/tutorials/CMakeLists.txt
Normal file
@@ -0,0 +1,144 @@
|
||||
# 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.
|
||||
|
||||
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
set_outdir(
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
"${OUT_DIR}/bin/${DIR_NAME}"
|
||||
)
|
||||
|
||||
# make_executable2(NAME
|
||||
# [SRCS src1 src2 ...]
|
||||
# [WITH_OPENCV]
|
||||
# [WITH_PCL])
|
||||
macro(make_executable2 NAME)
|
||||
set(options WITH_OPENCV WITH_PCL)
|
||||
set(oneValueArgs)
|
||||
set(multiValueArgs SRCS)
|
||||
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||
"${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(__link_libs mynteye)
|
||||
set(__dll_search_paths ${PRO_DIR}/_install/bin)
|
||||
if(THIS_WITH_OPENCV)
|
||||
list(APPEND __link_libs ${OpenCV_LIBS})
|
||||
list(APPEND __dll_search_paths ${OpenCV_LIB_SEARCH_PATH})
|
||||
endif()
|
||||
if(THIS_WITH_PCL)
|
||||
list(APPEND __link_libs ${PCL_LIBRARIES})
|
||||
#list(APPEND __link_libs pcl::pcl)
|
||||
list(APPEND __dll_search_paths ${PCL_LIB_SEARCH_PATH})
|
||||
endif()
|
||||
|
||||
add_executable(${NAME} ${THIS_SRCS})
|
||||
target_link_libraries(${NAME} ${__link_libs})
|
||||
target_create_scripts(${NAME} DLL_SEARCH_PATHS ${__dll_search_paths})
|
||||
|
||||
if(THIS_WITH_PCL)
|
||||
target_include_directories(${NAME} PRIVATE ${PCL_INCLUDE_DIRS})
|
||||
#target_compile_definitions(${NAME} PRIVATE ${PCL_DEFINITIONS})
|
||||
#target_compile_options(${NAME} PRIVATE ${PCL_COMPILE_OPTIONS})
|
||||
endif()
|
||||
if(OS_WIN)
|
||||
target_compile_definitions(${NAME}
|
||||
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# packages
|
||||
|
||||
# If you install PCL to different directory, please set CMAKE_PREFIX_PATH to find it.
|
||||
#LIST(APPEND CMAKE_PREFIX_PATH /usr/local/share)
|
||||
find_package(PCL)
|
||||
if(PCL_FOUND)
|
||||
message(STATUS "Found PCL: ${PCL_VERSION}")
|
||||
|
||||
#message(STATUS "PCL_LIBRARIES: ${PCL_LIBRARIES}")
|
||||
#message(STATUS "PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
|
||||
#message(STATUS "PCL_LIBRARY_DIRS: ${PCL_LIBRARY_DIRS}")
|
||||
#message(STATUS "PCL_DEFINITIONS: ${PCL_DEFINITIONS}")
|
||||
#message(STATUS "PCL_COMPILE_OPTIONS: ${PCL_COMPILE_OPTIONS}")
|
||||
|
||||
if(OS_WIN)
|
||||
get_filename_component(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}/../bin" ABSOLUTE)
|
||||
else()
|
||||
set(PCL_LIB_SEARCH_PATH "${PCL_LIBRARY_DIRS}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "PCL not found :(")
|
||||
endif()
|
||||
|
||||
# beginner level
|
||||
|
||||
## data
|
||||
|
||||
make_executable2(get_device_info SRCS data/get_device_info.cc WITH_OPENCV)
|
||||
make_executable2(get_img_params SRCS data/get_img_params.cc WITH_OPENCV)
|
||||
make_executable2(get_imu_params SRCS data/get_imu_params.cc WITH_OPENCV)
|
||||
|
||||
make_executable2(get_stereo SRCS data/get_stereo.cc WITH_OPENCV)
|
||||
make_executable2(get_stereo_rectified SRCS data/get_stereo_rectified.cc WITH_OPENCV)
|
||||
make_executable2(get_disparity SRCS data/get_disparity.cc WITH_OPENCV)
|
||||
make_executable2(get_depth SRCS data/get_depth.cc WITH_OPENCV)
|
||||
if(PCL_FOUND)
|
||||
make_executable2(get_points
|
||||
SRCS data/get_points.cc util/pc_viewer.cc
|
||||
WITH_OPENCV WITH_PCL
|
||||
)
|
||||
endif()
|
||||
make_executable2(get_imu SRCS data/get_imu.cc util/cv_painter.cc WITH_OPENCV)
|
||||
make_executable2(get_from_callbacks
|
||||
SRCS data/get_from_callbacks.cc util/cv_painter.cc
|
||||
WITH_OPENCV
|
||||
)
|
||||
make_executable2(get_with_plugin SRCS data/get_with_plugin.cc WITH_OPENCV)
|
||||
|
||||
## control
|
||||
|
||||
make_executable2(ctrl_framerate SRCS control/framerate.cc WITH_OPENCV)
|
||||
make_executable2(ctrl_auto_exposure
|
||||
SRCS control/auto_exposure.cc util/cv_painter.cc
|
||||
WITH_OPENCV
|
||||
)
|
||||
make_executable2(ctrl_manual_exposure
|
||||
SRCS control/manual_exposure.cc util/cv_painter.cc
|
||||
WITH_OPENCV
|
||||
)
|
||||
make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV)
|
||||
|
||||
# intermediate level
|
||||
|
||||
make_executable2(get_all_device_info SRCS intermediate/get_all_device_info.cc WITH_OPENCV)
|
||||
|
||||
if(PCL_FOUND)
|
||||
|
||||
if(OpenCV_VERSION VERSION_LESS 4.0)
|
||||
|
||||
make_executable2(get_depth_and_points
|
||||
SRCS intermediate/get_depth_and_points.cc util/cv_painter.cc util/pc_viewer.cc
|
||||
WITH_OPENCV WITH_PCL
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# advanced level
|
||||
71
samples/tutorials/control/auto_exposure.cc
Normal file
71
samples/tutorials/control/auto_exposure.cc
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// auto-exposure: 0
|
||||
api->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
|
||||
// max_gain: range [0,48], default 48
|
||||
api->SetOptionValue(Option::MAX_GAIN, 48);
|
||||
// max_exposure_time: range [0,240], default 240
|
||||
api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 240);
|
||||
// desired_brightness: range [0,255], default 192
|
||||
api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 192);
|
||||
|
||||
LOG(INFO) << "Enable auto-exposure";
|
||||
LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN);
|
||||
LOG(INFO) << "Set MAX_EXPOSURE_TIME to "
|
||||
<< api->GetOptionValue(Option::MAX_EXPOSURE_TIME);
|
||||
LOG(INFO) << "Set DESIRED_BRIGHTNESS to "
|
||||
<< api->GetOptionValue(Option::DESIRED_BRIGHTNESS);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE));
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
painter.DrawImgData(img, *left_data.img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
92
samples/tutorials/control/framerate.cc
Normal file
92
samples/tutorials/control/framerate.cc
Normal file
@@ -0,0 +1,92 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
#include "mynteye/times.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// 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
|
||||
api->SetOptionValue(Option::FRAME_RATE, 25);
|
||||
// IMU_FREQUENCY values: 100, 200, 250, 333, 500
|
||||
api->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
||||
|
||||
LOG(INFO) << "Set FRAME_RATE to " << api->GetOptionValue(Option::FRAME_RATE);
|
||||
LOG(INFO) << "Set IMU_FREQUENCY to "
|
||||
<< api->GetOptionValue(Option::IMU_FREQUENCY);
|
||||
|
||||
// Count img
|
||||
std::atomic_uint img_count(0);
|
||||
api->SetStreamCallback(
|
||||
Stream::LEFT, [&img_count](const api::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++img_count;
|
||||
});
|
||||
|
||||
// Count imu
|
||||
std::atomic_uint imu_count(0);
|
||||
api->SetMotionCallback([&imu_count](const api::MotionData &data) {
|
||||
CHECK_NOTNULL(data.imu);
|
||||
++imu_count;
|
||||
});
|
||||
|
||||
api->Start(Source::ALL);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
auto &&time_beg = times::now();
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto &&time_end = times::now();
|
||||
|
||||
api->Stop(Source::ALL);
|
||||
|
||||
// Calculate img fps and imu hz
|
||||
float elapsed_ms =
|
||||
times::count<times::microseconds>(time_end - time_beg) * 0.001f;
|
||||
LOG(INFO) << "Time beg: " << times::to_local_string(time_beg)
|
||||
<< ", end: " << times::to_local_string(time_end)
|
||||
<< ", cost: " << elapsed_ms << "ms";
|
||||
LOG(INFO) << "Img count: " << img_count
|
||||
<< ", fps: " << (1000.f * img_count / elapsed_ms);
|
||||
LOG(INFO) << "Imu count: " << imu_count
|
||||
<< ", hz: " << (1000.f * imu_count / elapsed_ms);
|
||||
return 0;
|
||||
}
|
||||
62
samples/tutorials/control/infrared.cc
Normal file
62
samples/tutorials/control/infrared.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Detect infrared add-ons
|
||||
LOG(INFO) << "Support infrared: " << std::boolalpha
|
||||
<< api->Supports(AddOns::INFRARED);
|
||||
LOG(INFO) << "Support infrared2: " << std::boolalpha
|
||||
<< api->Supports(AddOns::INFRARED2);
|
||||
|
||||
// Get infrared intensity range
|
||||
auto &&info = api->GetOptionInfo(Option::IR_CONTROL);
|
||||
LOG(INFO) << Option::IR_CONTROL << ": {" << info << "}";
|
||||
|
||||
// Set infrared intensity value
|
||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
69
samples/tutorials/control/manual_exposure.cc
Normal file
69
samples/tutorials/control/manual_exposure.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// manual-exposure: 1
|
||||
api->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
||||
|
||||
// gain: range [0,48], default 24
|
||||
api->SetOptionValue(Option::GAIN, 24);
|
||||
// brightness/exposure_time: range [0,240], default 120
|
||||
api->SetOptionValue(Option::BRIGHTNESS, 120);
|
||||
// contrast/black_level_calibration: range [0,255], default 127
|
||||
api->SetOptionValue(Option::CONTRAST, 127);
|
||||
|
||||
LOG(INFO) << "Enable manual-exposure";
|
||||
LOG(INFO) << "Set GAIN to " << api->GetOptionValue(Option::GAIN);
|
||||
LOG(INFO) << "Set BRIGHTNESS to " << api->GetOptionValue(Option::BRIGHTNESS);
|
||||
LOG(INFO) << "Set CONTRAST to " << api->GetOptionValue(Option::CONTRAST);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE));
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
painter.DrawImgData(img, *left_data.img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
57
samples/tutorials/data/get_depth.cc
Normal file
57
samples/tutorials/data/get_depth.cc
Normal file
@@ -0,0 +1,57 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("depth");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
auto &&depth_data = api->GetStreamData(Stream::DEPTH);
|
||||
if (!depth_data.frame.empty()) {
|
||||
cv::imshow("depth", depth_data.frame); // CV_16UC1
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
35
samples/tutorials/data/get_device_info.cc
Normal file
35
samples/tutorials/data/get_device_info.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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 <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME);
|
||||
LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER);
|
||||
LOG(INFO) << "Firmware version: " << api->GetInfo(Info::FIRMWARE_VERSION);
|
||||
LOG(INFO) << "Hardware version: " << api->GetInfo(Info::HARDWARE_VERSION);
|
||||
LOG(INFO) << "Spec version: " << api->GetInfo(Info::SPEC_VERSION);
|
||||
LOG(INFO) << "Lens type: " << api->GetInfo(Info::LENS_TYPE);
|
||||
LOG(INFO) << "IMU type: " << api->GetInfo(Info::IMU_TYPE);
|
||||
LOG(INFO) << "Nominal baseline: " << api->GetInfo(Info::NOMINAL_BASELINE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
64
samples/tutorials/data/get_disparity.cc
Normal file
64
samples/tutorials/data/get_disparity.cc
Normal file
@@ -0,0 +1,64 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// api->EnableStreamData(Stream::DISPARITY);
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
// cv::namedWindow("disparity");
|
||||
cv::namedWindow("disparity_normalized");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
// auto &&disp_data = api->GetStreamData(Stream::DISPARITY);
|
||||
// if (!disp_data.frame.empty()) {
|
||||
// cv::imshow("disparity", disp_data.frame);
|
||||
// }
|
||||
|
||||
auto &&disp_norm_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
if (!disp_norm_data.frame.empty()) {
|
||||
cv::imshow("disparity_normalized", disp_norm_data.frame); // CV_8UC1
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
148
samples/tutorials/data/get_from_callbacks.cc
Normal file
148
samples/tutorials/data/get_from_callbacks.cc
Normal file
@@ -0,0 +1,148 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Attention: must not block the callbacks.
|
||||
|
||||
// Get left image from callback
|
||||
std::atomic_uint left_count(0);
|
||||
api->SetStreamCallback(
|
||||
Stream::LEFT, [&left_count](const api::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++left_count;
|
||||
// LOG(INFO) << Stream::LEFT << ", count: " << left_count;
|
||||
// LOG(INFO) << " frame_id: " << data.img->frame_id
|
||||
// << ", timestamp: " << data.img->timestamp
|
||||
// << ", exposure_time: " << data.img->exposure_time;
|
||||
});
|
||||
|
||||
// Get depth image from callback
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
std::atomic_uint depth_count(0);
|
||||
cv::Mat depth;
|
||||
std::mutex depth_mtx;
|
||||
api->SetStreamCallback(
|
||||
Stream::DEPTH,
|
||||
[&depth_count, &depth, &depth_mtx](const api::StreamData &data) {
|
||||
UNUSED(data)
|
||||
++depth_count;
|
||||
{
|
||||
std::lock_guard<std::mutex> _(depth_mtx);
|
||||
depth = data.frame;
|
||||
}
|
||||
// LOG(INFO) << Stream::DEPTH << ", count: " << depth_count;
|
||||
});
|
||||
|
||||
// Get motion data from callback
|
||||
std::atomic_uint imu_count(0);
|
||||
std::shared_ptr<mynteye::ImuData> imu;
|
||||
std::mutex imu_mtx;
|
||||
api->SetMotionCallback(
|
||||
[&imu_count, &imu, &imu_mtx](const api::MotionData &data) {
|
||||
CHECK_NOTNULL(data.imu);
|
||||
++imu_count;
|
||||
{
|
||||
std::lock_guard<std::mutex> _(imu_mtx);
|
||||
imu = data.imu;
|
||||
}
|
||||
// LOG(INFO) << "Imu count: " << imu_count;
|
||||
// LOG(INFO) << " frame_id: " << data.imu->frame_id
|
||||
// << ", timestamp: " << data.imu->timestamp
|
||||
// << ", accel_x: " << data.imu->accel[0]
|
||||
// << ", accel_y: " << data.imu->accel[1]
|
||||
// << ", accel_z: " << data.imu->accel[2]
|
||||
// << ", gyro_x: " << data.imu->gyro[0]
|
||||
// << ", gyro_y: " << data.imu->gyro[1]
|
||||
// << ", gyro_z: " << data.imu->gyro[2]
|
||||
// << ", temperature: " << data.imu->temperature;
|
||||
});
|
||||
|
||||
api->Start(Source::ALL);
|
||||
|
||||
CVPainter painter;
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("depth");
|
||||
|
||||
unsigned int depth_num = 0;
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
// Concat left and right as img
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
|
||||
// Draw img data and size
|
||||
painter.DrawImgData(img, *left_data.img);
|
||||
|
||||
// Draw imu data
|
||||
if (imu) {
|
||||
std::lock_guard<std::mutex> _(imu_mtx);
|
||||
painter.DrawImuData(img, *imu);
|
||||
}
|
||||
|
||||
// Draw counts
|
||||
std::ostringstream ss;
|
||||
ss << "left: " << left_count << ", depth: " << depth_count
|
||||
<< ", imu: " << imu_count;
|
||||
painter.DrawText(img, ss.str(), CVPainter::BOTTOM_RIGHT);
|
||||
|
||||
// Show img
|
||||
cv::imshow("frame", img);
|
||||
|
||||
// Show depth
|
||||
if (!depth.empty()) {
|
||||
// Is the depth a new one?
|
||||
if (depth_num != depth_count || depth_num == 0) {
|
||||
std::lock_guard<std::mutex> _(depth_mtx);
|
||||
depth_num = depth_count;
|
||||
// LOG(INFO) << "depth_num: " << depth_num;
|
||||
ss.str("");
|
||||
ss.clear();
|
||||
ss << "depth: " << depth_count;
|
||||
painter.DrawText(depth, ss.str());
|
||||
cv::imshow("depth", depth); // CV_16UC1
|
||||
}
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::ALL);
|
||||
return 0;
|
||||
}
|
||||
32
samples/tutorials/data/get_img_params.cc
Normal file
32
samples/tutorials/data/get_img_params.cc
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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 <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
|
||||
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
|
||||
<< "}";
|
||||
LOG(INFO) << "Extrinsics right to left: {"
|
||||
<< api->GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
|
||||
|
||||
return 0;
|
||||
}
|
||||
77
samples/tutorials/data/get_imu.cc
Normal file
77
samples/tutorials/data/get_imu.cc
Normal file
@@ -0,0 +1,77 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// Enable this will cache the motion datas until you get them.
|
||||
api->EnableMotionDatas();
|
||||
|
||||
api->Start(Source::ALL);
|
||||
|
||||
CVPainter painter;
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
|
||||
auto &&motion_datas = api->GetMotionDatas();
|
||||
/*
|
||||
for (auto &&data : motion_datas) {
|
||||
LOG(INFO) << "Imu frame_id: " << data.imu->frame_id
|
||||
<< ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
<< ", gyro_x: " << data.imu->gyro[0]
|
||||
<< ", gyro_y: " << data.imu->gyro[1]
|
||||
<< ", gyro_z: " << data.imu->gyro[2]
|
||||
<< ", temperature: " << data.imu->temperature;
|
||||
}
|
||||
*/
|
||||
|
||||
painter.DrawImgData(img, *left_data.img);
|
||||
if (!motion_datas.empty()) {
|
||||
painter.DrawImuData(img, *motion_datas[0].imu);
|
||||
}
|
||||
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::ALL);
|
||||
return 0;
|
||||
}
|
||||
30
samples/tutorials/data/get_imu_params.cc
Normal file
30
samples/tutorials/data/get_imu_params.cc
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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 <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
LOG(INFO) << "Motion intrinsics: {" << api->GetMotionIntrinsics() << "}";
|
||||
LOG(INFO) << "Motion extrinsics left to imu: {"
|
||||
<< api->GetMotionExtrinsics(Stream::LEFT) << "}";
|
||||
|
||||
return 0;
|
||||
}
|
||||
62
samples/tutorials/data/get_points.cc
Normal file
62
samples/tutorials/data/get_points.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/pc_viewer.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::POINTS);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
PCViewer pcviewer;
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
auto &&points_data = api->GetStreamData(Stream::POINTS);
|
||||
if (!points_data.frame.empty()) {
|
||||
pcviewer.Update(points_data.frame);
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
if (pcviewer.WasStopped()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
49
samples/tutorials/data/get_stereo.cc
Normal file
49
samples/tutorials/data/get_stereo.cc
Normal file
@@ -0,0 +1,49 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
54
samples/tutorials/data/get_stereo_rectified.cc
Normal file
54
samples/tutorials/data/get_stereo_rectified.cc
Normal file
@@ -0,0 +1,54 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT_RECTIFIED);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT_RECTIFIED);
|
||||
|
||||
if (!left_data.frame.empty() && !right_data.frame.empty()) {
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
59
samples/tutorials/data/get_with_plugin.cc
Normal file
59
samples/tutorials/data/get_with_plugin.cc
Normal file
@@ -0,0 +1,59 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->EnablePlugin("plugins/linux-x86_64/libplugin_g_cuda9.1_opencv3.4.0.so");
|
||||
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("disparity");
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
if (!disp_data.frame.empty()) {
|
||||
cv::imshow("disparity", disp_data.frame);
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::ALL);
|
||||
return 0;
|
||||
}
|
||||
50
samples/tutorials/intermediate/get_all_device_info.cc
Normal file
50
samples/tutorials/intermediate/get_all_device_info.cc
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "mynteye/context.h"
|
||||
#include "mynteye/device.h"
|
||||
#include "mynteye/glog_init.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
glog_init _(argc, argv);
|
||||
|
||||
LOG(INFO) << "Detecting MYNT EYE devices";
|
||||
Context context;
|
||||
auto &&devices = context.devices();
|
||||
|
||||
size_t n = devices.size();
|
||||
if (n <= 0) {
|
||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
auto &&device = devices[i];
|
||||
LOG(INFO) << "MYNT EYE device index: " << i;
|
||||
LOG(INFO) << " Device name: " << device->GetInfo(Info::DEVICE_NAME);
|
||||
LOG(INFO) << " Serial number: " << device->GetInfo(Info::SERIAL_NUMBER);
|
||||
LOG(INFO) << " Firmware version: "
|
||||
<< device->GetInfo(Info::FIRMWARE_VERSION);
|
||||
LOG(INFO) << " Hardware version: "
|
||||
<< device->GetInfo(Info::HARDWARE_VERSION);
|
||||
LOG(INFO) << " Spec version: " << device->GetInfo(Info::SPEC_VERSION);
|
||||
LOG(INFO) << " Lens type: " << device->GetInfo(Info::LENS_TYPE);
|
||||
LOG(INFO) << " IMU type: " << device->GetInfo(Info::IMU_TYPE);
|
||||
LOG(INFO) << " Nominal baseline: "
|
||||
<< device->GetInfo(Info::NOMINAL_BASELINE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
241
samples/tutorials/intermediate/get_depth_and_points.cc
Normal file
241
samples/tutorials/intermediate/get_depth_and_points.cc
Normal file
@@ -0,0 +1,241 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "mynteye/api.h"
|
||||
|
||||
#include "util/cv_painter.h"
|
||||
#include "util/pc_viewer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class DepthRegion {
|
||||
public:
|
||||
explicit DepthRegion(std::uint32_t n)
|
||||
: n_(std::move(n)), show_(false), selected_(false), point_(0, 0) {}
|
||||
|
||||
~DepthRegion() = default;
|
||||
|
||||
/**
|
||||
* 鼠标事件:默认不选中区域,随鼠标移动而显示。单击后,则会选中区域来显示。你可以再单击已选中区域或双击未选中区域,取消选中。
|
||||
*/
|
||||
void OnMouse(const int &event, const int &x, const int &y, const int &flags) {
|
||||
UNUSED(flags)
|
||||
if (event != CV_EVENT_MOUSEMOVE && event != CV_EVENT_LBUTTONDOWN) {
|
||||
return;
|
||||
}
|
||||
show_ = true;
|
||||
|
||||
if (event == CV_EVENT_MOUSEMOVE) {
|
||||
if (!selected_) {
|
||||
point_.x = x;
|
||||
point_.y = y;
|
||||
}
|
||||
} else if (event == CV_EVENT_LBUTTONDOWN) {
|
||||
if (selected_) {
|
||||
if (x >= static_cast<int>(point_.x - n_) &&
|
||||
x <= static_cast<int>(point_.x + n_) &&
|
||||
y >= static_cast<int>(point_.y - n_) &&
|
||||
y <= static_cast<int>(point_.y + n_)) {
|
||||
selected_ = false;
|
||||
}
|
||||
} else {
|
||||
selected_ = true;
|
||||
}
|
||||
point_.x = x;
|
||||
point_.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void ShowElems(
|
||||
const cv::Mat &depth,
|
||||
std::function<std::string(const T &elem)> elem2string,
|
||||
int elem_space = 40,
|
||||
std::function<std::string(
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n)>
|
||||
getinfo = nullptr) {
|
||||
if (!show_)
|
||||
return;
|
||||
|
||||
int space = std::move(elem_space);
|
||||
int n = 2 * n_ + 1;
|
||||
cv::Mat im(space * n, space * n, CV_8UC3, cv::Scalar(255, 255, 255));
|
||||
|
||||
int x, y;
|
||||
std::string str;
|
||||
int baseline = 0;
|
||||
for (int i = -n_; i <= n; ++i) {
|
||||
x = point_.x + i;
|
||||
if (x < 0 || x >= depth.cols)
|
||||
continue;
|
||||
for (int j = -n_; j <= n; ++j) {
|
||||
y = point_.y + j;
|
||||
if (y < 0 || y >= depth.rows)
|
||||
continue;
|
||||
|
||||
str = elem2string(depth.at<T>(y, x));
|
||||
|
||||
cv::Scalar color(0, 0, 0);
|
||||
if (i == 0 && j == 0)
|
||||
color = cv::Scalar(0, 0, 255);
|
||||
|
||||
cv::Size sz =
|
||||
cv::getTextSize(str, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline);
|
||||
|
||||
cv::putText(
|
||||
im, str, cv::Point(
|
||||
(i + n_) * space + (space - sz.width) / 2,
|
||||
(j + n_) * space + (space + sz.height) / 2),
|
||||
cv::FONT_HERSHEY_PLAIN, 1, color, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (getinfo) {
|
||||
std::string info = getinfo(depth, point_, n_);
|
||||
if (!info.empty()) {
|
||||
cv::Size sz =
|
||||
cv::getTextSize(info, cv::FONT_HERSHEY_PLAIN, 1, 1, &baseline);
|
||||
|
||||
cv::putText(
|
||||
im, info, cv::Point(5, 5 + sz.height), cv::FONT_HERSHEY_PLAIN, 1,
|
||||
cv::Scalar(255, 0, 255), 1);
|
||||
}
|
||||
}
|
||||
|
||||
cv::imshow("region", im);
|
||||
}
|
||||
|
||||
void DrawRect(cv::Mat &image) { // NOLINT
|
||||
if (!show_)
|
||||
return;
|
||||
std::uint32_t n = (n_ > 1) ? n_ : 1;
|
||||
n += 1; // outside the region
|
||||
cv::rectangle(
|
||||
image, cv::Point(point_.x - n, point_.y - n),
|
||||
cv::Point(point_.x + n, point_.y + n),
|
||||
selected_ ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 0, 255), 1);
|
||||
}
|
||||
|
||||
private:
|
||||
std::uint32_t n_;
|
||||
bool show_;
|
||||
bool selected_;
|
||||
cv::Point point_;
|
||||
};
|
||||
|
||||
void OnDepthMouseCallback(int event, int x, int y, int flags, void *userdata) {
|
||||
DepthRegion *region = reinterpret_cast<DepthRegion *>(userdata);
|
||||
region->OnMouse(event, x, y, flags);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
|
||||
api->EnableStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("depth");
|
||||
cv::namedWindow("region");
|
||||
|
||||
DepthRegion depth_region(3);
|
||||
auto depth_info = [](
|
||||
const cv::Mat &depth, const cv::Point &point, const std::uint32_t &n) {
|
||||
UNUSED(depth)
|
||||
std::ostringstream os;
|
||||
os << "depth pos: [" << point.y << ", " << point.x << "]"
|
||||
<< "±" << n << ", unit: mm";
|
||||
return os.str();
|
||||
};
|
||||
|
||||
CVPainter painter;
|
||||
PCViewer pcviewer;
|
||||
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
|
||||
painter.DrawImgData(img, *left_data.img);
|
||||
|
||||
cv::imshow("frame", img);
|
||||
|
||||
auto &&disp_data = api->GetStreamData(Stream::DISPARITY_NORMALIZED);
|
||||
auto &&depth_data = api->GetStreamData(Stream::DEPTH);
|
||||
if (!disp_data.frame.empty() && !depth_data.frame.empty()) {
|
||||
// Show disparity instead of depth, but show depth values in region.
|
||||
auto &&depth_frame = disp_data.frame;
|
||||
|
||||
#ifdef USE_OPENCV3
|
||||
// ColormapTypes
|
||||
// http://docs.opencv.org/master/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65
|
||||
cv::applyColorMap(depth_frame, depth_frame, cv::COLORMAP_JET);
|
||||
#endif
|
||||
|
||||
cv::setMouseCallback("depth", OnDepthMouseCallback, &depth_region);
|
||||
// Note: DrawRect will change some depth values to show the rect.
|
||||
depth_region.DrawRect(depth_frame);
|
||||
|
||||
cv::imshow("depth", depth_frame);
|
||||
|
||||
depth_region.ShowElems<ushort>(
|
||||
depth_data.frame,
|
||||
[](const ushort &elem) {
|
||||
if (elem >= 10000) {
|
||||
// Filter errors, or limit to valid range.
|
||||
//
|
||||
// reprojectImageTo3D(), missing values will set to 10000
|
||||
// https://docs.opencv.org/master/d9/d0c/group__calib3d.html#ga1bc1152bd57d63bc524204f21fde6e02
|
||||
return std::string("invalid");
|
||||
}
|
||||
return std::to_string(elem);
|
||||
},
|
||||
80, depth_info);
|
||||
}
|
||||
|
||||
auto &&points_data = api->GetStreamData(Stream::POINTS);
|
||||
if (!points_data.frame.empty()) {
|
||||
pcviewer.Update(points_data.frame);
|
||||
}
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
break;
|
||||
}
|
||||
if (pcviewer.WasStopped()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
api->Stop(Source::VIDEO_STREAMING);
|
||||
return 0;
|
||||
}
|
||||
190
samples/tutorials/util/cv_painter.cc
Normal file
190
samples/tutorials/util/cv_painter.cc
Normal file
@@ -0,0 +1,190 @@
|
||||
// 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 "util/cv_painter.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
#define FONT_FACE cv::FONT_HERSHEY_PLAIN
|
||||
#define FONT_SCALE 1
|
||||
#define FONT_COLOR cv::Scalar(255, 255, 255)
|
||||
#define THICKNESS 1
|
||||
|
||||
namespace {
|
||||
|
||||
std::shared_ptr<std::ios> NewFormat(int width, int prec, char fillch = ' ') {
|
||||
auto fmt = std::make_shared<std::ios>(nullptr);
|
||||
fmt->setf(std::ios::fixed);
|
||||
if (width > 0)
|
||||
fmt->width(std::move(width));
|
||||
if (prec > 0)
|
||||
fmt->precision(std::move(prec));
|
||||
fmt->fill(std::move(fillch));
|
||||
return fmt;
|
||||
}
|
||||
|
||||
std::ostringstream &Clear(std::ostringstream &os) {
|
||||
os.str("");
|
||||
os.clear();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::ostream &operator<<(
|
||||
std::ostream &os, const std::shared_ptr<std::ios> &fmt) {
|
||||
if (fmt)
|
||||
os.copyfmt(*fmt);
|
||||
return os;
|
||||
}
|
||||
|
||||
CVPainter::CVPainter(std::int32_t frame_rate)
|
||||
: frame_rate_(std::move(frame_rate)) {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
CVPainter::~CVPainter() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
cv::Rect CVPainter::DrawSize(const cv::Mat &img, const gravity_t &gravity) {
|
||||
std::ostringstream ss;
|
||||
ss << img.cols << "x" << img.rows;
|
||||
return DrawText(img, ss.str(), gravity, 5);
|
||||
}
|
||||
|
||||
cv::Rect CVPainter::DrawImgData(
|
||||
const cv::Mat &img, const mynteye::ImgData &data,
|
||||
const gravity_t &gravity) {
|
||||
int sign = 1;
|
||||
if (gravity == BOTTOM_LEFT || gravity == BOTTOM_RIGHT)
|
||||
sign = -1;
|
||||
|
||||
static auto fmt_time = NewFormat(0, 2);
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "frame_id: " << data.frame_id;
|
||||
ss << ", stamp: " << fmt_time << (0.01f * data.timestamp); // ms
|
||||
ss << ", expo: ";
|
||||
if (frame_rate_ == 0) {
|
||||
ss << data.exposure_time;
|
||||
} else {
|
||||
ss << fmt_time << mynteye::utils::get_real_exposure_time(
|
||||
frame_rate_, data.exposure_time);
|
||||
}
|
||||
cv::Rect rect_i = DrawText(img, ss.str(), gravity, 5);
|
||||
|
||||
Clear(ss) << "size: " << img.cols << "x" << img.rows;
|
||||
cv::Rect rect_s =
|
||||
DrawText(img, ss.str(), gravity, 5, 0, sign * (5 + rect_i.height));
|
||||
|
||||
// rect_i.width is the max one
|
||||
if (sign > 0) {
|
||||
return cv::Rect(
|
||||
rect_i.tl(),
|
||||
cv::Point(rect_i.x + rect_i.width, rect_s.y + rect_s.height));
|
||||
} else {
|
||||
return cv::Rect(rect_s.tl(), rect_i.br());
|
||||
}
|
||||
}
|
||||
|
||||
cv::Rect CVPainter::DrawImuData(
|
||||
const cv::Mat &img, const mynteye::ImuData &data,
|
||||
const gravity_t &gravity) {
|
||||
static std::ostringstream ss;
|
||||
static auto fmt_imu = NewFormat(8, 4);
|
||||
static auto fmt_temp = NewFormat(6, 4);
|
||||
|
||||
int sign = 1;
|
||||
if (gravity == BOTTOM_LEFT || gravity == BOTTOM_RIGHT)
|
||||
sign = -1;
|
||||
|
||||
Clear(ss) << "frame_id: " << data.frame_id << ", stamp: " << data.timestamp
|
||||
<< ", temp: " << fmt_temp << data.temperature;
|
||||
cv::Rect rect_i = DrawText(img, ss.str(), gravity, 5);
|
||||
|
||||
Clear(ss) << "accel(x,y,z): " << fmt_imu << data.accel[0] << "," << fmt_imu
|
||||
<< data.accel[1] << "," << fmt_imu << data.accel[2];
|
||||
cv::Rect rect_a =
|
||||
DrawText(img, ss.str(), gravity, 5, 0, sign * (5 + rect_i.height));
|
||||
|
||||
Clear(ss) << "gyro(x,y,z): " << fmt_imu << data.gyro[0] << "," << fmt_imu
|
||||
<< data.gyro[1] << "," << fmt_imu << data.gyro[2];
|
||||
cv::Rect rect_g = DrawText(
|
||||
img, ss.str(), gravity, 5, 0,
|
||||
sign * (10 + rect_i.height + rect_a.height));
|
||||
|
||||
// rect_i.width is the max one
|
||||
if (sign > 0) {
|
||||
return cv::Rect(
|
||||
rect_i.tl(),
|
||||
cv::Point(rect_i.x + rect_i.width, rect_g.y + rect_g.height));
|
||||
} else {
|
||||
return cv::Rect(rect_g.tl(), rect_i.br());
|
||||
}
|
||||
}
|
||||
|
||||
cv::Rect CVPainter::DrawText(
|
||||
const cv::Mat &img, const std::string &text, const gravity_t &gravity,
|
||||
const int &margin, const int &offset_x, const int &offset_y) {
|
||||
int w = img.cols, h = img.rows;
|
||||
|
||||
int baseline = 0;
|
||||
cv::Size textSize =
|
||||
cv::getTextSize(text, FONT_FACE, FONT_SCALE, THICKNESS, &baseline);
|
||||
|
||||
int x, y;
|
||||
switch (gravity) {
|
||||
case TOP_LEFT:
|
||||
x = margin;
|
||||
y = margin + textSize.height;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
x = w - margin - textSize.width;
|
||||
y = margin + textSize.height;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
x = margin;
|
||||
y = h - margin;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
x = w - margin - textSize.width;
|
||||
y = h - margin;
|
||||
break;
|
||||
default: // TOP_LEFT
|
||||
x = margin;
|
||||
y = margin + textSize.height;
|
||||
break;
|
||||
}
|
||||
x += offset_x;
|
||||
y += offset_y;
|
||||
|
||||
cv::Point org(x, y);
|
||||
#ifdef USE_OPENCV2
|
||||
cv::putText(
|
||||
const_cast<cv::Mat &>(img), text, org, FONT_FACE, FONT_SCALE, FONT_COLOR,
|
||||
THICKNESS);
|
||||
#else
|
||||
cv::putText(img, text, org, FONT_FACE, FONT_SCALE, FONT_COLOR, THICKNESS);
|
||||
#endif
|
||||
return cv::Rect(org, textSize);
|
||||
}
|
||||
53
samples/tutorials/util/cv_painter.h
Normal file
53
samples/tutorials/util/cv_painter.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_TUTORIALS_CV_PAINTER_H_ // NOLINT
|
||||
#define MYNTEYE_TUTORIALS_CV_PAINTER_H_
|
||||
#pragma once
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mynteye/types.h"
|
||||
|
||||
class CVPainter {
|
||||
public:
|
||||
typedef enum Gravity {
|
||||
TOP_LEFT,
|
||||
TOP_RIGHT,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT
|
||||
} gravity_t;
|
||||
|
||||
explicit CVPainter(std::int32_t frame_rate = 0);
|
||||
~CVPainter();
|
||||
|
||||
cv::Rect DrawSize(const cv::Mat &img, const gravity_t &gravity = TOP_LEFT);
|
||||
cv::Rect DrawImgData(
|
||||
const cv::Mat &img, const mynteye::ImgData &data,
|
||||
const gravity_t &gravity = TOP_LEFT);
|
||||
cv::Rect DrawImuData(
|
||||
const cv::Mat &img, const mynteye::ImuData &data,
|
||||
const gravity_t &gravity = TOP_RIGHT);
|
||||
|
||||
cv::Rect DrawText(
|
||||
const cv::Mat &img, const std::string &text,
|
||||
const gravity_t &gravity = TOP_LEFT, const int &margin = 5,
|
||||
const int &offset_x = 0, const int &offset_y = 0);
|
||||
|
||||
private:
|
||||
std::int32_t frame_rate_;
|
||||
};
|
||||
|
||||
#endif // MYNTEYE_TUTORIALS_CV_PAINTER_H_ NOLINT
|
||||
102
samples/tutorials/util/pc_viewer.cc
Normal file
102
samples/tutorials/util/pc_viewer.cc
Normal file
@@ -0,0 +1,102 @@
|
||||
// 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 "util/pc_viewer.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
// #include <pcl/common/common_headers.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
std::shared_ptr<pcl::visualization::PCLVisualizer> CustomColorVis(
|
||||
pcl::PointCloud<pcl::PointXYZ>::ConstPtr pc) {
|
||||
// --------------------------------------------
|
||||
// -----Open 3D viewer and add point cloud-----
|
||||
// --------------------------------------------
|
||||
std::shared_ptr<pcl::visualization::PCLVisualizer> viewer(
|
||||
new pcl::visualization::PCLVisualizer("PointCloud Viewer"));
|
||||
viewer->setBackgroundColor(0, 0, 0);
|
||||
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> single_color(
|
||||
pc, 255, 255, 255);
|
||||
viewer->addPointCloud<pcl::PointXYZ>(pc, single_color, "point cloud");
|
||||
viewer->setPointCloudRenderingProperties(
|
||||
pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "point cloud");
|
||||
// viewer->addCoordinateSystem(1.0);
|
||||
viewer->addCoordinateSystem(1000.0);
|
||||
viewer->initCameraParameters();
|
||||
viewer->setCameraPosition(0, 0, -150, 0, -1, 0);
|
||||
return (viewer);
|
||||
}
|
||||
|
||||
PCViewer::PCViewer() : viewer_(nullptr) {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
PCViewer::~PCViewer() {
|
||||
VLOG(2) << __func__;
|
||||
if (viewer_) {
|
||||
// viewer_->saveCameraParameters("pcl_camera_params.txt");
|
||||
viewer_->close();
|
||||
viewer_ == nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PCViewer::Update(const cv::Mat &xyz) {
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr pc(new pcl::PointCloud<pcl::PointXYZ>);
|
||||
ConvertMatToPointCloud(xyz, pc);
|
||||
Update(pc);
|
||||
}
|
||||
|
||||
void PCViewer::Update(pcl::PointCloud<pcl::PointXYZ>::ConstPtr pc) {
|
||||
if (viewer_ == nullptr) {
|
||||
viewer_ = CustomColorVis(pc);
|
||||
}
|
||||
viewer_->updatePointCloud(pc, "point cloud");
|
||||
viewer_->spinOnce();
|
||||
}
|
||||
|
||||
bool PCViewer::WasVisual() const {
|
||||
return viewer_ != nullptr;
|
||||
}
|
||||
|
||||
bool PCViewer::WasStopped() const {
|
||||
return viewer_ != nullptr && viewer_->wasStopped();
|
||||
}
|
||||
|
||||
void PCViewer::ConvertMatToPointCloud(
|
||||
const cv::Mat &xyz, pcl::PointCloud<pcl::PointXYZ>::Ptr pc) {
|
||||
// cv::Mat channels[3];
|
||||
// cv::split(xyz, channels);
|
||||
// double min, max;
|
||||
// cv::minMaxLoc(channels[2], &min, &max);
|
||||
|
||||
for (int i = 0; i < xyz.rows; i++) {
|
||||
for (int j = 0; j < xyz.cols; j++) {
|
||||
auto &&p = xyz.at<cv::Point3f>(i, j);
|
||||
if (std::isfinite(p.x) && std::isfinite(p.y) && std::isfinite(p.z)) {
|
||||
// LOG(INFO) << "[" << i << "," << j << "] x: " << p.x << ", y: " << p.y
|
||||
// << ", z: " << p.z;
|
||||
pcl::PointXYZ point;
|
||||
point.x = p.x;
|
||||
point.y = p.y;
|
||||
point.z = p.z;
|
||||
// point.z = p.z - min;
|
||||
pc->points.push_back(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pc->width = static_cast<int>(pc->points.size());
|
||||
pc->height = 1;
|
||||
}
|
||||
43
samples/tutorials/util/pc_viewer.h
Normal file
43
samples/tutorials/util/pc_viewer.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_TUTORIALS_PC_VIEWER_H_ // NOLINT
|
||||
#define MYNTEYE_TUTORIALS_PC_VIEWER_H_
|
||||
#pragma once
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <pcl/visualization/pcl_visualizer.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PCViewer {
|
||||
public:
|
||||
PCViewer();
|
||||
~PCViewer();
|
||||
|
||||
void Update(const cv::Mat &xyz);
|
||||
|
||||
void Update(pcl::PointCloud<pcl::PointXYZ>::ConstPtr pc);
|
||||
|
||||
bool WasVisual() const;
|
||||
bool WasStopped() const;
|
||||
|
||||
private:
|
||||
void ConvertMatToPointCloud(
|
||||
const cv::Mat &xyz, pcl::PointCloud<pcl::PointXYZ>::Ptr pc);
|
||||
|
||||
std::shared_ptr<pcl::visualization::PCLVisualizer> viewer_;
|
||||
};
|
||||
|
||||
#endif // MYNTEYE_TUTORIALS_PC_VIEWER_H_ NOLINT
|
||||
@@ -1,3 +1,17 @@
|
||||
# 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.
|
||||
|
||||
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
set_outdir(
|
||||
@@ -12,11 +26,8 @@ include_directories(
|
||||
|
||||
## camera_u
|
||||
|
||||
add_executable(camera_u camera.cc)
|
||||
target_link_libraries(camera_u mynteye ${OpenCV_LIBS})
|
||||
|
||||
if(OS_WIN)
|
||||
target_compile_definitions(camera_u
|
||||
PUBLIC GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
)
|
||||
endif()
|
||||
make_executable(camera_u
|
||||
SRCS camera.cc
|
||||
LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
)
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
// 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 <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
@@ -14,8 +27,17 @@
|
||||
|
||||
struct frame {
|
||||
const void *data = nullptr;
|
||||
std::function<void()> continuation = nullptr;
|
||||
frame() {
|
||||
// VLOG(2) << __func__;
|
||||
}
|
||||
~frame() {
|
||||
// VLOG(2) << __func__;
|
||||
data = nullptr;
|
||||
if (continuation) {
|
||||
continuation();
|
||||
continuation = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,7 +50,11 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
auto context = uvc::create_context();
|
||||
auto devices = uvc::query_devices(context);
|
||||
LOG_IF(FATAL, devices.size() <= 0) << "No devices :(";
|
||||
if (devices.size() <= 0) {
|
||||
LOG(ERROR) << "No devices :(";
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (auto &&device : devices) {
|
||||
auto vid = uvc::get_vendor_id(*device);
|
||||
// auto pid = uvc::get_product_id(*device);
|
||||
@@ -41,7 +67,10 @@ int main(int argc, char *argv[]) {
|
||||
// std::string dashes(80, '-');
|
||||
|
||||
size_t n = mynteye_devices.size();
|
||||
LOG_IF(FATAL, n <= 0) << "No MYNT EYE devices :(";
|
||||
if (n <= 0) {
|
||||
LOG(ERROR) << "No MYNT EYE devices :(";
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "MYNT EYE devices: ";
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
@@ -74,18 +103,25 @@ int main(int argc, char *argv[]) {
|
||||
std::mutex mtx;
|
||||
std::condition_variable cv;
|
||||
|
||||
std::vector<frame> frames;
|
||||
const auto frame_ready = [&frames]() { return !frames.empty(); };
|
||||
const auto frame_empty = [&frames]() { return frames.empty(); };
|
||||
std::shared_ptr<frame> frame = nullptr;
|
||||
const auto frame_ready = [&frame]() { return frame != nullptr; };
|
||||
const auto frame_empty = [&frame]() { return frame == nullptr; };
|
||||
|
||||
uvc::set_device_mode(
|
||||
*device, 752, 480, static_cast<int>(Format::YUYV), 25,
|
||||
[&mtx, &cv, &frames, &frame_ready](const void *data) {
|
||||
[&mtx, &cv, &frame, &frame_ready](
|
||||
const void *data, std::function<void()> continuation) {
|
||||
// reinterpret_cast<const std::uint8_t *>(data);
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
frame frame;
|
||||
frame.data = data; // not copy
|
||||
frames.push_back(frame);
|
||||
if (frame == nullptr) {
|
||||
frame = std::make_shared<struct frame>();
|
||||
} else {
|
||||
if (frame->continuation) {
|
||||
frame->continuation();
|
||||
}
|
||||
}
|
||||
frame->data = data; // not copy here
|
||||
frame->continuation = continuation;
|
||||
if (frame_ready())
|
||||
cv.notify_one();
|
||||
});
|
||||
@@ -106,13 +142,12 @@ int main(int argc, char *argv[]) {
|
||||
throw std::runtime_error("Timeout waiting for frame.");
|
||||
}
|
||||
|
||||
auto frame = frames.back(); // only last one is valid
|
||||
|
||||
cv::Mat img(480, 752, CV_8UC2, const_cast<void *>(frame.data));
|
||||
// only lastest frame is valid
|
||||
cv::Mat img(480, 752, CV_8UC2, const_cast<void *>(frame->data));
|
||||
cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
frames.clear();
|
||||
frame = nullptr;
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -n "${_DETECT_SH_}" ] && return || readonly _DETECT_SH_=1
|
||||
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: detect.sh"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -n "${_ECHO_SH_}" ] && return || readonly _ECHO_SH_=1
|
||||
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: echo.sh"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -n "${_HOST_SH_}" ] && return || readonly _HOST_SH_=1
|
||||
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: host.sh"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -n "${_MKDIR_SH_}" ] && return || readonly _MKDIR_SH_=1
|
||||
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: mkdir.sh"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
[ -n "${_STRING_SH_}" ] && return || readonly _STRING_SH_=1
|
||||
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: string.sh"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
ROOT_DIR=$(realpath "$BASE_DIR/..")
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FIND="find"
|
||||
|
||||
|
||||
103
scripts/init.sh
103
scripts/init.sh
@@ -1,9 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# _VERBOSE_=1
|
||||
# _FORCE_INSRALL_=1
|
||||
|
||||
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
ROOT_DIR=$(realpath "$BASE_DIR/..")
|
||||
|
||||
source "$BASE_DIR/common/echo.sh"
|
||||
source "$BASE_DIR/common/detect.sh"
|
||||
@@ -11,20 +24,26 @@ source "$BASE_DIR/common/host.sh"
|
||||
|
||||
PYTHON="python"
|
||||
if [ "$HOST_OS" = "Win" ]; then
|
||||
# default python on MSYS
|
||||
PYTHON="python2"
|
||||
if ! _detect_cmd $PYTHON; then
|
||||
PYTHON="python2" # try python2 on MSYS
|
||||
fi
|
||||
fi
|
||||
|
||||
_detect curl
|
||||
_detect $PYTHON
|
||||
_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() {
|
||||
dpkg -s "$1" > /dev/null
|
||||
_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() {
|
||||
brew ls --versions "$1" > /dev/null
|
||||
_detect_cmd "$1" || brew ls --versions "$1" > /dev/null
|
||||
}
|
||||
else
|
||||
_detect_install() {
|
||||
@@ -61,19 +80,26 @@ if [ "$HOST_OS" = "Linux" ]; then
|
||||
# detect apt-get
|
||||
_detect apt-get
|
||||
# apt-get install
|
||||
_install_deps "sudo apt-get install" build-essential cmake git clang-format
|
||||
_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"
|
||||
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" cmake git clang-format
|
||||
_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
|
||||
@@ -82,7 +108,7 @@ elif [ "$HOST_OS" = "Win" ]; then
|
||||
# detect pacman on MSYS
|
||||
_detect pacman
|
||||
# pacman install (common)
|
||||
_install_deps "pacman -S" git clang-format
|
||||
_install_deps "pacman -S" curl git clang-format
|
||||
if [ "$HOST_NAME" = "MINGW" ]; then
|
||||
# pacman install (MINGW)
|
||||
_deps=()
|
||||
@@ -117,17 +143,60 @@ fi
|
||||
|
||||
# detect pip
|
||||
if ! _detect_cmd pip; then
|
||||
_echo_sn "Install pip"
|
||||
[ -f "get-pip.py" ] || curl -O https://bootstrap.pypa.io/get-pip.py
|
||||
$SUDO $PYTHON get-pip.py
|
||||
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
|
||||
_echo_d "pip install --upgrade autopep8 cpplint pylint requests"
|
||||
$SUDO pip install --upgrade autopep8 cpplint pylint requests
|
||||
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
|
||||
|
||||
_echo_s "Init git hooks"
|
||||
$PYTHON "$ROOT_DIR/tools/linter/init-git-hooks.py"
|
||||
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"
|
||||
cmake --version | head -1
|
||||
if [ "$HOST_NAME" = "Ubuntu" ]; then
|
||||
# sudo apt remove cmake
|
||||
_echo "How to upgrade cmake in Ubuntu"
|
||||
_echo " https://askubuntu.com/questions/829310/how-to-upgrade-cmake-in-ubuntu"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
|
||||
|
||||
455
src/api/api.cc
Normal file
455
src/api/api.cc
Normal file
@@ -0,0 +1,455 @@
|
||||
// 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 "api/api.h"
|
||||
|
||||
#ifdef WITH_BOOST_FILESYSTEM
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#endif
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <thread>
|
||||
|
||||
#include "mynteye/glog_init.h"
|
||||
#include "mynteye/utils.h"
|
||||
|
||||
#include "api/plugin.h"
|
||||
#include "api/synthetic.h"
|
||||
#include "device/device.h"
|
||||
#include "device/device_s.h"
|
||||
#include "internal/dl.h"
|
||||
|
||||
#if defined(WITH_FILESYSTEM) && defined(WITH_NATIVE_FILESYSTEM)
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(WITH_FILESYSTEM)
|
||||
|
||||
#if defined(WITH_BOOST_FILESYSTEM)
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
bool file_exists(const fs::path &p) {
|
||||
try {
|
||||
fs::file_status s = fs::status(p);
|
||||
return fs::exists(s) && fs::is_regular_file(s);
|
||||
} catch (fs::filesystem_error &e) {
|
||||
LOG(ERROR) << e.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool dir_exists(const fs::path &p) {
|
||||
try {
|
||||
fs::file_status s = fs::status(p);
|
||||
return fs::exists(s) && fs::is_directory(s);
|
||||
} catch (fs::filesystem_error &e) {
|
||||
LOG(ERROR) << e.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(WITH_NATIVE_FILESYSTEM)
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
bool file_exists(const std::string &p) {
|
||||
DWORD attrs = GetFileAttributes(p.c_str());
|
||||
return (attrs != INVALID_FILE_ATTRIBUTES) &&
|
||||
!(attrs & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
bool dir_exists(const std::string &p) {
|
||||
DWORD attrs = GetFileAttributes(p.c_str());
|
||||
return (attrs != INVALID_FILE_ATTRIBUTES) &&
|
||||
(attrs & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unsupported native filesystem"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
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");
|
||||
|
||||
cv::FileStorage fs(info_path, cv::FileStorage::READ);
|
||||
if (!fs.isOpened()) {
|
||||
LOG(WARNING) << "build.info not found: " << info_path;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto to_lower = [](std::string &s) { // NOLINT
|
||||
std::transform(s.begin(), s.end(), s.begin(), ::tolower);
|
||||
};
|
||||
|
||||
std::string host_os = fs["HOST_OS"];
|
||||
to_lower(host_os);
|
||||
std::string host_name = fs["HOST_NAME"];
|
||||
to_lower(host_name);
|
||||
std::string host_arch = fs["HOST_ARCH"];
|
||||
to_lower(host_arch);
|
||||
std::string host_compiler = fs["HOST_COMPILER"];
|
||||
to_lower(host_compiler);
|
||||
|
||||
// std::string compiler_version = fs["COMPILER_VERSION"];
|
||||
int compiler_version_major = fs["COMPILER_VERSION_MAJOR"];
|
||||
// int compiler_version_minor = fs["COMPILER_VERSION_MINOR"];
|
||||
// int compiler_version_patch = fs["COMPILER_VERSION_PATCH"];
|
||||
// int compiler_version_tweak = fs["COMPILER_VERSION_TWEAK"];
|
||||
|
||||
std::string cuda_version = fs["CUDA_VERSION"];
|
||||
// int cuda_version_major = fs["CUDA_VERSION_MAJOR"];
|
||||
// int cuda_version_minor = fs["CUDA_VERSION_MINOR"];
|
||||
// std::string cuda_version_string = fs["CUDA_VERSION_STRING"];
|
||||
|
||||
std::string opencv_version = fs["OpenCV_VERSION"];
|
||||
// int opencv_version_major = fs["OpenCV_VERSION_MAJOR"];
|
||||
// int opencv_version_minor = fs["OpenCV_VERSION_MINOR"];
|
||||
// int opencv_version_patch = fs["OpenCV_VERSION_PATCH"];
|
||||
// int opencv_version_tweak = fs["OpenCV_VERSION_TWEAK"];
|
||||
// std::string opencv_version_status = fs["OpenCV_VERSION_STATUS"];
|
||||
std::string opencv_with_world = fs["OpenCV_WITH_WORLD"];
|
||||
to_lower(opencv_with_world);
|
||||
|
||||
std::string mynteye_version = fs["MYNTEYE_VERSION"];
|
||||
// int mynteye_version_major = fs["MYNTEYE_VERSION_MAJOR"];
|
||||
// int mynteye_version_minor = fs["MYNTEYE_VERSION_MINOR"];
|
||||
// int mynteye_version_patch = fs["MYNTEYE_VERSION_PATCH"];
|
||||
// int mynteye_version_tweak = fs["MYNTEYE_VERSION_TWEAK"];
|
||||
|
||||
fs.release();
|
||||
|
||||
std::string lib_prefix;
|
||||
std::string lib_suffix;
|
||||
if (host_os == "linux") {
|
||||
if (host_compiler != "gnu" || compiler_version_major < 5)
|
||||
return {};
|
||||
lib_prefix = "lib";
|
||||
lib_suffix = ".so";
|
||||
} else if (host_os == "win") {
|
||||
lib_prefix = "";
|
||||
lib_suffix = ".dll";
|
||||
} else if (host_os == "mac") {
|
||||
lib_prefix = "lib";
|
||||
lib_suffix = ".dylib";
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
{
|
||||
std::vector<std::string> prefixes{
|
||||
// lib_prefix + "plugin_b_ocl" + ocl_version,
|
||||
lib_prefix + "plugin_g_cuda" + cuda_version,
|
||||
};
|
||||
std::string opencv_name("_opencv" + opencv_version);
|
||||
if (opencv_with_world == "true") {
|
||||
opencv_name.append("-world");
|
||||
}
|
||||
for (auto &&prefix : prefixes) {
|
||||
names.push_back(prefix + opencv_name + "_mynteye" + mynteye_version);
|
||||
names.push_back(prefix + opencv_name);
|
||||
names.push_back(prefix);
|
||||
}
|
||||
for (auto &&name : names) {
|
||||
name.append(lib_suffix);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> paths;
|
||||
|
||||
std::vector<std::string> plats;
|
||||
if (host_name != host_os) {
|
||||
plats.push_back(host_name + "-" + host_arch);
|
||||
}
|
||||
plats.push_back(host_os + "-" + host_arch);
|
||||
|
||||
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;
|
||||
// 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;
|
||||
if (!file_exists(path))
|
||||
continue;
|
||||
paths.push_back(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
API::API(std::shared_ptr<Device> device) : device_(device) {
|
||||
VLOG(2) << __func__;
|
||||
if (std::dynamic_pointer_cast<StandardDevice>(device_) != nullptr) {
|
||||
bool in_l_ok, in_r_ok, ex_r2l_ok;
|
||||
device_->GetIntrinsics(Stream::LEFT, &in_l_ok);
|
||||
device_->GetIntrinsics(Stream::RIGHT, &in_r_ok);
|
||||
device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT, &ex_r2l_ok);
|
||||
if (!in_l_ok || !in_r_ok || !ex_r2l_ok) {
|
||||
#if defined(WITH_DEVICE_INFO_REQUIRED)
|
||||
LOG(FATAL)
|
||||
#else
|
||||
LOG(WARNING)
|
||||
#endif
|
||||
<< "Image params not found, but we need it to process the "
|
||||
"images. Please `make tools` and use `img_params_writer` "
|
||||
"to write the image params. If you update the SDK from "
|
||||
"1.x, the `SN*.conf` is the file contains them. Besides, "
|
||||
"you could also calibrate them by yourself. Read the guide "
|
||||
"doc (https://github.com/slightech/MYNT-EYE-SDK-2-Guide) "
|
||||
"to learn more.";
|
||||
}
|
||||
}
|
||||
synthetic_.reset(new Synthetic(this));
|
||||
}
|
||||
|
||||
API::~API() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create() {
|
||||
return Create(device::select());
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(std::shared_ptr<Device> device) {
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||
static glog_init _(argc, argv);
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device) {
|
||||
static glog_init _(argc, argv);
|
||||
if (!device)
|
||||
return nullptr;
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
Model API::GetModel() const {
|
||||
return device_->GetModel();
|
||||
}
|
||||
|
||||
bool API::Supports(const Stream &stream) const {
|
||||
return synthetic_->Supports(stream);
|
||||
}
|
||||
|
||||
bool API::Supports(const Capabilities &capability) const {
|
||||
return device_->Supports(capability);
|
||||
}
|
||||
|
||||
bool API::Supports(const Option &option) const {
|
||||
return device_->Supports(option);
|
||||
}
|
||||
|
||||
bool API::Supports(const AddOns &addon) const {
|
||||
return device_->Supports(addon);
|
||||
}
|
||||
|
||||
const std::vector<StreamRequest> &API::GetStreamRequests(
|
||||
const Capabilities &capability) const {
|
||||
return device_->GetStreamRequests(capability);
|
||||
}
|
||||
|
||||
void API::ConfigStreamRequest(
|
||||
const Capabilities &capability, const StreamRequest &request) {
|
||||
device_->ConfigStreamRequest(capability, request);
|
||||
}
|
||||
|
||||
std::string API::GetInfo(const Info &info) const {
|
||||
return device_->GetInfo(info);
|
||||
}
|
||||
|
||||
Intrinsics API::GetIntrinsics(const Stream &stream) const {
|
||||
return device_->GetIntrinsics(stream);
|
||||
}
|
||||
|
||||
Extrinsics API::GetExtrinsics(const Stream &from, const Stream &to) const {
|
||||
return device_->GetExtrinsics(from, to);
|
||||
}
|
||||
|
||||
MotionIntrinsics API::GetMotionIntrinsics() const {
|
||||
return device_->GetMotionIntrinsics();
|
||||
}
|
||||
|
||||
Extrinsics API::GetMotionExtrinsics(const Stream &from) const {
|
||||
return device_->GetMotionExtrinsics(from);
|
||||
}
|
||||
|
||||
void API::LogOptionInfos() const {
|
||||
device_->LogOptionInfos();
|
||||
}
|
||||
|
||||
OptionInfo API::GetOptionInfo(const Option &option) const {
|
||||
return device_->GetOptionInfo(option);
|
||||
}
|
||||
|
||||
std::int32_t API::GetOptionValue(const Option &option) const {
|
||||
return device_->GetOptionValue(option);
|
||||
}
|
||||
|
||||
void API::SetOptionValue(const Option &option, std::int32_t value) {
|
||||
device_->SetOptionValue(option, value);
|
||||
}
|
||||
|
||||
bool API::RunOptionAction(const Option &option) const {
|
||||
return device_->RunOptionAction(option);
|
||||
}
|
||||
|
||||
void API::SetStreamCallback(const Stream &stream, stream_callback_t callback) {
|
||||
synthetic_->SetStreamCallback(stream, callback);
|
||||
}
|
||||
|
||||
void API::SetMotionCallback(motion_callback_t callback) {
|
||||
static auto callback_ = callback;
|
||||
if (callback_) {
|
||||
device_->SetMotionCallback(
|
||||
[](const device::MotionData &data) { callback_({data.imu}); }, true);
|
||||
} else {
|
||||
device_->SetMotionCallback(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
bool API::HasStreamCallback(const Stream &stream) const {
|
||||
return synthetic_->HasStreamCallback(stream);
|
||||
}
|
||||
|
||||
bool API::HasMotionCallback() const {
|
||||
return device_->HasMotionCallback();
|
||||
}
|
||||
|
||||
void API::Start(const Source &source) {
|
||||
if (source == Source::VIDEO_STREAMING) {
|
||||
#ifdef WITH_FILESYSTEM
|
||||
if (!synthetic_->HasPlugin()) {
|
||||
try {
|
||||
auto &&plugin_paths = get_plugin_paths();
|
||||
if (plugin_paths.size() > 0) {
|
||||
EnablePlugin(plugin_paths[0]);
|
||||
}
|
||||
} catch (...) {
|
||||
LOG(WARNING) << "Incorrect yaml format: build.info";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
synthetic_->StartVideoStreaming();
|
||||
} else if (source == Source::MOTION_TRACKING) {
|
||||
device_->StartMotionTracking();
|
||||
} else if (source == Source::ALL) {
|
||||
Start(Source::VIDEO_STREAMING);
|
||||
Start(Source::MOTION_TRACKING);
|
||||
} else {
|
||||
LOG(ERROR) << "Unsupported source :(";
|
||||
}
|
||||
}
|
||||
|
||||
void API::Stop(const Source &source) {
|
||||
if (source == Source::VIDEO_STREAMING) {
|
||||
synthetic_->StopVideoStreaming();
|
||||
} else if (source == Source::MOTION_TRACKING) {
|
||||
device_->StopMotionTracking();
|
||||
} else if (source == Source::ALL) {
|
||||
Stop(Source::MOTION_TRACKING);
|
||||
// Must stop motion tracking before video streaming and sleep a moment here
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
Stop(Source::VIDEO_STREAMING);
|
||||
} else {
|
||||
LOG(ERROR) << "Unsupported source :(";
|
||||
}
|
||||
}
|
||||
|
||||
void API::WaitForStreams() {
|
||||
synthetic_->WaitForStreams();
|
||||
}
|
||||
|
||||
void API::EnableStreamData(const Stream &stream) {
|
||||
synthetic_->EnableStreamData(stream);
|
||||
}
|
||||
|
||||
void API::DisableStreamData(const Stream &stream) {
|
||||
synthetic_->DisableStreamData(stream);
|
||||
}
|
||||
|
||||
api::StreamData API::GetStreamData(const Stream &stream) {
|
||||
return synthetic_->GetStreamData(stream);
|
||||
}
|
||||
|
||||
std::vector<api::StreamData> API::GetStreamDatas(const Stream &stream) {
|
||||
return synthetic_->GetStreamDatas(stream);
|
||||
}
|
||||
|
||||
void API::EnableMotionDatas(std::size_t max_size) {
|
||||
device_->EnableMotionDatas(max_size);
|
||||
}
|
||||
|
||||
std::vector<api::MotionData> API::GetMotionDatas() {
|
||||
std::vector<api::MotionData> datas;
|
||||
for (auto &&data : device_->GetMotionDatas()) {
|
||||
datas.push_back({data.imu});
|
||||
}
|
||||
return datas;
|
||||
}
|
||||
|
||||
void API::EnablePlugin(const std::string &path) {
|
||||
static DL dl;
|
||||
CHECK(dl.Open(path.c_str())) << "Open plugin failed: " << path;
|
||||
|
||||
plugin_version_code_t *plugin_version_code =
|
||||
dl.Sym<plugin_version_code_t>("plugin_version_code");
|
||||
LOG(INFO) << "Enable plugin success";
|
||||
LOG(INFO) << " version code: " << plugin_version_code();
|
||||
LOG(INFO) << " path: " << path;
|
||||
|
||||
plugin_create_t *plugin_create = dl.Sym<plugin_create_t>("plugin_create");
|
||||
plugin_destroy_t *plugin_destroy = dl.Sym<plugin_destroy_t>("plugin_destroy");
|
||||
|
||||
std::shared_ptr<Plugin> plugin(plugin_create(), plugin_destroy);
|
||||
plugin->OnCreate(this);
|
||||
|
||||
synthetic_->SetPlugin(plugin);
|
||||
}
|
||||
|
||||
std::shared_ptr<Device> API::device() {
|
||||
return device_;
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
283
src/api/api.h
Normal file
283
src/api/api.h
Normal file
@@ -0,0 +1,283 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_API_H_ // NOLINT
|
||||
#define MYNTEYE_API_H_
|
||||
#pragma once
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
#include "mynteye/types.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class Device;
|
||||
class Synthetic;
|
||||
|
||||
namespace device {
|
||||
|
||||
class Frame;
|
||||
|
||||
} // namespace device
|
||||
|
||||
namespace api {
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* API stream data.
|
||||
*/
|
||||
struct MYNTEYE_API StreamData {
|
||||
/** ImgData. */
|
||||
std::shared_ptr<ImgData> img;
|
||||
/** Frame. */
|
||||
cv::Mat frame;
|
||||
/** Raw frame. */
|
||||
std::shared_ptr<device::Frame> frame_raw;
|
||||
|
||||
bool operator==(const StreamData &other) const {
|
||||
if (img && other.img) {
|
||||
return img->frame_id == other.img->frame_id &&
|
||||
img->timestamp == other.img->timestamp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* API motion data.
|
||||
*/
|
||||
struct MYNTEYE_API MotionData {
|
||||
/** ImuData. */
|
||||
std::shared_ptr<ImuData> imu;
|
||||
|
||||
bool operator==(const MotionData &other) const {
|
||||
if (imu && other.imu) {
|
||||
return imu->frame_id == other.imu->frame_id &&
|
||||
imu->timestamp == other.imu->timestamp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
/**
|
||||
* The API class to communicate with MYNT® EYE device.
|
||||
*/
|
||||
class MYNTEYE_API API {
|
||||
public:
|
||||
/** The api::StreamData callback. */
|
||||
using stream_callback_t = std::function<void(const api::StreamData &data)>;
|
||||
/** The api::MotionData callback. */
|
||||
using motion_callback_t = std::function<void(const api::MotionData &data)>;
|
||||
|
||||
explicit API(std::shared_ptr<Device> device);
|
||||
virtual ~API();
|
||||
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @return the API instance.
|
||||
* @note This will call device::select() to select a device.
|
||||
*/
|
||||
static std::shared_ptr<API> Create();
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param device the selected device.
|
||||
* @return the API instance.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(std::shared_ptr<Device> device);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param argc the arg count.
|
||||
* @param argv the arg values.
|
||||
* @return the API instance.
|
||||
* @note This will init glog with args and call device::select() to select a
|
||||
* device.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(int argc, char *argv[]);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param argc the arg count.
|
||||
* @param argv the arg values.
|
||||
* @param device the selected device.
|
||||
* @return the API instance.
|
||||
* @note This will init glog with args.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device);
|
||||
|
||||
/**
|
||||
* Get the model.
|
||||
*/
|
||||
Model GetModel() const;
|
||||
|
||||
/**
|
||||
* Supports the stream or not.
|
||||
*/
|
||||
bool Supports(const Stream &stream) const;
|
||||
/**
|
||||
* Supports the capability or not.
|
||||
*/
|
||||
bool Supports(const Capabilities &capability) const;
|
||||
/**
|
||||
* Supports the option or not.
|
||||
*/
|
||||
bool Supports(const Option &option) const;
|
||||
/**
|
||||
* Supports the addon or not.
|
||||
*/
|
||||
bool Supports(const AddOns &addon) const;
|
||||
|
||||
/**
|
||||
* Get all stream requests of the capability.
|
||||
*/
|
||||
const std::vector<StreamRequest> &GetStreamRequests(
|
||||
const Capabilities &capability) const;
|
||||
/**
|
||||
* Config the stream request to the capability.
|
||||
*/
|
||||
void ConfigStreamRequest(
|
||||
const Capabilities &capability, const StreamRequest &request);
|
||||
|
||||
/**
|
||||
* Get the device info.
|
||||
*/
|
||||
std::string GetInfo(const Info &info) const;
|
||||
|
||||
/**
|
||||
* Get the intrinsics of stream.
|
||||
*/
|
||||
Intrinsics GetIntrinsics(const Stream &stream) const;
|
||||
/**
|
||||
* Get the extrinsics from one stream to another.
|
||||
*/
|
||||
Extrinsics GetExtrinsics(const Stream &from, const Stream &to) const;
|
||||
/**
|
||||
* Get the intrinsics of motion.
|
||||
*/
|
||||
MotionIntrinsics GetMotionIntrinsics() const;
|
||||
/**
|
||||
* Get the extrinsics from one stream to motion.
|
||||
*/
|
||||
Extrinsics GetMotionExtrinsics(const Stream &from) const;
|
||||
|
||||
/**
|
||||
* Log all option infos.
|
||||
*/
|
||||
void LogOptionInfos() const;
|
||||
/**
|
||||
* Get the option info.
|
||||
*/
|
||||
OptionInfo GetOptionInfo(const Option &option) const;
|
||||
|
||||
/**
|
||||
* Get the option value.
|
||||
*/
|
||||
std::int32_t GetOptionValue(const Option &option) const;
|
||||
/**
|
||||
* Set the option value.
|
||||
*/
|
||||
void SetOptionValue(const Option &option, std::int32_t value);
|
||||
|
||||
/**
|
||||
* Run the option action.
|
||||
*/
|
||||
bool RunOptionAction(const Option &option) const;
|
||||
|
||||
/**
|
||||
* Set the callback of stream.
|
||||
*/
|
||||
void SetStreamCallback(const Stream &stream, stream_callback_t callback);
|
||||
/**
|
||||
* Set the callback of motion.
|
||||
*/
|
||||
void SetMotionCallback(motion_callback_t callback);
|
||||
|
||||
/**
|
||||
* Has the callback of stream.
|
||||
*/
|
||||
bool HasStreamCallback(const Stream &stream) const;
|
||||
/**
|
||||
* Has the callback of motion.
|
||||
*/
|
||||
bool HasMotionCallback() const;
|
||||
|
||||
/**
|
||||
* Start capturing the source.
|
||||
*/
|
||||
void Start(const Source &source);
|
||||
/**
|
||||
* Stop capturing the source.
|
||||
*/
|
||||
void Stop(const Source &source);
|
||||
|
||||
/**
|
||||
* Wait the streams are ready.
|
||||
*/
|
||||
void WaitForStreams();
|
||||
|
||||
/**
|
||||
* Enable the data of stream.
|
||||
* @note must enable the stream if it's a synthetic one. This means the stream
|
||||
* in not native, the device has the capability to provide this stream, but
|
||||
* still support this stream.
|
||||
*/
|
||||
void EnableStreamData(const Stream &stream);
|
||||
/**
|
||||
* Disable the data of stream.
|
||||
*/
|
||||
void DisableStreamData(const Stream &stream);
|
||||
|
||||
/**
|
||||
* Get the latest data of stream.
|
||||
*/
|
||||
api::StreamData GetStreamData(const Stream &stream);
|
||||
/**
|
||||
* Get the datas of stream.
|
||||
* @note default cache 4 datas at most.
|
||||
*/
|
||||
std::vector<api::StreamData> GetStreamDatas(const Stream &stream);
|
||||
|
||||
/**
|
||||
* Enable cache motion datas.
|
||||
*/
|
||||
void EnableMotionDatas(
|
||||
std::size_t max_size = std::numeric_limits<std::size_t>::max());
|
||||
/**
|
||||
* Get the motion datas.
|
||||
*/
|
||||
std::vector<api::MotionData> GetMotionDatas();
|
||||
|
||||
/**
|
||||
* Enable the plugin.
|
||||
*/
|
||||
void EnablePlugin(const std::string &path);
|
||||
|
||||
std::shared_ptr<Device> device();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Device> device_;
|
||||
|
||||
std::unique_ptr<Synthetic> synthetic_;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_API_H_ NOLINT
|
||||
140
src/api/plugin.h
Normal file
140
src/api/plugin.h
Normal file
@@ -0,0 +1,140 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_PLUGIN_H_ // NOLINT
|
||||
#define MYNTEYE_PLUGIN_H_
|
||||
#pragma once
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
#ifndef MYNTEYE_PLUGIN_VERSION_CODE
|
||||
#define MYNTEYE_PLUGIN_VERSION_CODE 0
|
||||
#endif
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class API;
|
||||
struct Object;
|
||||
|
||||
/**
|
||||
* The plugin which could implement processing by yourself.
|
||||
*/
|
||||
class MYNTEYE_API Plugin {
|
||||
public:
|
||||
Plugin() = default;
|
||||
virtual ~Plugin() = 0;
|
||||
|
||||
/**
|
||||
* Called when plugin created.
|
||||
* @param api the API instacne.
|
||||
*/
|
||||
virtual void OnCreate(API *api) {
|
||||
api_ = api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when process rectify.
|
||||
* @param in input object.
|
||||
* @param out output object.
|
||||
* @return `true` if you process rectify.
|
||||
*/
|
||||
virtual bool OnRectifyProcess(Object *const in, Object *const out) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when process disparity.
|
||||
* @param in input object.
|
||||
* @param out output object.
|
||||
* @return `true` if you process disparity.
|
||||
*/
|
||||
virtual bool OnDisparityProcess(Object *const in, Object *const out) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when process normalized disparity.
|
||||
* @param in input object.
|
||||
* @param out output object.
|
||||
* @return `true` if you process normalized disparity.
|
||||
*/
|
||||
virtual bool OnDisparityNormalizedProcess(
|
||||
Object *const in, Object *const out) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when process points.
|
||||
* @param in input object.
|
||||
* @param out output object.
|
||||
* @return `true` if you process points.
|
||||
*/
|
||||
virtual bool OnPointsProcess(Object *const in, Object *const out) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when process depth.
|
||||
* @param in input object.
|
||||
* @param out output object.
|
||||
* @return `true` if you process depth.
|
||||
*/
|
||||
virtual bool OnDepthProcess(Object *const in, Object *const out) {
|
||||
UNUSED(in)
|
||||
UNUSED(out)
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
API *api_;
|
||||
};
|
||||
|
||||
inline Plugin::~Plugin() = default;
|
||||
|
||||
using plugin_version_code_t = std::uint32_t();
|
||||
using plugin_create_t = Plugin *();
|
||||
using plugin_destroy_t = void(Plugin *);
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
extern "C" {
|
||||
|
||||
/**
|
||||
* Get the plugin version code.
|
||||
*/
|
||||
MYNTEYE_API std::uint32_t plugin_version_code();
|
||||
|
||||
/**
|
||||
* Create the plugin.
|
||||
*/
|
||||
MYNTEYE_API mynteye::Plugin *plugin_create();
|
||||
|
||||
/**
|
||||
* Destroy the plugin.
|
||||
*/
|
||||
MYNTEYE_API void plugin_destroy(mynteye::Plugin *plugin);
|
||||
}
|
||||
|
||||
#endif // MYNTEYE_PLUGIN_H_ NOLINT
|
||||
52
src/api/processor/depth_processor.cc
Normal file
52
src/api/processor/depth_processor.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
// 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 "api/processor/depth_processor.h"
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char DepthProcessor::NAME[] = "DepthProcessor";
|
||||
|
||||
DepthProcessor::DepthProcessor(std::int32_t proc_period)
|
||||
: Processor(std::move(proc_period)) {
|
||||
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
||||
}
|
||||
|
||||
DepthProcessor::~DepthProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string DepthProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *DepthProcessor::OnCreateOutput() {
|
||||
return new ObjMat();
|
||||
}
|
||||
|
||||
bool DepthProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
UNUSED(parent)
|
||||
const ObjMat *input = Object::Cast<ObjMat>(in);
|
||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||
cv::Mat channels[3 /*input->value.channels()*/];
|
||||
cv::split(input->value, channels);
|
||||
channels[2].convertTo(output->value, CV_16UC1);
|
||||
return true;
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
41
src/api/processor/depth_processor.h
Normal file
41
src/api/processor/depth_processor.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_DEPTH_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_DEPTH_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class DepthProcessor : public Processor {
|
||||
public:
|
||||
static const char NAME[];
|
||||
|
||||
explicit DepthProcessor(std::int32_t proc_period = 0);
|
||||
virtual ~DepthProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
bool OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DEPTH_PROCESSOR_H_ NOLINT
|
||||
55
src/api/processor/disparity_normalized_processor.cc
Normal file
55
src/api/processor/disparity_normalized_processor.cc
Normal file
@@ -0,0 +1,55 @@
|
||||
// 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 "api/processor/disparity_normalized_processor.h"
|
||||
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
const char DisparityNormalizedProcessor::NAME[] =
|
||||
"DisparityNormalizedProcessor";
|
||||
|
||||
DisparityNormalizedProcessor::DisparityNormalizedProcessor(
|
||||
std::int32_t proc_period)
|
||||
: Processor(std::move(proc_period)) {
|
||||
VLOG(2) << __func__ << ": proc_period=" << proc_period;
|
||||
}
|
||||
|
||||
DisparityNormalizedProcessor::~DisparityNormalizedProcessor() {
|
||||
VLOG(2) << __func__;
|
||||
}
|
||||
|
||||
std::string DisparityNormalizedProcessor::Name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
Object *DisparityNormalizedProcessor::OnCreateOutput() {
|
||||
return new ObjMat();
|
||||
}
|
||||
|
||||
bool DisparityNormalizedProcessor::OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) {
|
||||
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);
|
||||
// cv::normalize maybe return empty ==
|
||||
return !output->value.empty();
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
41
src/api/processor/disparity_normalized_processor.h
Normal file
41
src/api/processor/disparity_normalized_processor.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
#ifndef MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ // NOLINT
|
||||
#define MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/processor/processor.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
class DisparityNormalizedProcessor : public Processor {
|
||||
public:
|
||||
static const char NAME[];
|
||||
|
||||
explicit DisparityNormalizedProcessor(std::int32_t proc_period = 0);
|
||||
virtual ~DisparityNormalizedProcessor();
|
||||
|
||||
std::string Name() override;
|
||||
|
||||
protected:
|
||||
Object *OnCreateOutput() override;
|
||||
bool OnProcess(
|
||||
Object *const in, Object *const out, Processor *const parent) override;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_DISPARITY_NORMALIZED_PROCESSOR_H_ NOLINT
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user