First commit

This commit is contained in:
John Zhao 2018-03-08 15:54:14 +08:00
commit 5f1168368f
18 changed files with 3024 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.DS_Store
/doc/output/

221
CommonDefs.mk Normal file
View File

@ -0,0 +1,221 @@
ifndef _COMMON_DEFS_MAKE_
_COMMON_DEFS_MAKE_ := 1
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
COLON := :
SEMICOLON := ;
QUOTE := "
SINGLE_QUOTE := '
OPEN_PAREN := (
CLOSE_PAREN := )
# Host detection
ifeq ($(OS),Windows_NT)
HOST_OS := Win
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
HOST_ARCH := x64
else
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
HOST_ARCH := x64
else ifeq ($(PROCESSOR_ARCHITECTURE),x86)
HOST_ARCH := x86
else
DUMMY := $(error "Can't detect host arch")
endif
endif
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),)
ifneq ($(findstring MINGW,$(UNAME_S)),)
HOST_OS := MinGW
endif
endif
else
UNAME_S := $(shell uname -s)
ifneq ($(findstring Linux,$(UNAME_S)),)
HOST_OS := Linux
else ifneq ($(findstring Darwin,$(UNAME_S)),)
HOST_OS := Mac
else ifneq ($(findstring MINGW,$(UNAME_S)),)
HOST_OS := MinGW
else ifneq ($(findstring MSYS,$(UNAME_S)),)
# Need MSYS on Windows
HOST_OS := Win
else
DUMMY := $(error "Can't detect host os")
endif
UNAME_M = $(shell uname -m)
ifneq ($(findstring x86_64,$(UNAME_M)),)
HOST_ARCH := x64
else ifneq ($(findstring x86,$(UNAME_M)),)
HOST_ARCH := x86
else ifneq ($(findstring i686,$(UNAME_M)),)
HOST_ARCH := x86
else ifneq ($(findstring i386,$(UNAME_M)),)
HOST_ARCH := x86
else ifneq ($(findstring arm,$(UNAME_M)),)
HOST_ARCH := Arm
else ifneq ($(findstring aarch64,$(UNAME_M)),)
HOST_ARCH := AArch64
else
DUMMY := $(error "Can't detect host arch")
endif
endif
HOST_NAME := $(HOST_OS)
ifeq ($(HOST_OS),Linux)
UNAME_A = $(shell uname -a)
ifneq ($(findstring tegra,$(UNAME_A)),)
HOST_NAME := Tegra
else ifneq ($(findstring jetsonbot,$(UNAME_A)),)
HOST_NAME := Tegra
#else ifneq ($(findstring firefly,$(UNAME_A)),)
# HOST_NAME := Firefly
endif
endif
# Function
mkinfo = $(info + $1)
lower = $(shell echo $1 | tr '[:upper:]' '[:lower:]')
# Command
ifeq ($(HOST_OS),MinGW)
ECHO := echo -e
CC := x86_64-w64-mingw32-gcc
CXX := x86_64-w64-mingw32-g++
MAKE := mingw32-make
BUILD := $(MAKE)
else ifeq ($(HOST_OS),Win)
ECHO := echo -e
CC := cl
CXX := cl
MAKE := make
BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release
else
# mac & linux
ECHO := echo
# Set realpath for linux because of compiler not found with wrong path when cmake again
CC := /usr/bin/cc
CXX := /usr/bin/c++
MAKE := make
BUILD := $(MAKE)
endif
FIND := $(shell ./scripts/getfind.sh)
ifeq ($(HOST_OS),Mac)
LDD := otool -L
else
LDD := ldd
endif
# CMake
CMAKE := cmake -DCMAKE_BUILD_TYPE=Release
ifneq ($(CC),)
CMAKE := $(CMAKE) -DCMAKE_C_COMPILER=$(CC)
endif
ifneq ($(CXX),)
CMAKE := $(CMAKE) -DCMAKE_CXX_COMPILER=$(CXX)
endif
ifneq ($(HOST_OS),Win)
ifneq ($(MAKE),)
CMAKE := $(CMAKE) -DCMAKE_MAKE_PROGRAM=$(MAKE)
endif
endif
CMAKE_OPTIONS :=
#CMAKE_OPTIONS += -DDEBUG=ON -DTIMECOST=ON
#CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
CMAKE_OPTIONS_AFTER :=
ifeq ($(HOST_OS),MinGW)
CMAKE += -G "MinGW Makefiles"
endif
ifeq ($(HOST_OS),Win)
ifeq ($(HOST_ARCH),x64)
VS_VERSION = $(shell echo "$(shell which cl)" | sed -e "s/.*Visual\sStudio\s\([0-9]\+\).*/\1/g")
ifeq (15,$(VS_VERSION))
CMAKE += -G "Visual Studio 15 2017 Win64"
else ifeq (14,$(VS_VERSION))
CMAKE += -G "Visual Studio 14 2015 Win64"
else ifeq (12,$(VS_VERSION))
CMAKE += -G "Visual Studio 12 2013 Win64"
else ifeq (11,$(VS_VERSION))
CMAKE += -G "Visual Studio 11 2012 Win64"
else ifeq (10,$(VS_VERSION))
CMAKE += -G "Visual Studio 10 2010 Win64"
else ifeq (9,$(VS_VERSION))
CMAKE += -G "Visual Studio 9 2008 Win64"
else ifeq (8,$(VS_VERSION))
CMAKE += -G "Visual Studio 8 2005 Win64"
else
$(call mkinfo,"Connot specify Visual Studio Win64")
endif
endif
endif
# Shell
# `sh` is not possible to export a function
# function __cp() {}; export -f __cp;
define echo
text="$1"; options="$2"; \
[ -z "$2" ] && options="1;33"; \
$(ECHO) "\033[$${options}m$${text}\033[0m"
endef
define rm
[ ! -e "$1" ] || (rm -rf "$1" && $(ECHO) "RM: $1")
endef
define rm_f
dir="$2"; [ -e "$${dir}" ] || dir="."; \
$(FIND) "$${dir}" -mindepth 1 -maxdepth 1 -name "$1" | while read -r p; do \
$(call rm,$$p); \
done
endef
define mkdir
([ -e "$1" ] || mkdir -p "$1")
endef
define cd
$(call mkdir,$1) && cd "$1" && $(ECHO) "CD: $1"
endef
define cp
(([ -d "$1" ] && $(call mkdir,$2) && cp -Rpv$3 "$1/." "$2") || \
([ -f "$1" ] && $(call mkdir,$$(dirname "$2")) && cp -Rpv$3 "$1" "$2"))
endef
define cp_if
if [ -e "$2" ]; then \
$(ECHO) "CP: $1 > $2 already done"; \
else \
$(ECHO) "CP: $1 > $2" && $(call cp,$1,$2); \
fi
endef
define cmake_build
work_dir="$1"; \
build_dir="$2"; [ -z "$2" ] && build_dir=..; \
build_options="$3"; \
$(call cd,$${work_dir}) && $(CMAKE) $${build_options} $(CMAKE_OPTIONS) $${build_dir} $(CMAKE_OPTIONS_AFTER) && $(BUILD)
endef
endif # _COMMON_DEFS_MAKE_

13
LICENSE Normal file
View File

@ -0,0 +1,13 @@
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.

23
Makefile Normal file
View File

@ -0,0 +1,23 @@
include CommonDefs.mk
.DEFAULT_GOAL := help
.PHONY: help apidoc
help:
@echo "Usage:"
@echo " make help show help message"
@echo " make apidoc make api doc"
@echo " make opendoc open api doc (html)"
apidoc:
@$(call echo,Make $@)
@sh ./doc/build.sh
opendoc: apidoc
@$(call echo,Make $@)
@$(shell sh ./doc/langs.sh 1); \
for lang in "$${LANGS[@]}"; do \
html=./doc/output/$$lang/html/index.html; \
[ -f "$$html" ] && sh ./scripts/open.sh $$html; \
done

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# MYNT® EYE SDK
## Overview
MYNT® EYE SDK 2.0 is a cross-platform library for MYNT® EYE cameras.
## License
This project is licensed under the Apache License, Version 2.0. Copyright 2018 Slightech Co., Ltd.

36
doc/build.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env sh
# _VERBOSE_=1
# _TEST_=1
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
ROOT_DIR=$(realpath "$BASE_DIR/..")
SCRIPTS_DIR="$ROOT_DIR/scripts"
source "$SCRIPTS_DIR/common/echo.sh"
source "$SCRIPTS_DIR/common/mkdir.sh"
source "$SCRIPTS_DIR/common/detect.sh"
_detect "doxygen"
_detect "pdflatex"
source "$BASE_DIR/langs.sh"
DOXYFILE="api.doxyfile"
OUTPUT="$BASE_DIR/output"
for lang in "${LANGS[@]}"; do
_echo_s "Build doc $lang"
cd "$BASE_DIR/$lang"
if [ -f "$DOXYFILE" ]; then
_mkdir "$OUTPUT/$lang"
_echo_i "doxygen $DOXYFILE"
doxygen $DOXYFILE
if [ -f "$OUTPUT/$lang/latex/Makefile" ]; then
_echo_in "doxygen make latex"
cd "$OUTPUT/$lang/latex" && make
[ -f "refman.pdf" ] && mv "refman.pdf" "../mynteye-apidoc.pdf"
fi
_echo_d "doxygen completed"
else
_echo_e "$DOXYFILE not found"
fi
done

6
doc/langs.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
LANGS=(
en
zh-Hans
)
[ $# -gt 0 ] && echo "LANGS=(${LANGS[@]})"

3
doc/static/custom.css vendored Normal file
View File

@ -0,0 +1,3 @@
#projectlogo img {
margin: 1em 0.5em 1em 1em;
}

BIN
doc/static/images/icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

2473
doc/zh-Hans/api.doxyfile Normal file

File diff suppressed because it is too large Load Diff

1
samples/README.md Normal file
View File

@ -0,0 +1 @@
# Samples for MYNT® EYE cameras

50
scripts/common/detect.sh Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env sh
[ -n "${_DETECT_SH_}" ] && return || readonly _DETECT_SH_=1
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: detect.sh"
_detect() {
cmd="$1"; optional="$2"; verbose="$3";
[ -n "$verbose" ] || [ -z "${_VERBOSE_}" ] || verbose=1;
if ! type "$cmd" &> /dev/null; then
[ -z "$verbose" ] || echo "-- DETECT: $cmd not found"
if [ -z "$optional" ]; then
echo >&2 "-- DETECT: $cmd not found, but required"
exit 1
fi
else
[ -z "$verbose" ] || echo "-- DETECT: $cmd found"
eval "${cmd}_FOUND=1"
fi
}
_detect_fn() {
[ `type -t $1`"" == "function" ]
}
if [ -n "${_TEST_}" ]; then
echo "-- TEST_BEG: _detect"
_CMDS=(ls none)
for _cmd in "${_CMDS[@]}"; do
_detect "$_cmd" 1
_CMD_FOUND="${_cmd}_FOUND"
if [ -n "${!_CMD_FOUND}" ]; then
echo "-- ${_CMD_FOUND} set"
else
echo "-- ${_CMD_FOUND} unset"
fi
done
echo "-- TEST_END: _detect"
echo "-- TEST_BEG: _detect_fn"
_FUNCS=(_detect none)
for _fn in "${_FUNCS[@]}"; do
if _detect_fn "$_fn"; then
echo "-- $_fn function exists"
else
echo "-- $_fn function not exist"
fi
done
echo "-- TEST_END: _detect_fn"
fi

66
scripts/common/echo.sh Normal file
View File

@ -0,0 +1,66 @@
#!/usr/bin/env sh
[ -n "${_ECHO_SH_}" ] && return || readonly _ECHO_SH_=1
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: echo.sh"
# if [ -n "$SCRIPTS_DIR" ]; then
# source "$SCRIPTS_DIR/common/echo.sh"
# else
# source "$(dirname "$0")/echo.sh"
# fi
ECHO="echo"
# task colors
COLOR_STRONG="1;35" # Magenta
COLOR_INFO="1;34" # Blue
COLOR_DONE="1;32" # Green
COLOR_ERROR="1;31" # Red
# action colors
COLOR_INFO_NORMAL="34"
COLOR_DONE_NORMAL="32"
COLOR_ERROR_NORMAL="31"
_echo_() {
text="$1"; shift; options="$1"; shift;
[ -z "$options" ] && options="$COLOR_STRONG";
$ECHO "\033[${options}m${text}\033[0m"
}
_echo_e_() {
text="$1"; shift; options="$1"; shift;
[ -z "$options" ] && options="$COLOR_ERROR";
$ECHO >&2 "\033[${options}m${text}\033[0m"
}
_echo() {
$ECHO "$@"
}
_echo_s() {
_echo_ "$1" "$COLOR_STRONG"
}
_echo_i() {
_echo_ "$1" "$COLOR_INFO"
}
_echo_d() {
_echo_ "$1" "$COLOR_DONE"
}
_echo_e() {
_echo_e_ "$1" "$COLOR_ERROR"
}
_echo_in() {
_echo_ "$1" "$COLOR_INFO_NORMAL"
}
_echo_dn() {
_echo_ "$1" "$COLOR_DONE_NORMAL"
}
_echo_en() {
_echo_e_ "$1" "$COLOR_ERROR_NORMAL"
}

62
scripts/common/host.sh Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env sh
[ -n "${_HOST_SH_}" ] && return || readonly _HOST_SH_=1
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: host.sh"
_host_contains_() {
[ `echo $1 | grep -c "$2"` -gt 0 ]
}
if _host_contains_ "$OS" "Windows_NT"; then
HOST_OS="Win"
if _host_contains_ "$PROCESSOR_ARCHITEW6432" "AMD64"; then
HOST_ARCH="x64"
else
if _host_contains_ "$PROCESSOR_ARCHITECTURE" "AMD64"; then
HOST_ARCH="x64"
elif _host_contains_ "$PROCESSOR_ARCHITECTURE" "x86"; then
HOST_ARCH="x86"
else
echo >&2 "-- HOST: unknown arch :("
exit 1
fi
fi
else
_UNAME_S=$(uname -s)
if _host_contains_ "$_UNAME_S" "Linux"; then
HOST_OS="Linux"
elif _host_contains_ "$_UNAME_S" "Darwin"; then
HOST_OS="Mac"
elif [ -n "$Windows_NT" ]; then
HOST_OS="Win"
else
echo >&2 "-- HOST: unknown os :("
exit 1
fi
_UNAME_M=$(uname -m)
if _host_contains_ "$_UNAME_M" "x86_64"; then
HOST_ARCH="x64"
elif _host_contains_ "$_UNAME_M" "x86\|i686\|i386"; then
HOST_ARCH="x86"
elif _host_contains_ "$_UNAME_M" "arm"; then
HOST_ARCH="Arm"
elif _host_contains_ "$_UNAME_M" "aarch64"; then
HOST_ARCH="AArch64"
else
echo >&2 "-- HOST: unknown arch :("
exit 1
fi
fi
if [ -n "${_VERBOSE_}" ]; then
echo "-- HOST_OS: $HOST_OS"
echo "-- HOST_ARCH: $HOST_ARCH"
fi

25
scripts/common/mkdir.sh Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env sh
[ -n "${_MKDIR_SH_}" ] && return || readonly _MKDIR_SH_=1
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: mkdir.sh"
MKDIR="mkdir -p"
_mkdir() {
dir="$1"; required="$2"; verbose="$3";
[ -n "$verbose" ] || [ -z "${_VERBOSE_}" ] || verbose=1;
if [ -e "$dir" ]; then
if [ -d "$dir" ]; then
[ -z "$verbose" ] || echo "-- MKDIR: $dir exists"
else
[ -z "$verbose" ] || echo >&2 "-- MKDIR: $dir not directory"
if [ -n "$required" ]; then
echo >&2 "-- MKDIR: $dir not directory, but required"
exit 1
fi
fi
else
[ -z "$verbose" ] || echo "-- MKDIR: $dir creates"
$MKDIR "$dir"
fi
}

13
scripts/getfind.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env sh
if type where &> /dev/null; then
for i in `where find`; do
# find on MSYS instead of Windows
if [ `echo $i | grep -c "msys"` -gt 0 ]; then
echo "${i%.exe}" | tr -d "[:space:]" | sed -e 's/\\/\//g'
exit
fi
done
fi
echo "find"

19
scripts/open.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env sh
BASE_DIR=$(cd "$(dirname "$0")" && pwd)
source "$BASE_DIR/common/echo.sh"
source "$BASE_DIR/common/host.sh"
if [ "$HOST_OS" = "Linux" ]; then
OPEN="xdg-open"
elif [ "$HOST_OS" = "Mac" ]; then
OPEN="open"
elif [ "$HOST_OS" = "Win" ]; then
OPEN="start"
else
_echo_e "Unknown host os :("
exit 1
fi
[ $# -gt 0 ] && $OPEN "$@"

1
wrappers/README.md Normal file
View File

@ -0,0 +1 @@
# Wrappers for MYNT® EYE SDK