Compare commits
118 Commits
2.2.2-rc0
...
devel-s210
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e32138c70a | ||
|
|
61b0d85292 | ||
|
|
1c17308a02 | ||
|
|
f6abc57475 | ||
|
|
e7dc4b7def | ||
|
|
54a9159850 | ||
|
|
9b7c36c724 | ||
|
|
f59c918e81 | ||
|
|
324e68bca5 | ||
|
|
486e9d459d | ||
|
|
515bcb5f8a | ||
|
|
a57c096e91 | ||
|
|
132cbc19e2 | ||
|
|
66eb9883ff | ||
|
|
206683b76f | ||
|
|
b9db889fa3 | ||
|
|
28ca9b60b0 | ||
|
|
0ecb395044 | ||
|
|
97701188b8 | ||
|
|
4ebdcf9bee | ||
|
|
0b2fabe550 | ||
|
|
3458aa19cf | ||
|
|
04f32f21ba | ||
|
|
1afe33f924 | ||
|
|
e832fa66b9 | ||
|
|
4c49a6af26 | ||
|
|
2a1232647a | ||
|
|
35e069a858 | ||
|
|
b625dca3df | ||
|
|
02f39dbf9e | ||
|
|
4c291588ab | ||
|
|
ce76b16c07 | ||
|
|
c7f1cb718e | ||
|
|
7a9f9139fd | ||
|
|
0c5a4f7014 | ||
|
|
f0d2950701 | ||
|
|
4fcdb6fc7b | ||
|
|
b346f7fec9 | ||
|
|
1811f20a14 | ||
|
|
bd273eed4f | ||
|
|
772ba8ebfa | ||
|
|
210ddba1ba | ||
|
|
e991d59b45 | ||
|
|
7789bc8474 | ||
|
|
7e5b3ee419 | ||
|
|
2b1288bcd4 | ||
|
|
0fc1196b52 | ||
|
|
ee19a8c857 | ||
|
|
6d39773439 | ||
|
|
677c10925f | ||
|
|
5e8bc7c05b | ||
|
|
0610d43fe5 | ||
|
|
4021c565d2 | ||
|
|
2096f93a92 | ||
|
|
d9393cfe76 | ||
|
|
ae8cc4cae2 | ||
|
|
9ef4820226 | ||
|
|
8331b8415d | ||
|
|
a57edded4b | ||
|
|
9a465b9f04 | ||
|
|
14988ffd24 | ||
|
|
48a9cd0461 | ||
|
|
5c46c72883 | ||
|
|
a9353c965a | ||
|
|
c58dd28f63 | ||
|
|
77e4411a4c | ||
|
|
2a56616195 | ||
|
|
30363e18c6 | ||
|
|
33e38bba2f | ||
|
|
59370e3e8d | ||
|
|
672b9da6f9 | ||
|
|
6a39aae98f | ||
|
|
aa7e89a502 | ||
|
|
41222abfec | ||
|
|
fbdbb5b6f6 | ||
|
|
30332a80de | ||
|
|
13e9a89b59 | ||
|
|
6feeb49d62 | ||
|
|
dfc0de34d4 | ||
|
|
3c670cedb3 | ||
|
|
8d945fe042 | ||
|
|
0d1b063942 | ||
|
|
c3fc4ba3ba | ||
|
|
0efb51ac11 | ||
|
|
94fd56a65d | ||
|
|
23e28e20a6 | ||
|
|
e40a4aaa3f | ||
|
|
5677aa56b2 | ||
|
|
ef890dee0c | ||
|
|
4614a64dc9 | ||
|
|
f92ecd4371 | ||
|
|
7f6effebbb | ||
|
|
576558e5a1 | ||
|
|
a0c3fcea89 | ||
|
|
b9def3128e | ||
|
|
67a0356a84 | ||
|
|
6d961203be | ||
|
|
26d95ec0ac | ||
|
|
00aa72166d | ||
|
|
33d3f15b86 | ||
|
|
b139fd21c3 | ||
|
|
614227a85c | ||
|
|
d2b4cc3022 | ||
|
|
a7750e8217 | ||
|
|
94053b8e35 | ||
|
|
27c8ccaac3 | ||
|
|
5ef5e8d866 | ||
|
|
f1003b63b3 | ||
|
|
900c44179d | ||
|
|
d4547c5525 | ||
|
|
c5a4161b9c | ||
|
|
08fb1a425f | ||
|
|
01c3c71516 | ||
|
|
259dc968aa | ||
|
|
b33fc86a45 | ||
|
|
25220a27ed | ||
|
|
659f03ac18 | ||
|
|
6c25f06005 |
@@ -106,7 +106,6 @@ set_outdir(
|
||||
)
|
||||
|
||||
## main
|
||||
|
||||
if(WITH_GLOG)
|
||||
add_executable(main src/main.cc)
|
||||
target_link_libraries(main glog::glog)
|
||||
@@ -124,11 +123,34 @@ if(NOT WITH_GLOG AND NOT OS_WIN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__MINIGLOG_FLAGS}")
|
||||
unset(__MINIGLOG_FLAGS)
|
||||
endif()
|
||||
if(NOT WITH_GLOG)
|
||||
list(APPEND MYNTEYE_PUBLIC_H
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/mynteye/miniglog.h
|
||||
)
|
||||
endif()
|
||||
|
||||
if(OS_WIN)
|
||||
set(UVC_SRC src/mynteye/uvc/win/uvc-wmf.cc)
|
||||
elseif(OS_MAC)
|
||||
set(UVC_SRC src/mynteye/uvc/macosx/uvc-libuvc.cc)
|
||||
add_compile_options(-x objective-c++)
|
||||
## INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx)
|
||||
## INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/VVUVCKit)
|
||||
## aux_source_directory(src/mynteye/uvc/macosx/VVUVCKit/ MAC_VVUVCKIT_SRC_LIST)
|
||||
## aux_source_directory(src/mynteye/uvc/macosx/USBBusProber/ MAC_USBBUSPROBER_SRC_LIST)
|
||||
## add_library(usbBusProber SHARED ${MAC_USBBUSPROBER_SRC_LIST})
|
||||
## set_target_properties(usbBusProber PROPERTIES FRAMEWORK TRUE )
|
||||
## add_library(vvuvckit SHARED ${MAC_VVUVCKIT_SRC_LIST})
|
||||
## set_target_properties(vvuvckit PROPERTIES FRAMEWORK TRUE )
|
||||
|
||||
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/USBBusProber.framework/Headers)
|
||||
INCLUDE_DIRECTORIES(src/mynteye/uvc/macosx/VVUVCKit.framework/Headers)
|
||||
find_library(VVUVCKIT_LIBRARY VVUVCKit PATHS src/mynteye/uvc/macosx)
|
||||
find_library(USB_LIBRARY USBBusProber PATHS src/mynteye/uvc/macosx)
|
||||
MARK_AS_ADVANCED (VVUVCKIT_LIBRARY USB_LIBRARY)
|
||||
SET(OSX_EXTRA_LIBS ${VVUVCKIT_LIBRARY} ${USB_LIBRARY})
|
||||
|
||||
set(UVC_SRC src/mynteye/uvc/macosx/CameraEngine.cpp src/mynteye/uvc/macosx/AVfoundationCamera.mm src/mynteye/uvc/macosx/uvc-vvuvckit.cc )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework CoreFoundation -framework AVFoundation -framework IOKit -framework AppKit -framework Cocoa -framework CoreMedia -framework CoreData -framework Foundation -framework CoreVideo ${__MACUVCLOG_FLAGS}")
|
||||
|
||||
find_package(libuvc REQUIRED)
|
||||
set(UVC_LIB ${libuvc_LIBRARIES})
|
||||
@@ -186,6 +208,9 @@ endif()
|
||||
|
||||
add_library(${MYNTEYE_NAME} SHARED ${MYNTEYE_SRCS})
|
||||
target_link_libraries(${MYNTEYE_NAME} ${MYNTEYE_LINKLIBS})
|
||||
if(OS_MAC)
|
||||
target_link_libraries( ${MYNTEYE_NAME} ${OSX_EXTRA_LIBS} )
|
||||
endif()
|
||||
target_link_threads(${MYNTEYE_NAME})
|
||||
|
||||
if(OS_WIN)
|
||||
|
||||
12
Makefile
12
Makefile
@@ -24,7 +24,7 @@ MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
|
||||
|
||||
SUDO ?= sudo
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
help:
|
||||
@echo "Usage:"
|
||||
@@ -44,7 +44,7 @@ help:
|
||||
|
||||
.PHONY: help
|
||||
|
||||
all: test samples tools
|
||||
all: init samples tools ros
|
||||
|
||||
.PHONY: all
|
||||
|
||||
@@ -78,7 +78,7 @@ submodules:
|
||||
|
||||
# init
|
||||
|
||||
init: submodules
|
||||
init:
|
||||
@$(call echo,Make $@)
|
||||
@$(SH) ./scripts/init.sh $(INIT_OPTIONS)
|
||||
|
||||
@@ -86,7 +86,7 @@ init: submodules
|
||||
|
||||
# build
|
||||
|
||||
build: submodules
|
||||
build:
|
||||
@$(call echo,Make $@)
|
||||
ifeq ($(HOST_OS),Win)
|
||||
@$(call cmake_build,./_build,..,-DCMAKE_INSTALL_PREFIX=$(MKFILE_DIR)/_install)
|
||||
@@ -98,7 +98,7 @@ endif
|
||||
|
||||
# test
|
||||
|
||||
test: install
|
||||
test: submodules install
|
||||
@$(call echo,Make $@)
|
||||
@$(call echo,Make gtest,33)
|
||||
ifeq ($(HOST_OS),Win)
|
||||
@@ -139,8 +139,8 @@ endif
|
||||
uninstall:
|
||||
@$(call echo,Make $@)
|
||||
ifeq ($(HOST_OS),Linux)
|
||||
$(SUDO) rm -rf /usr/local/lib/libmynteye*
|
||||
$(SUDO) rm -rf /usr/local/include/mynteye/
|
||||
$(SUDO) rm -rf /usr/local/lib/libmynteye.so*
|
||||
$(SUDO) rm -rf /usr/local/lib/cmake/mynteye/
|
||||
$(SUDO) rm -rf /usr/local/share/mynteye/
|
||||
endif
|
||||
|
||||
12
README.md
12
README.md
@@ -1,6 +1,6 @@
|
||||
# MYNT® EYE S SDK
|
||||
|
||||
[](https://github.com/slightech/MYNT-EYE-S-SDK)
|
||||
[](https://github.com/slightech/MYNT-EYE-S-SDK)
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -17,11 +17,11 @@ Please follow the guide doc to install the SDK on different platforms.
|
||||
## Documentations
|
||||
|
||||
* [API Doc](https://github.com/slightech/MYNT-EYE-S-SDK/releases): API reference, some guides and data spec.
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2501756/mynt-eye-sdk-apidoc-2.2.1-rc-en.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2501763/mynt-eye-sdk-apidoc-2.2.1-rc-en.zip) [](https://slightech.github.io/MYNT-EYE-S-SDK/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2501770/mynt-eye-sdk-apidoc-2.2.1-rc-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2501782/mynt-eye-sdk-apidoc-2.2.1-rc-zh-Hans.zip) [](http://doc.myntai.com/resource/api/mynt-eye-sdk-apidoc-2.2.1-rc-zh-Hans/mynt-eye-sdk-apidoc-2.2.1-rc-zh-Hans/index.html)
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683636/mynt-eye-s-sdk-apidoc-2.2.2-en.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683637/mynt-eye-s-sdk-apidoc-2.2.2-en.zip) [](https://slightech.github.io/MYNT-EYE-S-SDK/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683638/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK/files/2683639/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans.zip) [](http://doc.myntai.com/resource/api/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans/mynt-eye-s-sdk-apidoc-2.2.2-zh-Hans/index.html)
|
||||
* [Guide Doc](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/releases): How to install and start using the SDK.
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2501821/mynt-eye-sdk-guide-2.2.1-rc-en.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2501822/mynt-eye-sdk-guide-2.2.1-rc-en.zip) [](https://slightech.github.io/MYNT-EYE-S-SDK-Guide/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2501823/mynt-eye-sdk-guide-2.2.1-rc-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2501827/mynt-eye-sdk-guide-2.2.1-rc-zh-Hans.zip) [](http://doc.myntai.com/resource/sdk/mynt-eye-sdk-guide-2.2.1-rc-zh-Hans/mynt-eye-sdk-guide-2.2.1-rc-zh-Hans/index.html)
|
||||
* en: [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683625/mynt-eye-s-sdk-guide-2.2.2-en.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683626/mynt-eye-s-sdk-guide-2.2.2-en.zip) [](https://slightech.github.io/MYNT-EYE-S-SDK-Guide/)
|
||||
* zh-Hans: [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683627/mynt-eye-s-sdk-guide-2.2.2-zh-Hans.pdf) [](https://github.com/slightech/MYNT-EYE-S-SDK-Guide/files/2683628/mynt-eye-s-sdk-guide-2.2.2-zh-Hans.zip) [](http://doc.myntai.com/resource/sdk/mynt-eye-s-sdk-guide-2.2.2-zh-Hans/mynt-eye-s-sdk-guide-2.2.2-zh-Hans/index.html)
|
||||
|
||||
> Supported languages: `en`, `zh-Hans`.
|
||||
|
||||
@@ -29,7 +29,7 @@ Please follow the guide doc to install the SDK on different platforms.
|
||||
|
||||
[MYNTEYE_BOX]: http://doc.myntai.com/mynteye/s/download
|
||||
|
||||
Get firmwares from our online disks: [MYNTEYE_BOX][]. The latest version is `2.2.1`.
|
||||
Get firmwares from our online disks: [MYNTEYE_BOX][]. The latest version is `2.2.2`.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ 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
|
||||
@@ -32,7 +31,6 @@ option(WITH_BOOST "Include Boost support" ON)
|
||||
# Ubuntu: `sudo apt-get install libgoogle-glog-dev`
|
||||
option(WITH_GLOG "Include glog support" OFF)
|
||||
|
||||
|
||||
# packages
|
||||
|
||||
if(WITH_API)
|
||||
|
||||
@@ -38,13 +38,13 @@ PROJECT_NAME = "MYNT EYE S SDK"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.2.2-rc0
|
||||
PROJECT_NUMBER = 2.2.2
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
# quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = http://www.myntai.com/camera
|
||||
PROJECT_BRIEF = http://www.myntai.com/mynteye/standard
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
@@ -38,13 +38,13 @@ PROJECT_NAME = "MYNT EYE S SDK"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 2.2.2-rc0
|
||||
PROJECT_NUMBER = 2.2.2
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
# quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = http://www.myntai.com/camera
|
||||
PROJECT_BRIEF = http://www.myntai.com/mynteye/standard
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
|
||||
@@ -6,23 +6,22 @@
|
||||
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----- |
|
||||
| 增益 | gain | 2 | 24 | 0 | 48 | √ | 0x12 | 关闭自动曝光,手动设定的参数 |
|
||||
| 亮度 | brightness/exposure_time | 2 | 120 | 0 | 240 | √ | 0x14 | 关闭自动曝光,手动设定的参数 |
|
||||
| 对比度 | contrast/black_level_calibration | 2 | 127 | 0 | 255 | √ | 0x10 | 关闭自动曝光,手动设定的参数 |
|
||||
| 亮度 | brightness | 2 | 192 | 0 | 255 | √ | 0x14 | 关闭自动曝光,手动设定的参数 |
|
||||
|
||||
> UVC 标准协议实现的控制,有现成的 API 进行 Get & Set ,包括 Min, Max, Default 。
|
||||
|
||||
## 自定义协议
|
||||
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----- |
|
||||
| 图像帧率 | frame_rate | 2 | 25 | 10 | 60 | √ | 0x21 | XU_CAM_CTRL | 步进为5,即有效值为{10,15,20,25,30,35,40,45,50,55,60} |
|
||||
| IMU 频率 | imu_frequency | 2 | 200 | 100 | 500 | √ | 0x23 | XU_CAM_CTRL | 有效值为{100,200,250,333,500} |
|
||||
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0:开启自动曝光; 1:关闭 |
|
||||
| 最大增益 | max_gain | 2 | 48 | 0 | 48 | √ | 0x1D | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| 最大曝光时间 | max_exposure_time | 2 | 240 | 0 | 240 | √ | 0x1B | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| 期望亮度 | desired_brightness | 2 | 192 | 0 | 255 | √ | 0x19 | XU_CAM_CTRL | 开始自动曝光,可设定的阈值 |
|
||||
| IR 控制 | ir_control | 1 | 0 | 0 | 160 | × | - | XU_CAM_CTRL | |
|
||||
| HDR 模式 | hdr_mode | 1 | 0 | 0 | 1 | √ | 0x1F | XU_CAM_CTRL | 0:10-bit;1:12-bit |
|
||||
| 零漂标定 | zero_drift_calibration | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | |
|
||||
| 名称 | 字段 | 字节数 | 默认值 | 最小值 | 最大值 | 是否储存 | Flash 地址 | 所属通道 | 通道地址 | 说明 |
|
||||
| :----- | :----- | :-------- | :-------- | :-------- | :-------- | :----------- | :----------- | :----------- | :----------- | :----- |
|
||||
| 曝光模式 | exposure_mode | 1 | 0 | 0 | 1 | √ | 0x0F | XU_CAM_CTRL | 0x0100 | 0:开启自动曝光; 1:关闭 |
|
||||
| 最大增益 | max_gain | 2 | 8 | 0 | 255 | √ | 0x1D | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
|
||||
| 最大曝光时间 | max_exposure_time | 2 | 333 | 0 | 1000 | √ | 0x1B | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
|
||||
| 期望亮度 | desired_brightness | 2 | 122 | 1 | 255 | √ | 0x19 | XU_CAM_CTRL | 0x0100 | |
|
||||
| 擦除芯片 | erase_chip | | - | - | - | × | - | XU_HALF_DUPLEX | 0x0200 | |
|
||||
| 最小曝光时间 | min_exposure_time | 2 | 0 | 0 | 1000 | √ | - | XU_CAM_CTRL | 0x0100 | 开始自动曝光,可设定的阈值 |
|
||||
| 加速度计量程 | accelerometer_range | 2 | 12 | 6 | 48 | √ | - | XU_CAM_CTRL | 0x0100 | |
|
||||
| 陀螺仪量程 | gyroscope_range | 2 | 1000 | 250 | 4000 | √ | - | XU_CAM_CTRL | 0x0100 | |
|
||||
| 加速度计低通滤波 | accelerometer_low_pass_filter | 2 | 2 | 0 | 2 | √ | - | XU_CAM_CTRL | 0x0100 | |
|
||||
| 陀螺仪低通滤波 | gyroscope__low_pass_filter | 2 | 64 | 23 | 64 | √ | - | XU_CAM_CTRL | 0x0100 | |
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@
|
||||
| File | ID | Max Size |
|
||||
| :--- | :- | :------- |
|
||||
| 硬件信息 | 1 | 250 |
|
||||
| 图像参数 | 2 | 250 |
|
||||
| 图像参数 | 2 | 404 |
|
||||
| IMU 参数 | 4 | 500 |
|
||||
|
||||
@@ -3,20 +3,19 @@
|
||||
| 名称 | 字段 | 单位 | 字节数 | 说明 |
|
||||
| :----- | :----- | :----- | :-------- | :----- |
|
||||
| 帧 ID | frame_id | - | 2 | uint16_t; [0,65535] |
|
||||
| 时间戳 | timestamp | 10 us | 4 | uint32_t |
|
||||
| 曝光时间 | exposure_time | 10 us | 2 | uint16_t |
|
||||
| 时间戳 | timestamp | 1 us | 8 | uint64_t |
|
||||
| 曝光时间 | exposure_time | 1 us | 2 | uint16_t |
|
||||
|
||||
> 图像数据传输方式:倒序排在图像尾部。
|
||||
|
||||
## 图像数据包
|
||||
|
||||
| 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 | 时间戳 | 曝光时间 | 校验码(数据内容所有字节异或) |
|
||||
| Name | Header | Size | FrameID | Timestamp | ExposureTime | Checksum |
|
||||
| :--- | :----- | :--- | :------ | :-------- | :----------- | :------- |
|
||||
| 字节数 | 1 | 1 | 2 | 8 | 2 | 1 |
|
||||
| 类型 | uint8_t | uint8_t | uint16_t | uint64_t | uint16_t | uint8_t |
|
||||
| 描述 | 0x3B | 0x10 (数据内容大小) | 帧 ID | 时间戳 | 曝光时间 | 校验码(数据内容所有字节异或) |
|
||||
|
||||
* 数据包校验不过,会丢弃该帧。
|
||||
* 时间单位的精度为: 0.01 ms / 10 us 。
|
||||
* 4 字节能表示的最大时间约是 11.9 小时,溢出后将重累计。
|
||||
* 时间的单位精度为: 1 us 。
|
||||
* 时间累计是从上电时从开始,而不是从打开时开始。
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
## IMU 响应数据包
|
||||
|
||||
IMU 响应数据包里会包含多个 IMU 包,而每个 IMU 包又带有多个 IMU 段。
|
||||
IMU 响应数据包里会包含1个 IMU 包,而每个 IMU 包又带有多个 IMU 段。
|
||||
|
||||
| Name | Header | State | Size | IMU Packets | Checksum |
|
||||
| :--- | :----- | :---- | :--- | :---------- | :------- |
|
||||
@@ -22,21 +22,21 @@ IMU 响应数据包里会包含多个 IMU 包,而每个 IMU 包又带有多个
|
||||
|
||||
IMU 包/小包,是一组 IMU 数据。
|
||||
|
||||
| Name | Serial Number | Timestamp | Count | IMU Datas |
|
||||
| :--- | :------------ | :-------- | :---- | :-------- |
|
||||
| 字节数 | 4 | 4 | 1 | ... |
|
||||
| 类型 | uint32_t | uint32_t | uint8_t | - |
|
||||
| 描述 | 序列号 | IMU 基准时间戳 | IMU 段数量 | 所包含的 IMU 段 |
|
||||
| Name | Count | IMU Datas |
|
||||
| :--- | :-----| :-------- |
|
||||
| 字节数 | 2 | ... |
|
||||
| 类型 | uint16_t | - |
|
||||
| 描述 | IMU 段数量 | 所包含的 IMU 段 |
|
||||
|
||||
### IMU 段
|
||||
|
||||
| Name | Offset | Frame ID | Accelerometer | Temperature | Gyroscope |
|
||||
| :--- | :----- | :------- | :------------ | :---------- | :-------- |
|
||||
| 字节数 | 2 | 2 | 6 | 2 | 6 |
|
||||
| 类型 | int16_t | uint16_t | int16_t * 3 | int16_t | int16_t * 3 |
|
||||
| 描述 | 相对基准时间戳的偏移量 | 图像帧 ID | 加速度计 x y z 三轴的值 | IMU 的温度 | 陀螺仪 x y z 三轴的值 |
|
||||
| Name | Serial Number | Timestamp | flag | Temperature | Accelerometer or Gyroscope |
|
||||
| :--- | :------------ | :-------- | :----| :----------- | :------------------------- |
|
||||
| 字节数 | 4 | 8 | 1 | 2 | 6 |
|
||||
| 类型 | uint32_t | uint64_t | int8_t | int16_t | int16_t * 3 |
|
||||
| Description | 序列号 | 时间戳 | 指定传感器类型 | IMU 的温度 | 陀螺仪或陀螺仪 x y z 三轴的值 |
|
||||
|
||||
* 加速度计和陀螺仪的计量值换算成物理值公式: **real = data * range / 0x10000** 。
|
||||
* 加速度计量程默认值为 **8 g** ,陀螺仪量程默认值为 **1000 deg/s** 。
|
||||
* 加速度计量程默认值为 **12 g** ,陀螺仪量程默认值为 **1000 deg/s** 。
|
||||
* 温度计量值换算成物理值公式: **real = data / ratio + offset** 。
|
||||
* ``ratio`` 默认值为 **326.8** , ``offset`` 默认值为 **25℃** 。
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define MYNTEYE_API_API_H_
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -71,8 +72,7 @@ struct MYNTEYE_API MotionData {
|
||||
|
||||
bool operator==(const MotionData &other) const {
|
||||
if (imu && other.imu) {
|
||||
return imu->frame_id == other.imu->frame_id &&
|
||||
imu->timestamp == other.imu->timestamp;
|
||||
return imu->timestamp == other.imu->timestamp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +98,14 @@ class MYNTEYE_API API {
|
||||
* @return the API instance.
|
||||
* @note This will call device::select() to select a device.
|
||||
*/
|
||||
static std::shared_ptr<API> Create();
|
||||
static std::shared_ptr<API> Create(Resolution res);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param device the selected device.
|
||||
* @return the API instance.
|
||||
*/
|
||||
static std::shared_ptr<API> Create(
|
||||
std::shared_ptr<Device> device, Resolution res);
|
||||
/**
|
||||
* Create the API instance.
|
||||
* @param device the selected device.
|
||||
@@ -147,6 +154,10 @@ class MYNTEYE_API API {
|
||||
*/
|
||||
bool Supports(const AddOns &addon) const;
|
||||
|
||||
/**
|
||||
* set the stream request.
|
||||
*/
|
||||
void SetStreamRequest(const Format &format, const FrameRate &rate);
|
||||
/**
|
||||
* Get all stream requests of the capability.
|
||||
*/
|
||||
@@ -203,6 +214,11 @@ class MYNTEYE_API API {
|
||||
*/
|
||||
bool RunOptionAction(const Option &option) const;
|
||||
|
||||
/**
|
||||
* Init device resolution.
|
||||
*/
|
||||
void InitResolution(const Resolution &res);
|
||||
|
||||
/**
|
||||
* Set the callback of stream.
|
||||
*/
|
||||
@@ -278,6 +294,8 @@ class MYNTEYE_API API {
|
||||
std::shared_ptr<Device> device_;
|
||||
|
||||
std::unique_ptr<Synthetic> synthetic_;
|
||||
|
||||
void CheckImageParams();
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -29,6 +30,20 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace device {
|
||||
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
std::map<Resolution, Intrinsics> in_left_map;
|
||||
std::map<Resolution, Intrinsics> in_right_map;
|
||||
Extrinsics ex_right_to_left;
|
||||
} img_params_t;
|
||||
|
||||
typedef struct ImuParams {
|
||||
bool ok;
|
||||
ImuIntrinsics in_accel;
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
|
||||
/**
|
||||
* @ingroup datatypes
|
||||
* Frame with raw data.
|
||||
|
||||
@@ -66,6 +66,9 @@ class MYNTEYE_API Device {
|
||||
using stream_async_callback_ptr_t = std::shared_ptr<stream_async_callback_t>;
|
||||
using motion_async_callback_ptr_t = std::shared_ptr<motion_async_callback_t>;
|
||||
|
||||
using img_params_t = device::img_params_t;
|
||||
using imu_params_t = device::imu_params_t;
|
||||
|
||||
Device(const Model &model, std::shared_ptr<uvc::device> device);
|
||||
virtual ~Device();
|
||||
|
||||
@@ -101,7 +104,14 @@ class MYNTEYE_API Device {
|
||||
* Supports the addon or not.
|
||||
*/
|
||||
bool Supports(const AddOns &addon) const;
|
||||
|
||||
/**
|
||||
* Init device resolution.
|
||||
*/
|
||||
void InitResolution(const Resolution &res);
|
||||
/**
|
||||
* set the stream request.
|
||||
*/
|
||||
void SetStreamRequest(const Format &format, const FrameRate &rate);
|
||||
/**
|
||||
* Get all stream requests of the capability.
|
||||
*/
|
||||
@@ -253,6 +263,10 @@ class MYNTEYE_API Device {
|
||||
* Get the motion datas.
|
||||
*/
|
||||
std::vector<device::MotionData> GetMotionDatas();
|
||||
/**
|
||||
* Get the device img params
|
||||
*/
|
||||
img_params_t GetImgParams();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<uvc::device> device() const {
|
||||
@@ -288,6 +302,8 @@ class MYNTEYE_API Device {
|
||||
|
||||
private:
|
||||
Model model_;
|
||||
Resolution res_ = Resolution::RES_752x480;
|
||||
StreamRequest request_;
|
||||
std::shared_ptr<uvc::device> device_;
|
||||
std::shared_ptr<DeviceInfo> device_info_;
|
||||
|
||||
@@ -297,6 +313,7 @@ class MYNTEYE_API Device {
|
||||
std::shared_ptr<MotionIntrinsics> motion_intrinsics_;
|
||||
std::map<Stream, Extrinsics> motion_from_extrinsics_;
|
||||
|
||||
img_params_t img_params_;
|
||||
stream_callbacks_t stream_callbacks_;
|
||||
motion_callback_t motion_callback_;
|
||||
|
||||
@@ -315,6 +332,8 @@ class MYNTEYE_API Device {
|
||||
|
||||
void ReadAllInfos();
|
||||
|
||||
void ConfigIntrinsics(const Resolution &res);
|
||||
|
||||
void CallbackPushedStreamData(const Stream &stream);
|
||||
void CallbackMotionData(const device::MotionData &data);
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ enum class Capabilities : std::uint8_t {
|
||||
STEREO,
|
||||
/** Provides color stream */
|
||||
COLOR,
|
||||
/** Provide stereo color stream */
|
||||
STEREO_COLOR,
|
||||
/** Provides depth stream */
|
||||
DEPTH,
|
||||
/** Provides point cloud stream */
|
||||
@@ -163,19 +165,19 @@ enum class Option : std::uint8_t {
|
||||
/**
|
||||
* Max gain, valid if auto-exposure
|
||||
*
|
||||
* range: [0,48], default: 48
|
||||
* range: [0,255], default: 8
|
||||
*/
|
||||
MAX_GAIN,
|
||||
/**
|
||||
* Max exposure time, valid if auto-exposure
|
||||
*
|
||||
* range: [0,240], default: 240
|
||||
* range: [0,1000], default: 333
|
||||
*/
|
||||
MAX_EXPOSURE_TIME,
|
||||
/**
|
||||
* Desired brightness, valid if auto-exposure
|
||||
*
|
||||
* range: [0,255], default: 192
|
||||
* range: [1,255], default: 122
|
||||
*/
|
||||
DESIRED_BRIGHTNESS,
|
||||
/**
|
||||
@@ -195,6 +197,36 @@ enum class Option : std::uint8_t {
|
||||
ZERO_DRIFT_CALIBRATION,
|
||||
/** Erase chip */
|
||||
ERASE_CHIP,
|
||||
/**
|
||||
* min exposure time, valid if auto-exposure
|
||||
*
|
||||
* range: [0,1000], default: 0
|
||||
*/
|
||||
MIN_EXPOSURE_TIME,
|
||||
/**
|
||||
* The range of accelerometer
|
||||
*
|
||||
* values: {6,12,24,48}, default: 6
|
||||
*/
|
||||
ACCELEROMETER_RANGE,
|
||||
/**
|
||||
* The range of gyroscope
|
||||
*
|
||||
* values: {250,500,1000,2000,4000}, default: 1000
|
||||
*/
|
||||
GYROSCOPE_RANGE,
|
||||
/**
|
||||
* The parameter of accelerometer low pass filter
|
||||
*
|
||||
* values: {0,1,2}, default: 2
|
||||
*/
|
||||
ACCELEROMETER_LOW_PASS_FILTER,
|
||||
/**
|
||||
* The parameter of gyroscope low pass filter
|
||||
*
|
||||
* values: {23,64}, default: 64
|
||||
*/
|
||||
GYROSCOPE_LOW_PASS_FILTER,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
@@ -227,6 +259,40 @@ enum class AddOns : std::uint8_t {
|
||||
LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup enumerations
|
||||
* @brief Camera supported resolution.
|
||||
*/
|
||||
enum class Resolution : std::uint8_t {
|
||||
/** 752x480 */
|
||||
RES_752x480,
|
||||
/** 1280x400 */
|
||||
RES_1280x400,
|
||||
/** 2560x800 */
|
||||
RES_2560x800,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup enumerations
|
||||
* @brief Camera supported frame rate.
|
||||
*/
|
||||
enum class FrameRate : std::uint8_t {
|
||||
/** 10 fps */
|
||||
RATE_10_FPS = 10,
|
||||
/** 20 fps */
|
||||
RATE_20_FPS = 20,
|
||||
/** 20 fps */
|
||||
RATE_25_FPS = 25,
|
||||
/** 30 fps */
|
||||
RATE_30_FPS = 30,
|
||||
/** 60 fps */
|
||||
RATE_60_FPS = 60,
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
|
||||
#define MYNTEYE_ENUM_HELPERS(TYPE) \
|
||||
MYNTEYE_API const char *to_string(const TYPE &value); \
|
||||
inline bool is_valid(const TYPE &value) { \
|
||||
@@ -250,6 +316,8 @@ MYNTEYE_ENUM_HELPERS(Info)
|
||||
MYNTEYE_ENUM_HELPERS(Option)
|
||||
MYNTEYE_ENUM_HELPERS(Source)
|
||||
MYNTEYE_ENUM_HELPERS(AddOns)
|
||||
MYNTEYE_ENUM_HELPERS(Resolution)
|
||||
MYNTEYE_ENUM_HELPERS(FrameRate)
|
||||
|
||||
#undef MYNTEYE_ENUM_HELPERS
|
||||
|
||||
@@ -266,6 +334,8 @@ enum class Format : std::uint32_t {
|
||||
GREY = MYNTEYE_FOURCC('G', 'R', 'E', 'Y'),
|
||||
/** YUV 4:2:2, 16 bits per pixel */
|
||||
YUYV = MYNTEYE_FOURCC('Y', 'U', 'Y', 'V'),
|
||||
/** BGR 8:8:8, 24 bits per pixel */
|
||||
BGR888 = MYNTEYE_FOURCC('B', 'G', 'R', '3'),
|
||||
/** Last guard */
|
||||
LAST
|
||||
};
|
||||
@@ -293,6 +363,33 @@ struct MYNTEYE_API StreamRequest {
|
||||
/** Stream frames per second (unused) */
|
||||
std::uint16_t fps;
|
||||
|
||||
StreamRequest() {}
|
||||
|
||||
StreamRequest(
|
||||
std::uint16_t width, std::uint16_t height, Format format,
|
||||
std::uint16_t fps)
|
||||
: width(width), height(height), format(format), fps(fps) {}
|
||||
|
||||
StreamRequest(Resolution res, Format format, FrameRate rate)
|
||||
: format(format) {
|
||||
fps = static_cast<uint16_t>(rate);
|
||||
|
||||
switch (res) {
|
||||
case Resolution::RES_752x480:
|
||||
width = 480, height = 752;
|
||||
break;
|
||||
case Resolution::RES_1280x400:
|
||||
width = 1280, height = 400;
|
||||
break;
|
||||
case Resolution::RES_2560x800:
|
||||
width = 2560, height = 800;
|
||||
break;
|
||||
default:
|
||||
width = 480, height = 752;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const StreamRequest &other) const {
|
||||
return width == other.width && height == other.height &&
|
||||
format == other.format && fps == other.fps;
|
||||
@@ -409,8 +506,8 @@ std::ostream &operator<<(std::ostream &os, const Extrinsics &ex);
|
||||
struct MYNTEYE_API ImgData {
|
||||
/** Image frame id */
|
||||
std::uint16_t frame_id;
|
||||
/** Image timestamp in 0.01ms */
|
||||
std::uint32_t timestamp;
|
||||
/** Image timestamp in 1us */
|
||||
std::uint64_t timestamp;
|
||||
/** Image exposure time, virtual value in [1, 480] */
|
||||
std::uint16_t exposure_time;
|
||||
|
||||
@@ -441,10 +538,12 @@ struct MYNTEYE_API ImgData {
|
||||
* IMU data.
|
||||
*/
|
||||
struct MYNTEYE_API ImuData {
|
||||
/** Image frame id */
|
||||
std::uint16_t frame_id;
|
||||
/** IMU timestamp in 0.01ms */
|
||||
std::uint32_t timestamp;
|
||||
/** Imu serial number */
|
||||
std::uint32_t serial_number;
|
||||
/** accel or gyro flag:1 for accel,2 for gyro,3 for both */
|
||||
std::uint8_t flag;
|
||||
/** IMU timestamp in 1us */
|
||||
std::uint64_t timestamp;
|
||||
/** IMU accelerometer data for 3-axis: X, Y, Z. */
|
||||
double accel[3];
|
||||
/** IMU gyroscope data for 3-axis: X, Y, Z. */
|
||||
@@ -453,7 +552,7 @@ struct MYNTEYE_API ImuData {
|
||||
double temperature;
|
||||
|
||||
void Reset() {
|
||||
frame_id = 0;
|
||||
flag = 0;
|
||||
timestamp = 0;
|
||||
std::fill(accel, accel + 3, 0);
|
||||
std::fill(gyro, gyro + 3, 0);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
@PACKAGE_INIT@
|
||||
set(mynteye_WITH_API @WITH_API@)
|
||||
set(mynteye_WITH_GLOG @WITH_GLOG@)
|
||||
|
||||
set(mynteye_WITH_API @WITH_API@)
|
||||
set(mynteye_WITH_GLOG @WITH_GLOG@)
|
||||
|
||||
@@ -53,6 +53,10 @@ message(STATUS "Found mynteye: ${mynteye_VERSION}")
|
||||
|
||||
include(${PRO_DIR}/cmake/DetectOpenCV.cmake)
|
||||
|
||||
if(mynteye_WITH_GLOG)
|
||||
include(${PRO_DIR}/cmake/DetectGLog.cmake)
|
||||
endif()
|
||||
|
||||
#LIST(APPEND CMAKE_MODULE_PATH ${PRO_DIR}/cmake)
|
||||
|
||||
# targets
|
||||
@@ -71,7 +75,7 @@ add_subdirectory(device)
|
||||
|
||||
# samples above uvc layer
|
||||
|
||||
add_subdirectory(uvc)
|
||||
#add_subdirectory(uvc)
|
||||
|
||||
# tutorials
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ 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->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
api->LogOptionInfos();
|
||||
|
||||
std::size_t left_count = 0;
|
||||
@@ -55,8 +52,7 @@ int main(int argc, char *argv[]) {
|
||||
CHECK_NOTNULL(data.imu);
|
||||
++imu_count;
|
||||
VLOG(2) << "Imu count: " << imu_count;
|
||||
VLOG(2) << " frame_id: " << data.imu->frame_id
|
||||
<< ", timestamp: " << data.imu->timestamp
|
||||
VLOG(2) << ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
@@ -106,8 +102,7 @@ int main(int argc, char *argv[]) {
|
||||
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
|
||||
LOG(INFO) << ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
include_directories(
|
||||
${PRO_DIR}/src
|
||||
)
|
||||
|
||||
set_outdir(
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
"${OUT_DIR}/lib/${DIR_NAME}"
|
||||
|
||||
@@ -27,33 +27,15 @@ int main(int argc, char *argv[]) {
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return 1;
|
||||
/*
|
||||
{ // auto-exposure
|
||||
device->SetOptionValue(Option::EXPOSURE_MODE, 0);
|
||||
device->SetOptionValue(Option::MAX_GAIN, 40); // [0.48]
|
||||
device->SetOptionValue(Option::MAX_EXPOSURE_TIME, 120); // [0,240]
|
||||
device->SetOptionValue(Option::DESIRED_BRIGHTNESS, 200); // [0,255]
|
||||
}
|
||||
{ // manual-exposure
|
||||
device->SetOptionValue(Option::EXPOSURE_MODE, 1);
|
||||
device->SetOptionValue(Option::GAIN, 20); // [0.48]
|
||||
device->SetOptionValue(Option::BRIGHTNESS, 20); // [0,240]
|
||||
device->SetOptionValue(Option::CONTRAST, 20); // [0,255]
|
||||
}
|
||||
device->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
device->SetOptionValue(Option::FRAME_RATE, 25);
|
||||
device->SetOptionValue(Option::IMU_FREQUENCY, 500);
|
||||
*/
|
||||
device->LogOptionInfos();
|
||||
|
||||
// device->RunOptionAction(Option::ZERO_DRIFT_CALIBRATION);
|
||||
|
||||
std::size_t left_count = 0;
|
||||
device->InitResolution(Resolution::RES_1280x400);
|
||||
device->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
device->SetStreamCallback(
|
||||
Stream::LEFT, [&left_count](const device::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++left_count;
|
||||
VLOG(2) << Stream::LEFT << ", count: " << 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;
|
||||
@@ -63,19 +45,19 @@ int main(int argc, char *argv[]) {
|
||||
Stream::RIGHT, [&right_count](const device::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++right_count;
|
||||
VLOG(2) << Stream::RIGHT << ", count: " << 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;
|
||||
|
||||
device->SetMotionCallback([&imu_count](const device::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
|
||||
VLOG(2) << ", timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
@@ -88,7 +70,6 @@ int main(int argc, char *argv[]) {
|
||||
// Enable this will cache the motion datas until you get them.
|
||||
device->EnableMotionDatas();
|
||||
device->Start(Source::ALL);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
std::size_t motion_count = 0;
|
||||
@@ -102,8 +83,7 @@ int main(int argc, char *argv[]) {
|
||||
auto &&motion_datas = device->GetMotionDatas();
|
||||
motion_count += motion_datas.size();
|
||||
for (auto &&data : motion_datas) {
|
||||
LOG(INFO) << "Imu frame_id: " << data.imu->frame_id
|
||||
<< ", timestamp: " << data.imu->timestamp
|
||||
LOG(INFO) << "timestamp: " << data.imu->timestamp
|
||||
<< ", accel_x: " << data.imu->accel[0]
|
||||
<< ", accel_y: " << data.imu->accel[1]
|
||||
<< ", accel_z: " << data.imu->accel[2]
|
||||
@@ -113,15 +93,41 @@ int main(int argc, char *argv[]) {
|
||||
<< ", temperature: " << data.imu->temperature;
|
||||
}
|
||||
|
||||
cv::Mat left_img(
|
||||
left_data.frame->height(), left_data.frame->width(), CV_8UC1,
|
||||
left_data.frame->data());
|
||||
cv::Mat right_img(
|
||||
right_data.frame->height(), right_data.frame->width(), CV_8UC1,
|
||||
right_data.frame->data());
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_img, right_img, img);
|
||||
|
||||
// TODO(Kalman): Extract into public or internal method
|
||||
if (left_data.frame->format() == Format::GREY) {
|
||||
cv::Mat left_img(
|
||||
left_data.frame->height(), left_data.frame->width(), CV_8UC1,
|
||||
left_data.frame->data());
|
||||
cv::Mat right_img(
|
||||
right_data.frame->height(), right_data.frame->width(), CV_8UC1,
|
||||
right_data.frame->data());
|
||||
cv::hconcat(left_img, right_img, img);
|
||||
} else if (left_data.frame->format() == Format::YUYV) {
|
||||
cv::Mat left_img(
|
||||
left_data.frame->height(), left_data.frame->width(), CV_8UC2,
|
||||
left_data.frame->data());
|
||||
cv::Mat right_img(
|
||||
right_data.frame->height(), right_data.frame->width(), CV_8UC2,
|
||||
right_data.frame->data());
|
||||
cv::cvtColor(left_img, left_img, cv::COLOR_YUV2BGR_YUY2);
|
||||
cv::cvtColor(right_img, right_img, cv::COLOR_YUV2BGR_YUY2);
|
||||
cv::hconcat(left_img, right_img, img);
|
||||
} else if (left_data.frame->format() == Format::BGR888) {
|
||||
cv::Mat left_img(
|
||||
left_data.frame->height(), left_data.frame->width(), CV_8UC3,
|
||||
left_data.frame->data());
|
||||
cv::Mat right_img(
|
||||
right_data.frame->height(), right_data.frame->width(), CV_8UC3,
|
||||
right_data.frame->data());
|
||||
cv::cvtColor(left_img, left_img, CV_BGR2RGB);
|
||||
cv::cvtColor(right_img, right_img, CV_BGR2RGB);
|
||||
cv::hconcat(left_img, right_img, img);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<char>(cv::waitKey(1));
|
||||
@@ -144,7 +150,7 @@ int main(int argc, char *argv[]) {
|
||||
<< ", 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);
|
||||
LOG(INFO) << "Motion count: " << motion_count
|
||||
<< ", hz: " << (1000.f * motion_count / elapsed_ms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ get_filename_component(DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PRO_DIR}/src
|
||||
)
|
||||
|
||||
set_outdir(
|
||||
@@ -114,6 +115,7 @@ make_executable2(get_with_plugin SRCS data/get_with_plugin.cc WITH_OPENCV)
|
||||
## control
|
||||
|
||||
make_executable2(ctrl_framerate SRCS control/framerate.cc WITH_OPENCV)
|
||||
make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV)
|
||||
make_executable2(ctrl_auto_exposure
|
||||
SRCS control/auto_exposure.cc util/cv_painter.cc
|
||||
WITH_OPENCV
|
||||
@@ -122,7 +124,6 @@ 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
|
||||
|
||||
|
||||
@@ -24,16 +24,19 @@ int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
|
||||
// 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);
|
||||
// max_gain: range [0,255], default 8
|
||||
api->SetOptionValue(Option::MAX_GAIN, 8);
|
||||
// max_exposure_time: range [0,1000], default 333
|
||||
api->SetOptionValue(Option::MAX_EXPOSURE_TIME, 333);
|
||||
// desired_brightness: range [1,255], default 122
|
||||
api->SetOptionValue(Option::DESIRED_BRIGHTNESS, 122);
|
||||
// min_exposure_time: range [0,1000], default 0
|
||||
api->SetOptionValue(Option::MIN_EXPOSURE_TIME, 0);
|
||||
|
||||
LOG(INFO) << "Enable auto-exposure";
|
||||
LOG(INFO) << "Set MAX_GAIN to " << api->GetOptionValue(Option::MAX_GAIN);
|
||||
@@ -41,10 +44,12 @@ int main(int argc, char *argv[]) {
|
||||
<< api->GetOptionValue(Option::MAX_EXPOSURE_TIME);
|
||||
LOG(INFO) << "Set DESIRED_BRIGHTNESS to "
|
||||
<< api->GetOptionValue(Option::DESIRED_BRIGHTNESS);
|
||||
LOG(INFO) << "Set MIN_EXPOSURE_TIME to "
|
||||
<< api->GetOptionValue(Option::MIN_EXPOSURE_TIME);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
CVPainter painter(api->GetOptionValue(Option::FRAME_RATE));
|
||||
CVPainter painter(30);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
|
||||
@@ -22,22 +22,11 @@
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
auto &&api = API::Create(Resolution::RES_1280x400);
|
||||
// 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, 60
|
||||
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);
|
||||
|
||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
// Count img
|
||||
std::atomic_uint img_count(0);
|
||||
api->SetStreamCallback(
|
||||
@@ -46,13 +35,6 @@ int main(int argc, char *argv[]) {
|
||||
++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");
|
||||
@@ -85,7 +67,5 @@ int main(int argc, char *argv[]) {
|
||||
<< ", 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;
|
||||
}
|
||||
|
||||
89
samples/tutorials/control/imu_range.cc
Normal file
89
samples/tutorials/control/imu_range.cc
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <atomic>
|
||||
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/api/api.h"
|
||||
#include "mynteye/util/times.h"
|
||||
|
||||
MYNTEYE_USE_NAMESPACE
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
// ACCELEROMETER_RANGE values: 6, 12, 24, 32
|
||||
api->SetOptionValue(Option::ACCELEROMETER_RANGE, 6);
|
||||
// GYROSCOPE_RANGE values: 250, 500, 1000, 2000, 4000
|
||||
api->SetOptionValue(Option::GYROSCOPE_RANGE, 1000);
|
||||
|
||||
LOG(INFO) << "Set ACCELEROMETER_RANGE to "
|
||||
<< api->GetOptionValue(Option::ACCELEROMETER_RANGE);
|
||||
LOG(INFO) << "Set GYROSCOPE_RANGE to "
|
||||
<< api->GetOptionValue(Option::GYROSCOPE_RANGE);
|
||||
|
||||
// Count img
|
||||
std::atomic_uint img_count(0);
|
||||
api->SetStreamCallback(
|
||||
Stream::LEFT, [&img_count](const api::StreamData &data) {
|
||||
CHECK_NOTNULL(data.img);
|
||||
++img_count;
|
||||
});
|
||||
|
||||
// Count imu
|
||||
std::atomic_uint imu_count(0);
|
||||
api->SetMotionCallback([&imu_count](const api::MotionData &data) {
|
||||
CHECK_NOTNULL(data.imu);
|
||||
++imu_count;
|
||||
});
|
||||
|
||||
api->Start(Source::ALL);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
auto &&time_beg = times::now();
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||
|
||||
cv::Mat img;
|
||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
char key = static_cast<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;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
// 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 "mynteye/logger.h"
|
||||
#include "mynteye/api/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;
|
||||
}
|
||||
@@ -24,25 +24,20 @@ int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
|
||||
// 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));
|
||||
CVPainter painter(30);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ int main(int argc, char *argv[]) {
|
||||
auto &&api = API::Create(argc, argv);
|
||||
if (!api)
|
||||
return 1;
|
||||
|
||||
api->SetStreamRequest(Format::BGR888, FrameRate::RATE_30_FPS);
|
||||
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
|
||||
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
|
||||
<< "}";
|
||||
|
||||
@@ -117,7 +117,7 @@ cv::Rect CVPainter::DrawImuData(
|
||||
if (gravity == BOTTOM_LEFT || gravity == BOTTOM_RIGHT)
|
||||
sign = -1;
|
||||
|
||||
Clear(ss) << "frame_id: " << data.frame_id << ", stamp: " << data.timestamp
|
||||
Clear(ss) << "stamp: " << data.timestamp
|
||||
<< ", temp: " << fmt_temp << data.temperature;
|
||||
cv::Rect rect_i = DrawText(img, ss.str(), gravity, 5);
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ int main(int argc, char *argv[]) {
|
||||
const auto frame_empty = [&frame]() { return frame == nullptr; };
|
||||
|
||||
uvc::set_device_mode(
|
||||
*device, 752, 480, static_cast<int>(Format::YUYV), 25,
|
||||
*device, 1280, 400, static_cast<int>(Format::BGR888), 20,
|
||||
[&mtx, &cv, &frame, &frame_ready](
|
||||
const void *data, std::function<void()> continuation) {
|
||||
// reinterpret_cast<const std::uint8_t *>(data);
|
||||
@@ -143,8 +143,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
// 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::Mat img(400, 1280, CV_8UC3, const_cast<void *>(frame->data));
|
||||
cv::cvtColor(img, img, CV_BGR2RGB);
|
||||
cv::imshow("frame", img);
|
||||
|
||||
frame = nullptr;
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
||||
#endif
|
||||
#include <glog/logging.h>
|
||||
|
||||
#ifdef HAVE_LIB_GFLAGS
|
||||
#include <gflags/gflags.h>
|
||||
#endif
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
int main(int /*argc*/, char *argv[]) {
|
||||
|
||||
@@ -210,26 +210,7 @@ std::vector<std::string> get_plugin_paths() {
|
||||
|
||||
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-S-SDK-Guide) "
|
||||
"to learn more.";
|
||||
}
|
||||
}
|
||||
std::dynamic_pointer_cast<StandardDevice>(device_);
|
||||
synthetic_.reset(new Synthetic(this));
|
||||
}
|
||||
|
||||
@@ -237,29 +218,52 @@ 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);
|
||||
std::shared_ptr<API> API::Create(Resolution res) {
|
||||
auto &&device = device::select();
|
||||
if (!device)
|
||||
return nullptr;
|
||||
device->InitResolution(res);
|
||||
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);
|
||||
std::shared_ptr<Device> device, Resolution res) {
|
||||
if (!device)
|
||||
return nullptr;
|
||||
device->InitResolution(res);
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
std::shared_ptr<API> API::Create(std::shared_ptr<Device> device) {
|
||||
return Create(device, Resolution::RES_2560x800);
|
||||
}
|
||||
|
||||
std::shared_ptr<API> API::Create(int argc, char *argv[]) {
|
||||
auto &&device = device::select();
|
||||
return Create(argc, argv, device);
|
||||
}
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
std::shared_ptr<API> API::Create(
|
||||
int argc, char *argv[], std::shared_ptr<Device> device) {
|
||||
static glog_init _(argc, argv);
|
||||
int index = 0;
|
||||
if (argc >= 2) {
|
||||
try {
|
||||
index = std::stoi(argv[1]);
|
||||
} catch (...) {
|
||||
LOG(WARNING) << "Unexpected index.";
|
||||
}
|
||||
}
|
||||
if (!device)
|
||||
return nullptr;
|
||||
if (index == 0)
|
||||
device->InitResolution(Resolution::RES_1280x400);
|
||||
else if (index == 1)
|
||||
device->InitResolution(Resolution::RES_2560x800);
|
||||
else
|
||||
device->InitResolution(Resolution::RES_1280x400);
|
||||
return std::make_shared<API>(device);
|
||||
}
|
||||
|
||||
@@ -283,6 +287,14 @@ bool API::Supports(const AddOns &addon) const {
|
||||
return device_->Supports(addon);
|
||||
}
|
||||
|
||||
void API::InitResolution(const Resolution &res) {
|
||||
return device_->InitResolution(res);
|
||||
}
|
||||
|
||||
void API::SetStreamRequest(const Format &format, const FrameRate &rate) {
|
||||
device_->SetStreamRequest(format, rate);
|
||||
}
|
||||
|
||||
const std::vector<StreamRequest> &API::GetStreamRequests(
|
||||
const Capabilities &capability) const {
|
||||
return device_->GetStreamRequests(capability);
|
||||
@@ -450,4 +462,23 @@ std::shared_ptr<Device> API::device() {
|
||||
return device_;
|
||||
}
|
||||
|
||||
// TODO(Kalman): Call this function in the appropriate place
|
||||
void API::CheckImageParams() {
|
||||
if (device_ != nullptr) {
|
||||
bool in_l_ok, in_r_ok, ex_l2r_ok;
|
||||
device_->GetIntrinsics(Stream::LEFT, &in_l_ok);
|
||||
device_->GetIntrinsics(Stream::RIGHT, &in_r_ok);
|
||||
device_->GetExtrinsics(Stream::LEFT, Stream::RIGHT, &ex_l2r_ok);
|
||||
if (!in_l_ok || !in_r_ok || !ex_l2r_ok) {
|
||||
LOG(FATAL) << "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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -98,7 +98,7 @@ bool DisparityProcessor::OnProcess(
|
||||
// whereas other algorithms output 32-bit floating-point disparity map.
|
||||
sgbm_->compute(input->first, input->second, disparity);
|
||||
#endif
|
||||
output->value = disparity / 16 + 1;
|
||||
disparity.convertTo(output->value, CV_32F, 1./16, 1);
|
||||
output->id = input->first_id;
|
||||
output->data = input->first_data;
|
||||
return true;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/api/object.h"
|
||||
#include "mynteye/api/plugin.h"
|
||||
@@ -39,9 +41,17 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||
namespace {
|
||||
|
||||
cv::Mat frame2mat(const std::shared_ptr<device::Frame> &frame) {
|
||||
// TODO(JohnZhao) Support different format frame to cv::Mat
|
||||
CHECK_EQ(frame->format(), Format::GREY);
|
||||
return cv::Mat(frame->height(), frame->width(), CV_8UC1, frame->data());
|
||||
if (frame->format() == Format::YUYV) {
|
||||
cv::Mat img(frame->height(), frame->width(), CV_8UC2, frame->data());
|
||||
cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2);
|
||||
return img;
|
||||
} else if (frame->format() == Format::BGR888) {
|
||||
cv::Mat img(frame->height(), frame->width(), CV_8UC3, frame->data());
|
||||
cv::cvtColor(img, img, CV_BGR2RGB);
|
||||
return img;
|
||||
} else {
|
||||
return cv::Mat(frame->height(), frame->width(), CV_8UC1, frame->data());
|
||||
}
|
||||
}
|
||||
|
||||
api::StreamData data2api(const device::StreamData &data) {
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "mynteye/util/strings.h"
|
||||
#include "mynteye/util/times.h"
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
#define IMU_TRACK_PERIOD 25 // ms
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
@@ -63,6 +65,21 @@ int XuCamCtrlId(Option option) {
|
||||
case Option::FRAME_RATE:
|
||||
return 7;
|
||||
break;
|
||||
case Option::MIN_EXPOSURE_TIME:
|
||||
return 8;
|
||||
break;
|
||||
case Option::ACCELEROMETER_RANGE:
|
||||
return 9;
|
||||
break;
|
||||
case Option::GYROSCOPE_RANGE:
|
||||
return 10;
|
||||
break;
|
||||
case Option::ACCELEROMETER_LOW_PASS_FILTER:
|
||||
return 11;
|
||||
break;
|
||||
case Option::GYROSCOPE_LOW_PASS_FILTER:
|
||||
return 12;
|
||||
break;
|
||||
default:
|
||||
LOG(FATAL) << "No cam ctrl id for " << option;
|
||||
}
|
||||
@@ -86,7 +103,7 @@ void CheckSpecVersion(const Version *spec_version) {
|
||||
LOG(FATAL) << "Spec version must be specified";
|
||||
}
|
||||
|
||||
std::vector<std::string> spec_versions{"1.0"};
|
||||
std::vector<std::string> spec_versions{"1.0", "1.1"};
|
||||
for (auto &&spec_ver : spec_versions) {
|
||||
if (*spec_version == Version(spec_ver)) {
|
||||
return; // supported
|
||||
@@ -126,26 +143,29 @@ void Channels::LogControlInfos() const {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
void Channels::UpdateControlInfos() {
|
||||
for (auto &&option : std::vector<Option>{Option::GAIN, Option::BRIGHTNESS,
|
||||
Option::CONTRAST}) {
|
||||
for (auto &&option : std::vector<Option>{Option::BRIGHTNESS}) {
|
||||
control_infos_[option] = PuControlInfo(option);
|
||||
}
|
||||
|
||||
for (auto &&option : std::vector<Option>{
|
||||
Option::FRAME_RATE, Option::IMU_FREQUENCY, Option::EXPOSURE_MODE,
|
||||
Option::MAX_GAIN, Option::MAX_EXPOSURE_TIME,
|
||||
Option::DESIRED_BRIGHTNESS, Option::IR_CONTROL, Option::HDR_MODE}) {
|
||||
control_infos_[option] = XuControlInfo(option);
|
||||
}
|
||||
|
||||
if (VLOG_IS_ON(2)) {
|
||||
for (auto &&it = control_infos_.begin(); it != control_infos_.end(); it++) {
|
||||
VLOG(2) << it->first << ": min=" << it->second.min
|
||||
<< ", max=" << it->second.max << ", def=" << it->second.def
|
||||
<< ", cur=" << GetControlValue(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &&option : std::vector<Option>{
|
||||
Option::EXPOSURE_MODE, Option::DESIRED_BRIGHTNESS,
|
||||
Option::MAX_GAIN, Option::MAX_EXPOSURE_TIME,
|
||||
Option::MIN_EXPOSURE_TIME, Option::ACCELEROMETER_RANGE,
|
||||
Option::GYROSCOPE_RANGE, Option::ACCELEROMETER_LOW_PASS_FILTER,
|
||||
Option::GYROSCOPE_LOW_PASS_FILTER}) {
|
||||
control_infos_[option] = XuControlInfo(option);
|
||||
}
|
||||
|
||||
if (VLOG_IS_ON(2)) {
|
||||
for (auto &&it = control_infos_.begin(); it != control_infos_.end();
|
||||
it++) {
|
||||
VLOG(2) << it->first << ": min=" << it->second.min
|
||||
<< ", max=" << it->second.max << ", def=" << it->second.def
|
||||
<< ", cur=" << GetControlValue(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Channels::control_info_t Channels::GetControlInfo(const Option &option) const {
|
||||
@@ -177,6 +197,11 @@ std::int32_t Channels::GetControlValue(const Option &option) const {
|
||||
case Option::DESIRED_BRIGHTNESS:
|
||||
case Option::IR_CONTROL:
|
||||
case Option::HDR_MODE:
|
||||
case Option::MIN_EXPOSURE_TIME:
|
||||
case Option::ACCELEROMETER_RANGE:
|
||||
case Option::GYROSCOPE_RANGE:
|
||||
case Option::ACCELEROMETER_LOW_PASS_FILTER:
|
||||
case Option::GYROSCOPE_LOW_PASS_FILTER:
|
||||
return XuCamCtrlGet(option);
|
||||
case Option::ZERO_DRIFT_CALIBRATION:
|
||||
case Option::ERASE_CHIP:
|
||||
@@ -232,12 +257,33 @@ void Channels::SetControlValue(const Option &option, std::int32_t value) {
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
case Option::ACCELEROMETER_RANGE: {
|
||||
if (!in_range() || !in_values({6, 12, 24, 48}))
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
case Option::GYROSCOPE_RANGE: {
|
||||
if (!in_range() || !in_values({250, 500, 1000, 2000, 4000}))
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
case Option::ACCELEROMETER_LOW_PASS_FILTER: {
|
||||
if (!in_range() || !in_values({0, 1, 2}))
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
case Option::GYROSCOPE_LOW_PASS_FILTER: {
|
||||
if (!in_range() || !in_values({23, 64}))
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
} break;
|
||||
case Option::EXPOSURE_MODE:
|
||||
case Option::MAX_GAIN:
|
||||
case Option::MAX_EXPOSURE_TIME:
|
||||
case Option::DESIRED_BRIGHTNESS:
|
||||
case Option::IR_CONTROL:
|
||||
case Option::HDR_MODE: {
|
||||
case Option::HDR_MODE:
|
||||
case Option::MIN_EXPOSURE_TIME: {
|
||||
if (!in_range())
|
||||
break;
|
||||
XuCamCtrlSet(option, value);
|
||||
@@ -268,6 +314,11 @@ bool Channels::RunControlAction(const Option &option) const {
|
||||
case Option::DESIRED_BRIGHTNESS:
|
||||
case Option::IR_CONTROL:
|
||||
case Option::HDR_MODE:
|
||||
case Option::MIN_EXPOSURE_TIME:
|
||||
case Option::ACCELEROMETER_RANGE:
|
||||
case Option::GYROSCOPE_RANGE:
|
||||
case Option::ACCELEROMETER_LOW_PASS_FILTER:
|
||||
case Option::GYROSCOPE_LOW_PASS_FILTER:
|
||||
LOG(WARNING) << option << " run action useless";
|
||||
return false;
|
||||
default:
|
||||
@@ -297,6 +348,10 @@ void Channels::DoImuTrack() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (res_packet.packets.back().count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
VLOG(2) << "Imu req sn: " << imu_sn_ << ", res count: " << []() {
|
||||
std::size_t n = 0;
|
||||
for (auto &&packet : res_packet.packets) {
|
||||
@@ -305,7 +360,7 @@ void Channels::DoImuTrack() {
|
||||
return n;
|
||||
}();
|
||||
|
||||
auto &&sn = res_packet.packets.back().serial_number;
|
||||
auto &&sn = res_packet.packets.back().segments.back().serial_number;
|
||||
if (imu_sn_ == sn) {
|
||||
VLOG(2) << "New imu not ready, dropped";
|
||||
return;
|
||||
@@ -508,18 +563,44 @@ std::size_t from_data(
|
||||
return i;
|
||||
}
|
||||
|
||||
// TODO(Kalman): Is there a more elegant way?
|
||||
std::size_t from_data(
|
||||
Channels::img_params_t *img_params, const std::uint8_t *data,
|
||||
device::img_params_t *img_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
i += from_data(&img_params->in_left, data + i, spec_version);
|
||||
i += from_data(&img_params->in_right, data + i, spec_version);
|
||||
|
||||
if (spec_version->major() == 1) {
|
||||
if (spec_version->minor() == 0) {
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_752x480], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_752x480], data + i,
|
||||
spec_version);
|
||||
}
|
||||
|
||||
if (spec_version->minor() == 1) {
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_1280x400], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_1280x400], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_left_map[Resolution::RES_2560x800], data + i,
|
||||
spec_version);
|
||||
i += from_data(
|
||||
&img_params->in_right_map[Resolution::RES_2560x800], data + i,
|
||||
spec_version);
|
||||
}
|
||||
}
|
||||
|
||||
i += from_data(&img_params->ex_right_to_left, data + i, spec_version);
|
||||
return i;
|
||||
}
|
||||
|
||||
std::size_t from_data(
|
||||
Channels::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
device::imu_params_t *imu_params, const std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 0;
|
||||
i += from_data(&imu_params->in_accel, data + i, spec_version);
|
||||
@@ -596,7 +677,9 @@ bool Channels::GetFiles(
|
||||
img_params->ok = file_size > 0;
|
||||
if (img_params->ok) {
|
||||
CheckSpecVersion(spec_ver);
|
||||
CHECK_EQ(from_data(img_params, data + i, spec_ver), file_size);
|
||||
from_data(img_params, data + i, spec_ver);
|
||||
// Considering the upgrade, comment this
|
||||
// CHECK_EQ(from_data(img_params, data + i, spec_ver), file_size);
|
||||
}
|
||||
} break;
|
||||
case FID_IMU_PARAMS: {
|
||||
@@ -781,11 +864,37 @@ std::size_t to_data(
|
||||
}
|
||||
|
||||
std::size_t to_data(
|
||||
const Channels::img_params_t *img_params, std::uint8_t *data,
|
||||
const device::img_params_t *img_params, std::uint8_t *data,
|
||||
const Version *spec_version) {
|
||||
std::size_t i = 3; // skip id, size
|
||||
i += to_data(&img_params->in_left, data + i, spec_version);
|
||||
i += to_data(&img_params->in_right, data + i, spec_version);
|
||||
|
||||
if (spec_version->major() == 1) {
|
||||
if (spec_version->minor() == 0) {
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_752x480), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_752x480), data + i,
|
||||
spec_version);
|
||||
}
|
||||
|
||||
if (spec_version->minor() == 1) {
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_1280x400), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_1280x400), data + i,
|
||||
spec_version);
|
||||
|
||||
i += to_data(
|
||||
&img_params->in_left_map.at(Resolution::RES_2560x800), data + i,
|
||||
spec_version);
|
||||
i += to_data(
|
||||
&img_params->in_right_map.at(Resolution::RES_2560x800), data + i,
|
||||
spec_version);
|
||||
}
|
||||
}
|
||||
|
||||
i += to_data(&img_params->ex_right_to_left, data + i, spec_version);
|
||||
// others
|
||||
std::size_t size = i - 3;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "mynteye/mynteye.h"
|
||||
#include "mynteye/types.h"
|
||||
#include "mynteye/device/device.h"
|
||||
#include "mynteye/device/types.h"
|
||||
#include "mynteye/uvc/uvc.h"
|
||||
|
||||
@@ -67,10 +68,13 @@ class MYNTEYE_API Channels {
|
||||
|
||||
using device_info_t = DeviceInfo;
|
||||
|
||||
using imu_params_t = device::imu_params_t;
|
||||
using img_params_t = device::img_params_t;
|
||||
/*
|
||||
typedef struct ImgParams {
|
||||
bool ok;
|
||||
Intrinsics in_left;
|
||||
Intrinsics in_right;
|
||||
std::map<Resolution, Intrinsics> in_left_map;
|
||||
std::map<Resolution, Intrinsics> in_right_map;
|
||||
Extrinsics ex_right_to_left;
|
||||
} img_params_t;
|
||||
|
||||
@@ -80,7 +84,7 @@ class MYNTEYE_API Channels {
|
||||
ImuIntrinsics in_gyro;
|
||||
Extrinsics ex_left_to_imu;
|
||||
} imu_params_t;
|
||||
|
||||
*/
|
||||
explicit Channels(std::shared_ptr<uvc::device> device);
|
||||
~Channels();
|
||||
|
||||
|
||||
@@ -19,18 +19,36 @@ const std::map<Model, StreamSupports> stream_supports_map = {
|
||||
{Model::STANDARD, {Stream::LEFT, Stream::RIGHT}}};
|
||||
|
||||
const std::map<Model, CapabilitiesSupports> capabilities_supports_map = {
|
||||
{Model::STANDARD, {Capabilities::STEREO, Capabilities::IMU}}};
|
||||
{Model::STANDARD, {Capabilities::STEREO_COLOR, Capabilities::IMU}}};
|
||||
|
||||
// TODO(Kalman): Compatible with two generation
|
||||
const std::map<Model, OptionSupports> option_supports_map = {
|
||||
{Model::STANDARD,
|
||||
{Option::GAIN, Option::BRIGHTNESS, Option::CONTRAST, Option::FRAME_RATE,
|
||||
Option::IMU_FREQUENCY, Option::EXPOSURE_MODE, Option::MAX_GAIN,
|
||||
Option::MAX_EXPOSURE_TIME, Option::DESIRED_BRIGHTNESS, Option::IR_CONTROL,
|
||||
Option::HDR_MODE, Option::ZERO_DRIFT_CALIBRATION, Option::ERASE_CHIP}}};
|
||||
{Option::BRIGHTNESS, Option::EXPOSURE_MODE, Option::MAX_GAIN,
|
||||
Option::MAX_EXPOSURE_TIME, Option::DESIRED_BRIGHTNESS,
|
||||
Option::MIN_EXPOSURE_TIME, Option::ERASE_CHIP,
|
||||
Option::ACCELEROMETER_RANGE, Option::GYROSCOPE_RANGE,
|
||||
Option::ACCELEROMETER_LOW_PASS_FILTER,
|
||||
Option::GYROSCOPE_LOW_PASS_FILTER}}};
|
||||
|
||||
const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||
stream_requests_map = {
|
||||
{Model::STANDARD,
|
||||
{{Capabilities::STEREO, {{752, 480, Format::YUYV, 25}}}}}};
|
||||
{{Capabilities::STEREO, {{480, 752, Format::YUYV, 25}}},
|
||||
{Capabilities::STEREO_COLOR,
|
||||
{// {1280, 400, Format::YUYV, 10},
|
||||
// {1280, 400, Format::YUYV, 20},
|
||||
// {1280, 400, Format::YUYV, 30},
|
||||
// {1280, 400, Format::YUYV, 60},
|
||||
// {2560, 800, Format::YUYV, 10},
|
||||
// {2560, 800, Format::YUYV, 20},
|
||||
// {2560, 800, Format::YUYV, 30},
|
||||
{1280, 400, Format::BGR888, 10},
|
||||
{1280, 400, Format::BGR888, 20},
|
||||
{1280, 400, Format::BGR888, 30},
|
||||
{1280, 400, Format::BGR888, 60},
|
||||
{2560, 800, Format::BGR888, 10},
|
||||
{2560, 800, Format::BGR888, 20},
|
||||
{2560, 800, Format::BGR888, 30}}}}}};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -27,13 +27,18 @@ MYNTEYE_BEGIN_NAMESPACE
|
||||
using StreamSupports = std::set<Stream>;
|
||||
using CapabilitiesSupports = std::set<Capabilities>;
|
||||
using OptionSupports = std::set<Option>;
|
||||
|
||||
using ResolutionSupports = std::set<Resolution>;
|
||||
using FrameRateSupports = std::set<FrameRate>;
|
||||
extern const std::map<Model, StreamSupports> stream_supports_map;
|
||||
extern const std::map<Model, CapabilitiesSupports> capabilities_supports_map;
|
||||
extern const std::map<Model, OptionSupports> option_supports_map;
|
||||
extern const std::map<Model, ResolutionSupports> resolution_supports_map;
|
||||
|
||||
using StreamRequests = std::vector<StreamRequest>;
|
||||
|
||||
extern const std::map<Model, std::map<Resolution, FrameRateSupports>>
|
||||
framerate_Supports_supports_map;
|
||||
|
||||
extern const std::map<Model, std::map<Capabilities, StreamRequests>>
|
||||
stream_requests_map;
|
||||
|
||||
|
||||
@@ -100,14 +100,20 @@ std::shared_ptr<Device> Device::Create(
|
||||
return std::make_shared<StandardDevice>(device);
|
||||
} else if (strings::starts_with(name, "MYNT-EYE-")) {
|
||||
// TODO(JohnZhao): Create different device by name, such as MYNT-EYE-S1000
|
||||
std::string model_s = name.substr(9);
|
||||
std::string model_s = name.substr(9, 5);
|
||||
VLOG(2) << "MYNE EYE Model: " << model_s;
|
||||
DeviceModel model(model_s);
|
||||
switch (model.type) {
|
||||
case 'S':
|
||||
return std::make_shared<StandardDevice>(device);
|
||||
default:
|
||||
LOG(FATAL) << "MYNT EYE model is not supported now";
|
||||
if (model.type == 'S') {
|
||||
switch (model.generation) {
|
||||
case '1':
|
||||
return std::make_shared<StandardDevice>(device);
|
||||
case '2':
|
||||
return std::make_shared<StandardDevice>(device);
|
||||
default:
|
||||
LOG(FATAL) << "No such generation now";
|
||||
}
|
||||
} else {
|
||||
LOG(FATAL) << "MYNT EYE model is not supported now";
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
@@ -431,13 +437,26 @@ std::vector<device::MotionData> Device::GetMotionDatas() {
|
||||
return motions_->GetMotionDatas();
|
||||
}
|
||||
|
||||
void Device::InitResolution(const Resolution &res) {
|
||||
res_ = res;
|
||||
ConfigIntrinsics(res_);
|
||||
}
|
||||
|
||||
void Device::SetStreamRequest(const Format &format, const FrameRate &rate) {
|
||||
StreamRequest request(res_, format, rate);
|
||||
request_ = request;
|
||||
}
|
||||
|
||||
const StreamRequest &Device::GetStreamRequest(const Capabilities &capability) {
|
||||
try {
|
||||
return stream_config_requests_.at(capability);
|
||||
} catch (const std::out_of_range &e) {
|
||||
auto &&requests = GetStreamRequests(capability);
|
||||
if (requests.size() >= 1) {
|
||||
VLOG(2) << "Select the first one stream request of " << capability;
|
||||
for (auto &&request : requests) {
|
||||
if (request == request_)
|
||||
return request;
|
||||
}
|
||||
return requests[0];
|
||||
} else {
|
||||
LOG(FATAL) << "Please config the stream request of " << capability;
|
||||
@@ -454,53 +473,48 @@ void Device::StartVideoStreaming() {
|
||||
streams_ = std::make_shared<Streams>(GetKeyStreams());
|
||||
|
||||
// if stream capabilities are supported with subdevices of device_
|
||||
/*
|
||||
Capabilities stream_capabilities[] = {
|
||||
Capabilities::STEREO,
|
||||
Capabilities::COLOR,
|
||||
Capabilities::DEPTH,
|
||||
Capabilities::POINTS,
|
||||
Capabilities::FISHEYE,
|
||||
Capabilities::INFRARED,
|
||||
Capabilities::INFRARED2
|
||||
};
|
||||
Capabilities::STEREO, Capabilities::COLOR,
|
||||
Capabilities::STEREO_COLOR, Capabilities::DEPTH,
|
||||
Capabilities::POINTS, Capabilities::FISHEYE,
|
||||
Capabilities::INFRARED, Capabilities::INFRARED2};
|
||||
for (auto &&capability : stream_capabilities) {
|
||||
}
|
||||
*/
|
||||
if (Supports(Capabilities::STEREO)) {
|
||||
// do stream request selection if more than one request of each stream
|
||||
auto &&stream_request = GetStreamRequest(Capabilities::STEREO);
|
||||
if (Supports(capability)) {
|
||||
// do stream request selection if more than one request of each stream
|
||||
auto &&stream_request = GetStreamRequest(capability);
|
||||
|
||||
streams_->ConfigStream(Capabilities::STEREO, stream_request);
|
||||
uvc::set_device_mode(
|
||||
*device_, stream_request.width, stream_request.height,
|
||||
static_cast<int>(stream_request.format), stream_request.fps,
|
||||
[this](const void *data, std::function<void()> continuation) {
|
||||
// drop the first stereo stream data
|
||||
static std::uint8_t drop_count = 1;
|
||||
if (drop_count > 0) {
|
||||
--drop_count;
|
||||
continuation();
|
||||
return;
|
||||
}
|
||||
// auto &&time_beg = times::now();
|
||||
{
|
||||
std::lock_guard<std::mutex> _(mtx_streams_);
|
||||
if (streams_->PushStream(Capabilities::STEREO, data)) {
|
||||
CallbackPushedStreamData(Stream::LEFT);
|
||||
CallbackPushedStreamData(Stream::RIGHT);
|
||||
streams_->ConfigStream(capability, stream_request);
|
||||
uvc::set_device_mode(
|
||||
*device_, stream_request.width, stream_request.height,
|
||||
static_cast<int>(stream_request.format), stream_request.fps,
|
||||
[this, capability](
|
||||
const void *data, std::function<void()> continuation) {
|
||||
// drop the first stereo stream data
|
||||
static std::uint8_t drop_count = 1;
|
||||
if (drop_count > 0) {
|
||||
--drop_count;
|
||||
continuation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
continuation();
|
||||
OnStereoStreamUpdate();
|
||||
// VLOG(2) << "Stereo video callback cost "
|
||||
// << times::count<times::milliseconds>(times::now() - time_beg)
|
||||
// << " ms";
|
||||
});
|
||||
} else {
|
||||
LOG(FATAL) << "Not any stream capabilities are supported by this device";
|
||||
// auto &&time_beg = times::now();
|
||||
{
|
||||
std::lock_guard<std::mutex> _(mtx_streams_);
|
||||
if (streams_->PushStream(capability, data)) {
|
||||
CallbackPushedStreamData(Stream::LEFT);
|
||||
CallbackPushedStreamData(Stream::RIGHT);
|
||||
}
|
||||
}
|
||||
continuation();
|
||||
OnStereoStreamUpdate();
|
||||
// VLOG(2) << "Stereo video callback cost "
|
||||
// << times::count<times::milliseconds>(times::now() - time_beg)
|
||||
// << " ms";
|
||||
});
|
||||
} else {
|
||||
// LOG(FATAL) << "Not any stream capabilities are supported by this
|
||||
// device";
|
||||
}
|
||||
}
|
||||
|
||||
uvc::start_streaming(*device_, 0);
|
||||
video_streaming_ = true;
|
||||
}
|
||||
@@ -543,9 +557,8 @@ void Device::ReadAllInfos() {
|
||||
device_info_ = std::make_shared<DeviceInfo>();
|
||||
|
||||
CHECK_NOTNULL(channels_);
|
||||
Channels::img_params_t img_params;
|
||||
Channels::imu_params_t imu_params;
|
||||
if (!channels_->GetFiles(device_info_.get(), &img_params, &imu_params)) {
|
||||
Device::imu_params_t imu_params;
|
||||
if (!channels_->GetFiles(device_info_.get(), &img_params_, &imu_params)) {
|
||||
#if defined(WITH_DEVICE_INFO_REQUIRED)
|
||||
LOG(FATAL)
|
||||
#else
|
||||
@@ -566,14 +579,10 @@ void Device::ReadAllInfos() {
|
||||
<< ", nominal_baseline: " << device_info_->nominal_baseline << "}";
|
||||
|
||||
device_info_->name = uvc::get_name(*device_);
|
||||
if (img_params.ok) {
|
||||
SetIntrinsics(Stream::LEFT, img_params.in_left);
|
||||
SetIntrinsics(Stream::RIGHT, img_params.in_right);
|
||||
SetExtrinsics(Stream::RIGHT, Stream::LEFT, img_params.ex_right_to_left);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
VLOG(2) << "Extrinsics right to left: {"
|
||||
<< GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
|
||||
if (img_params_.ok) {
|
||||
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params_.ex_right_to_left);
|
||||
VLOG(2) << "Extrinsics left to right: {"
|
||||
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}";
|
||||
} else {
|
||||
LOG(WARNING) << "Intrinsics & extrinsics not exist";
|
||||
}
|
||||
@@ -588,6 +597,15 @@ void Device::ReadAllInfos() {
|
||||
}
|
||||
}
|
||||
|
||||
void Device::ConfigIntrinsics(const Resolution &res) {
|
||||
if (img_params_.ok) {
|
||||
SetIntrinsics(Stream::LEFT, img_params_.in_left_map[res]);
|
||||
SetIntrinsics(Stream::RIGHT, img_params_.in_right_map[res]);
|
||||
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
|
||||
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
|
||||
}
|
||||
}
|
||||
|
||||
void Device::CallbackPushedStreamData(const Stream &stream) {
|
||||
if (HasStreamCallback(stream)) {
|
||||
auto &&datas = streams_->stream_datas(stream);
|
||||
@@ -611,4 +629,8 @@ void Device::CallbackMotionData(const device::MotionData &data) {
|
||||
}
|
||||
}
|
||||
|
||||
Device::img_params_t Device::GetImgParams() {
|
||||
return img_params_;
|
||||
}
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -34,26 +34,48 @@ Motions::~Motions() {
|
||||
void Motions::SetMotionCallback(motion_callback_t callback) {
|
||||
motion_callback_ = callback;
|
||||
if (motion_callback_) {
|
||||
accel_range = channels_->GetControlValue(Option::ACCELEROMETER_RANGE);
|
||||
if (accel_range == -1)
|
||||
accel_range = 12;
|
||||
|
||||
gyro_range = channels_->GetControlValue(Option::GYROSCOPE_RANGE);
|
||||
if (gyro_range == -1)
|
||||
gyro_range = 1000;
|
||||
|
||||
channels_->SetImuCallback([this](const ImuPacket &packet) {
|
||||
if (!motion_callback_ && !motion_datas_enabled_) {
|
||||
return;
|
||||
}
|
||||
for (auto &&seg : packet.segments) {
|
||||
auto &&imu = std::make_shared<ImuData>();
|
||||
imu->frame_id = seg.frame_id;
|
||||
// imu->frame_id = seg.frame_id;
|
||||
// if (seg.offset < 0 &&
|
||||
// static_cast<uint32_t>(-seg.offset) > packet.timestamp) {
|
||||
// LOG(WARNING) << "Imu timestamp offset is incorrect";
|
||||
// }
|
||||
imu->timestamp = packet.timestamp + seg.offset;
|
||||
imu->accel[0] = seg.accel[0] * 8.f / 0x10000;
|
||||
imu->accel[1] = seg.accel[1] * 8.f / 0x10000;
|
||||
imu->accel[2] = seg.accel[2] * 8.f / 0x10000;
|
||||
imu->gyro[0] = seg.gyro[0] * 1000.f / 0x10000;
|
||||
imu->gyro[1] = seg.gyro[1] * 1000.f / 0x10000;
|
||||
imu->gyro[2] = seg.gyro[2] * 1000.f / 0x10000;
|
||||
imu->serial_number = seg.serial_number;
|
||||
imu->timestamp = seg.timestamp;
|
||||
imu->flag = seg.flag;
|
||||
imu->temperature = seg.temperature / 326.8f + 25;
|
||||
|
||||
if (imu->flag == 1) {
|
||||
imu->accel[0] = seg.accel_or_gyro[0] * 1.f * accel_range / 0x10000;
|
||||
imu->accel[1] = seg.accel_or_gyro[1] * 1.f * accel_range / 0x10000;
|
||||
imu->accel[2] = seg.accel_or_gyro[2] * 1.f * accel_range / 0x10000;
|
||||
imu->gyro[0] = 0;
|
||||
imu->gyro[1] = 0;
|
||||
imu->gyro[2] = 0;
|
||||
} else if (imu->flag == 2) {
|
||||
imu->accel[0] = 0;
|
||||
imu->accel[1] = 0;
|
||||
imu->accel[2] = 0;
|
||||
imu->gyro[0] = seg.accel_or_gyro[0] * 1.f * gyro_range / 0x10000;
|
||||
imu->gyro[1] = seg.accel_or_gyro[1] * 1.f * gyro_range / 0x10000;
|
||||
imu->gyro[2] = seg.accel_or_gyro[2] * 1.f * gyro_range / 0x10000;
|
||||
} else {
|
||||
imu->Reset();
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> _(mtx_datas_);
|
||||
motion_data_t data = {imu};
|
||||
if (motion_datas_enabled_) {
|
||||
|
||||
@@ -57,6 +57,9 @@ class Motions {
|
||||
bool is_imu_tracking;
|
||||
|
||||
std::mutex mtx_datas_;
|
||||
|
||||
int accel_range = 12;
|
||||
int gyro_range = 1000;
|
||||
};
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace {
|
||||
bool unpack_stereo_img_data(
|
||||
const void *data, const StreamRequest &request, ImgData *img) {
|
||||
CHECK_NOTNULL(img);
|
||||
CHECK_EQ(request.format, Format::YUYV);
|
||||
|
||||
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
||||
std::size_t data_n =
|
||||
request.width * request.height * bytes_per_pixel(request.format);
|
||||
@@ -59,6 +57,7 @@ bool unpack_stereo_img_data(
|
||||
for (std::size_t i = 2, n = packet_n - 2; i <= n; i++) { // content: [2,9]
|
||||
checksum = (checksum ^ packet[i]);
|
||||
}
|
||||
|
||||
if (img_packet.checksum != checksum) {
|
||||
VLOG(2) << "Image packet checksum should be 0x" << std::hex
|
||||
<< std::uppercase << std::setw(2) << std::setfill('0')
|
||||
@@ -77,26 +76,53 @@ bool unpack_stereo_img_data(
|
||||
bool unpack_left_img_pixels(
|
||||
const void *data, const StreamRequest &request, Streams::frame_t *frame) {
|
||||
CHECK_NOTNULL(frame);
|
||||
CHECK_EQ(request.format, Format::YUYV);
|
||||
CHECK_EQ(frame->format(), Format::GREY);
|
||||
CHECK_EQ(request.format, frame->format());
|
||||
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
||||
std::size_t n = frame->width() * frame->height();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
frame->data()[i] = *(data_new + (i * 2));
|
||||
if (request.format == Format::YUYV || request.format == Format::BGR888) {
|
||||
std::size_t n = request.format == Format::YUYV ? 2 : 3;
|
||||
std::size_t w = frame->width() * n;
|
||||
std::size_t h = frame->height();
|
||||
for (std::size_t i = 0; i < h; i++) {
|
||||
for (std::size_t j = 0; j < w; j++) {
|
||||
frame->data()[i * w + j] = *(data_new + 2 * i * w + j);
|
||||
}
|
||||
}
|
||||
} else if (request.format == Format::GREY) {
|
||||
std::size_t n = frame->width() * frame->height();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
frame->data()[i] = *(data_new + (i * 2));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO(Kalman): Too similar to 'unpack_left_img_pixels'
|
||||
bool unpack_right_img_pixels(
|
||||
const void *data, const StreamRequest &request, Streams::frame_t *frame) {
|
||||
CHECK_NOTNULL(frame);
|
||||
CHECK_EQ(request.format, Format::YUYV);
|
||||
CHECK_EQ(frame->format(), Format::GREY);
|
||||
CHECK_EQ(request.format, frame->format());
|
||||
auto data_new = reinterpret_cast<const std::uint8_t *>(data);
|
||||
std::size_t n = frame->width() * frame->height();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
frame->data()[i] = *(data_new + (i * 2 + 1));
|
||||
if (request.format == Format::YUYV || request.format == Format::BGR888) {
|
||||
std::size_t n = request.format == Format::YUYV ? 2 : 3;
|
||||
std::size_t w = frame->width() * n;
|
||||
std::size_t h = frame->height();
|
||||
for (std::size_t i = 0; i < h; i++) {
|
||||
for (std::size_t j = 0; j < w; j++) {
|
||||
frame->data()[i * w + j] = *(data_new + (2 * i + 1) * w + j);
|
||||
}
|
||||
}
|
||||
} else if (request.format == Format::GREY) {
|
||||
std::size_t n = frame->width() * frame->height();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
frame->data()[i] = *(data_new + (i * 2 + 1));
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,7 +133,7 @@ Streams::Streams(const std::vector<Stream> key_streams)
|
||||
stream_capabilities_(
|
||||
{Capabilities::STEREO, Capabilities::COLOR, Capabilities::DEPTH,
|
||||
Capabilities::POINTS, Capabilities::FISHEYE, Capabilities::INFRARED,
|
||||
Capabilities::INFRARED2}),
|
||||
Capabilities::INFRARED2, Capabilities::STEREO_COLOR}),
|
||||
unpack_img_data_map_(
|
||||
{{Stream::LEFT, unpack_stereo_img_data},
|
||||
{Stream::RIGHT, unpack_stereo_img_data}}),
|
||||
@@ -139,16 +165,16 @@ bool Streams::PushStream(const Capabilities &capability, const void *data) {
|
||||
auto &&request = GetStreamConfigRequest(capability);
|
||||
bool pushed = false;
|
||||
switch (capability) {
|
||||
case Capabilities::STEREO: {
|
||||
case Capabilities::STEREO_COLOR: {
|
||||
// alloc left
|
||||
AllocStreamData(Stream::LEFT, request, Format::GREY);
|
||||
AllocStreamData(Stream::LEFT, request);
|
||||
auto &&left_data = stream_datas_map_[Stream::LEFT].back();
|
||||
// unpack img data
|
||||
if (unpack_img_data_map_[Stream::LEFT](
|
||||
data, request, left_data.img.get())) {
|
||||
left_data.frame_id = left_data.img->frame_id;
|
||||
// alloc right
|
||||
AllocStreamData(Stream::RIGHT, request, Format::GREY);
|
||||
AllocStreamData(Stream::RIGHT, request);
|
||||
auto &&right_data = stream_datas_map_[Stream::RIGHT].back();
|
||||
*right_data.img = *left_data.img;
|
||||
right_data.frame_id = left_data.img->frame_id;
|
||||
@@ -282,8 +308,11 @@ void Streams::AllocStreamData(
|
||||
data.img = nullptr;
|
||||
}
|
||||
if (!data.frame) {
|
||||
data.frame = std::make_shared<frame_t>(
|
||||
request.width, request.height, format, nullptr);
|
||||
int width = request.width;
|
||||
if (format != Format::GREY)
|
||||
width /= 2;
|
||||
data.frame =
|
||||
std::make_shared<frame_t>(width, request.height, format, nullptr);
|
||||
}
|
||||
data.frame_id = 0;
|
||||
stream_datas_map_[stream].push_back(data);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
@@ -148,7 +147,7 @@ struct ImagePacket {
|
||||
std::uint8_t header;
|
||||
std::uint8_t size;
|
||||
std::uint16_t frame_id;
|
||||
std::uint32_t timestamp;
|
||||
std::uint64_t timestamp;
|
||||
std::uint16_t exposure_time;
|
||||
std::uint8_t checksum;
|
||||
|
||||
@@ -158,13 +157,19 @@ struct ImagePacket {
|
||||
}
|
||||
|
||||
void from_data(std::uint8_t *data) {
|
||||
std::uint32_t timestamp_l;
|
||||
std::uint32_t timestamp_h;
|
||||
|
||||
header = *data;
|
||||
size = *(data + 1);
|
||||
frame_id = (*(data + 2) << 8) | *(data + 3);
|
||||
timestamp = (*(data + 4) << 24) | (*(data + 5) << 16) | (*(data + 6) << 8) |
|
||||
*(data + 7);
|
||||
exposure_time = (*(data + 8) << 8) | *(data + 9);
|
||||
checksum = *(data + 10);
|
||||
timestamp_h = (*(data + 4) << 24) | (*(data + 5) << 16) |
|
||||
(*(data + 6) << 8) | *(data + 7);
|
||||
timestamp_l = (*(data + 8) << 24) | (*(data + 9) << 16) |
|
||||
(*(data + 10) << 8) | *(data + 11);
|
||||
timestamp = (static_cast<std::uint64_t>(timestamp_h) << 32) | timestamp_l;
|
||||
exposure_time = (*(data + 12) << 8) | *(data + 13);
|
||||
checksum = *(data + 14);
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
@@ -199,11 +204,11 @@ struct ImuReqPacket {
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuSegment {
|
||||
std::int16_t offset;
|
||||
std::uint16_t frame_id;
|
||||
std::int16_t accel[3];
|
||||
std::uint32_t serial_number;
|
||||
std::uint64_t timestamp;
|
||||
std::uint8_t flag;
|
||||
std::int16_t temperature;
|
||||
std::int16_t gyro[3];
|
||||
std::int16_t accel_or_gyro[3];
|
||||
|
||||
ImuSegment() = default;
|
||||
explicit ImuSegment(std::uint8_t *data) {
|
||||
@@ -211,15 +216,21 @@ struct ImuSegment {
|
||||
}
|
||||
|
||||
void from_data(std::uint8_t *data) {
|
||||
offset = (*(data) << 8) | *(data + 1);
|
||||
frame_id = (*(data + 2) << 8) | *(data + 3);
|
||||
accel[0] = (*(data + 4) << 8) | *(data + 5);
|
||||
accel[1] = (*(data + 6) << 8) | *(data + 7);
|
||||
accel[2] = (*(data + 8) << 8) | *(data + 9);
|
||||
temperature = (*(data + 10) << 8) | *(data + 11);
|
||||
gyro[0] = (*(data + 12) << 8) | *(data + 13);
|
||||
gyro[1] = (*(data + 14) << 8) | *(data + 15);
|
||||
gyro[2] = (*(data + 16) << 8) | *(data + 17);
|
||||
std::uint32_t timestamp_l;
|
||||
std::uint32_t timestamp_h;
|
||||
|
||||
serial_number = (*(data) << 24) | (*(data + 1) << 16) | (*(data + 2) << 8) |
|
||||
*(data + 3);
|
||||
timestamp_h = (*(data + 4) << 24) | (*(data + 5) << 16) |
|
||||
(*(data + 6) << 8) | *(data + 7);
|
||||
timestamp_l = (*(data + 8) << 24) | (*(data + 9) << 16) |
|
||||
(*(data + 10) << 8) | *(data + 11);
|
||||
timestamp = (static_cast<std::uint64_t>(timestamp_h) << 32) | timestamp_l;
|
||||
flag = *(data + 12);
|
||||
temperature = (*(data + 13) << 8) | *(data + 14);
|
||||
accel_or_gyro[0] = (*(data + 15) << 8) | *(data + 16);
|
||||
accel_or_gyro[1] = (*(data + 17) << 8) | *(data + 18);
|
||||
accel_or_gyro[2] = (*(data + 19) << 8) | *(data + 20);
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
@@ -230,27 +241,19 @@ struct ImuSegment {
|
||||
*/
|
||||
#pragma pack(push, 1)
|
||||
struct ImuPacket {
|
||||
std::uint32_t serial_number;
|
||||
std::uint32_t timestamp;
|
||||
std::uint8_t count;
|
||||
std::vector<ImuSegment> segments;
|
||||
|
||||
ImuPacket() = default;
|
||||
explicit ImuPacket(std::uint8_t *data) {
|
||||
explicit ImuPacket(std::uint8_t seg_count, std::uint8_t *data) {
|
||||
count = seg_count;
|
||||
from_data(data);
|
||||
}
|
||||
|
||||
void from_data(std::uint8_t *data) {
|
||||
serial_number = (*(data) << 24) | (*(data + 1) << 16) | (*(data + 2) << 8) |
|
||||
*(data + 3);
|
||||
timestamp = (*(data + 4) << 24) | (*(data + 5) << 16) | (*(data + 6) << 8) |
|
||||
*(data + 7);
|
||||
count = *(data + 8);
|
||||
|
||||
std::size_t seg_n = sizeof(ImuSegment); // 18
|
||||
for (std::size_t i = 0; i < count; i++) {
|
||||
segments.push_back(ImuSegment(data + 9 + (seg_n * i)));
|
||||
}
|
||||
std::size_t seg_n = sizeof(ImuSegment); // 21
|
||||
for (std::size_t i = 0; i < count; i++) {
|
||||
segments.push_back(ImuSegment(data + seg_n * i));
|
||||
}
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
@@ -277,13 +280,11 @@ struct ImuResPacket {
|
||||
state = *(data + 1);
|
||||
size = (*(data + 2) << 8) | *(data + 3);
|
||||
|
||||
std::size_t seg_n = sizeof(ImuSegment); // 18
|
||||
for (std::size_t i = 4; i < size;) {
|
||||
ImuPacket packet(data + i);
|
||||
packets.push_back(packet);
|
||||
i += 9 + (packet.count * seg_n);
|
||||
}
|
||||
|
||||
std::size_t seg_n = sizeof(ImuSegment); // 21
|
||||
std::uint8_t seg_count = size / seg_n;
|
||||
ImuPacket packet(seg_count, data + 4);
|
||||
packets.push_back(packet);
|
||||
// packet(2);
|
||||
checksum = *(data + 4 + size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "mynteye/device/context.h"
|
||||
#include "mynteye/device/device.h"
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace device {
|
||||
|
||||
@@ -114,6 +114,11 @@ const char *to_string(const Option &value) {
|
||||
CASE(HDR_MODE)
|
||||
CASE(ZERO_DRIFT_CALIBRATION)
|
||||
CASE(ERASE_CHIP)
|
||||
CASE(MIN_EXPOSURE_TIME)
|
||||
CASE(ACCELEROMETER_RANGE)
|
||||
CASE(GYROSCOPE_RANGE)
|
||||
CASE(ACCELEROMETER_LOW_PASS_FILTER)
|
||||
CASE(GYROSCOPE_LOW_PASS_FILTER)
|
||||
default:
|
||||
CHECK(is_valid(value));
|
||||
return "Option::UNKNOWN";
|
||||
@@ -167,6 +172,8 @@ std::size_t bytes_per_pixel(const Format &value) {
|
||||
return 1;
|
||||
case Format::YUYV:
|
||||
return 2;
|
||||
case Format::BGR888:
|
||||
return 3;
|
||||
default:
|
||||
LOG(FATAL) << "Unknown format";
|
||||
}
|
||||
|
||||
@@ -46,9 +46,10 @@ namespace uvc {
|
||||
} while (0)
|
||||
|
||||
#define NO_DATA_MAX_COUNT 200
|
||||
#define LIVING_MAX_COUNT 9000
|
||||
|
||||
int no_data_count = 0;
|
||||
|
||||
int living_count = 0;
|
||||
/*
|
||||
class device_error : public std::exception {
|
||||
public:
|
||||
@@ -394,6 +395,12 @@ struct device {
|
||||
if (xioctl(fd, VIDIOC_QBUF, &buf) < 0)
|
||||
throw_error("VIDIOC_QBUF");
|
||||
});
|
||||
if (living_count < LIVING_MAX_COUNT) {
|
||||
living_count++;
|
||||
} else {
|
||||
living_count = 0;
|
||||
// LOG(INFO) << "UVC pulse detection,Please ignore.";
|
||||
}
|
||||
}
|
||||
|
||||
no_data_count = 0;
|
||||
@@ -402,7 +409,12 @@ struct device {
|
||||
}
|
||||
|
||||
if (no_data_count > NO_DATA_MAX_COUNT) {
|
||||
throw_error("v4l2 get stream time out!");
|
||||
no_data_count = 0;
|
||||
living_count = 0;
|
||||
LOG(WARNING) << __func__
|
||||
<< " failed: v4l2 get stream time out,Try to reboot!";
|
||||
stop_capture();
|
||||
start_capture();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
91
src/mynteye/uvc/macosx/AVfoundationCamera.h
Normal file
91
src/mynteye/uvc/macosx/AVfoundationCamera.h
Normal file
@@ -0,0 +1,91 @@
|
||||
// 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 AVfoundationCamera_H
|
||||
#define AVfoundationCamera_H
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "VVUVCKit.h"
|
||||
|
||||
#include "CameraEngine.h"
|
||||
|
||||
static int32_t codec_table[] = { 0, 40, 0, 24, 0, 0, 0, 0, 0, 0, 'yuvs', '2vuy', 0, 'v308', '420v', '410v', 0, 0, 0, 0, 'dmb1', 'dmb1', 'mp1v', 'mp2v', 'mp4v', 'h263', 'avc1', 'dvcp', 'dvc ' };
|
||||
|
||||
|
||||
@interface FrameGrabber : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>
|
||||
{
|
||||
bool new_frame;
|
||||
int cam_width, cam_height;
|
||||
int frm_width, frm_height;
|
||||
int xoff, yoff;
|
||||
unsigned char *buffer;
|
||||
bool crop;
|
||||
bool color;
|
||||
}
|
||||
- (id) initWithCameraSize:(int)w :(int)h :(int)b;
|
||||
- (id) initWithCropSize:(int)cw :(int)ch :(int)b :(int)fw :(int)fh :(int)xo :(int)yo;
|
||||
- (void)captureOutput:(AVCaptureOutput *)captureOutput
|
||||
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
fromConnection:(AVCaptureConnection *)connection;
|
||||
- (unsigned char*) getFrame;
|
||||
|
||||
@end
|
||||
|
||||
class AVfoundationCamera : public CameraEngine
|
||||
{
|
||||
|
||||
public:
|
||||
AVfoundationCamera(CameraConfig* cam_cfg);
|
||||
~AVfoundationCamera();
|
||||
|
||||
static int getDeviceCount();
|
||||
static std::vector<CameraConfig> getCameraConfigs(int dev_id = -1);
|
||||
static CameraEngine* getCamera(CameraConfig* cam_cfg);
|
||||
|
||||
bool initCamera();
|
||||
bool startCamera();
|
||||
unsigned char* getFrame();
|
||||
bool stopCamera();
|
||||
bool stillRunning();
|
||||
bool resetCamera();
|
||||
bool closeCamera();
|
||||
|
||||
int getCameraSettingStep(int mode);
|
||||
bool setCameraSettingAuto(int mode, bool flag);
|
||||
bool getCameraSettingAuto(int mode);
|
||||
bool setCameraSetting(int mode, int value);
|
||||
int getCameraSetting(int mode);
|
||||
int getMaxCameraSetting(int mode);
|
||||
int getMinCameraSetting(int mode);
|
||||
bool setDefaultCameraSetting(int mode);
|
||||
int getDefaultCameraSetting(int mode);
|
||||
bool hasCameraSetting(int mode);
|
||||
bool hasCameraSettingAuto(int mode);
|
||||
|
||||
bool showSettingsDialog(bool lock);
|
||||
|
||||
private:
|
||||
|
||||
bool disconnected;
|
||||
|
||||
VVUVCController *uvcController;
|
||||
FrameGrabber *grabber;
|
||||
|
||||
AVCaptureSession *session;
|
||||
AVCaptureDeviceInput *videoDeviceInput;
|
||||
AVCaptureVideoDataOutput *videoOutput;
|
||||
AVCaptureDevice *videoDevice;
|
||||
};
|
||||
#endif
|
||||
739
src/mynteye/uvc/macosx/AVfoundationCamera.mm
Normal file
739
src/mynteye/uvc/macosx/AVfoundationCamera.mm
Normal file
@@ -0,0 +1,739 @@
|
||||
// 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 "AVfoundationCamera.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
// #include "CameraTool.h"
|
||||
|
||||
#ifdef OSC_HOST_BIG_ENDIAN
|
||||
#define FourCC2Str(fourcc) (const char[]){*((char*)&fourcc), *(((char*)&fourcc)+1), *(((char*)&fourcc)+2), *(((char*)&fourcc)+3),0}
|
||||
#else
|
||||
#define FourCC2Str(fourcc) (const char[]){*(((char*)&fourcc)+3), *(((char*)&fourcc)+2), *(((char*)&fourcc)+1), *(((char*)&fourcc)+0),0}
|
||||
#endif
|
||||
|
||||
@implementation FrameGrabber
|
||||
- (id) initWithCameraSize:(int)cw :(int)ch :(int) bytes
|
||||
{
|
||||
self = [super init];
|
||||
cam_width = cw;
|
||||
cam_height = ch;
|
||||
new_frame = false;
|
||||
crop = false;
|
||||
|
||||
if(bytes==3) color = true;
|
||||
else color = false;
|
||||
|
||||
buffer = new unsigned char[cam_width*cam_height*bytes];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithCropSize:(int)cw :(int)ch :(int)bytes :(int)fw :(int)fh :(int)xo :(int)yo
|
||||
{
|
||||
self = [super init];
|
||||
cam_width = cw;
|
||||
cam_height = ch;
|
||||
frm_width = fw;
|
||||
frm_height = fh;
|
||||
xoff = xo;
|
||||
yoff = yo;
|
||||
new_frame = false;
|
||||
crop = true;
|
||||
|
||||
if(bytes==3) color = true;
|
||||
else color = false;
|
||||
|
||||
buffer = new unsigned char[frm_width*frm_height*bytes];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void)captureOutput:(AVCaptureOutput *)captureOutput
|
||||
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
fromConnection:(AVCaptureConnection *)connection
|
||||
{
|
||||
|
||||
new_frame = false;
|
||||
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
|
||||
if (CVPixelBufferLockBaseAddress(imageBuffer, 0) == kCVReturnSuccess) {
|
||||
|
||||
unsigned char *src = (unsigned char*)CVPixelBufferGetBaseAddress(imageBuffer);
|
||||
unsigned char *dest = buffer;
|
||||
|
||||
if (color) {
|
||||
|
||||
if (crop) {
|
||||
unsigned char *src_buf = src + 3*(yoff*cam_width + xoff);
|
||||
|
||||
for (int i=0;i<frm_height;i++) {
|
||||
memcpy(dest, src_buf, 3*frm_width);
|
||||
|
||||
src_buf += 3*cam_width;
|
||||
dest += 3*frm_width;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
memcpy(dest,src,cam_width*cam_height*3);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (crop) {
|
||||
|
||||
src += 2*(yoff*cam_width);
|
||||
int xend = (cam_width-(frm_width+xoff));
|
||||
|
||||
for (int i=0;i<frm_height;i++) {
|
||||
|
||||
src += 2*xoff;
|
||||
for (int j=frm_width/2;j>0;j--) {
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
}
|
||||
src += 2*xend;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
int size = cam_width*cam_height/2;
|
||||
for (int i=size;i>0;i--) {
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
|
||||
new_frame = true;
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned char*) getFrame
|
||||
{
|
||||
if (new_frame){
|
||||
new_frame = false;
|
||||
return buffer;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if(buffer) delete []buffer;
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
AVfoundationCamera::AVfoundationCamera(CameraConfig *cam_cfg):CameraEngine(cam_cfg)
|
||||
{
|
||||
disconnected = false;
|
||||
running=false;
|
||||
lost_frames=0;
|
||||
timeout = 1000;
|
||||
|
||||
uvcController = NULL;
|
||||
|
||||
session = NULL;
|
||||
videoDeviceInput = NULL;
|
||||
videoOutput = NULL;
|
||||
|
||||
videoDevice = NULL;
|
||||
grabber = NULL;
|
||||
|
||||
cam_cfg->driver = DRIVER_DEFAULT;
|
||||
}
|
||||
|
||||
AVfoundationCamera::~AVfoundationCamera()
|
||||
{
|
||||
if (uvcController) [uvcController release];
|
||||
//if (videoDevice) [videoDevice release];
|
||||
if (videoOutput) [videoOutput release];
|
||||
if (grabber) [grabber release];
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getDeviceCount() {
|
||||
|
||||
NSInteger dev_count0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo].count;
|
||||
NSInteger dev_count1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed].count;
|
||||
return (dev_count0 + dev_count1);
|
||||
}
|
||||
|
||||
std::vector<CameraConfig> AVfoundationCamera::getCameraConfigs(int dev_id) {
|
||||
std::vector<CameraConfig> cfg_list;
|
||||
|
||||
int dev_count = getDeviceCount();
|
||||
if (dev_count==0) return cfg_list;
|
||||
|
||||
NSMutableArray *captureDevices = [NSMutableArray arrayWithCapacity:dev_count];
|
||||
NSArray *dev_list0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
|
||||
for (AVCaptureDevice* device in dev_list0) [captureDevices addObject:device];
|
||||
NSArray *dev_list1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];
|
||||
for (AVCaptureDevice* device in dev_list1)[captureDevices addObject:device];
|
||||
|
||||
int cam_id = -1;
|
||||
for (AVCaptureDevice* device in captureDevices) {
|
||||
cam_id ++;
|
||||
if ((dev_id>=0) && (dev_id!=cam_id)) continue;
|
||||
|
||||
CameraConfig cam_cfg;
|
||||
// CameraTool::initCameraConfig(&cam_cfg);
|
||||
|
||||
cam_cfg.driver = DRIVER_DEFAULT;
|
||||
cam_cfg.device = cam_id;
|
||||
|
||||
if ([device localizedName]!=NULL)
|
||||
sprintf(cam_cfg.name,"%s",[[device localizedName] cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
else sprintf(cam_cfg.name,"unknown device");
|
||||
|
||||
std::vector<CameraConfig> fmt_list;
|
||||
int last_format = FORMAT_UNKNOWN;
|
||||
NSArray *captureDeviceFormats = [device formats];
|
||||
for (AVCaptureDeviceFormat *format in captureDeviceFormats) {
|
||||
|
||||
int32_t codec = CMVideoFormatDescriptionGetCodecType((CMVideoFormatDescriptionRef)[format formatDescription]);
|
||||
|
||||
if (codec == '420f') codec = '420v';
|
||||
|
||||
cam_cfg.cam_format = FORMAT_UNKNOWN;
|
||||
for (int i=FORMAT_MAX-1;i>0;i--) {
|
||||
if (codec == codec_table[i]) {
|
||||
cam_cfg.cam_format = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cam_cfg.cam_format != last_format) {
|
||||
std::sort(fmt_list.begin(), fmt_list.end());
|
||||
cfg_list.insert( cfg_list.end(), fmt_list.begin(), fmt_list.end() );
|
||||
fmt_list.clear();
|
||||
last_format = cam_cfg.cam_format;
|
||||
}
|
||||
|
||||
CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
||||
|
||||
cam_cfg.cam_width = dim.width;
|
||||
cam_cfg.cam_height = dim.height;
|
||||
|
||||
for (AVFrameRateRange *frameRateRange in [format videoSupportedFrameRateRanges]) {
|
||||
cam_cfg.cam_fps = roundf([frameRateRange maxFrameRate]*10)/10.0f;
|
||||
fmt_list.push_back(cam_cfg);
|
||||
}
|
||||
}
|
||||
std::sort(fmt_list.begin(), fmt_list.end());
|
||||
cfg_list.insert( cfg_list.end(), fmt_list.begin(), fmt_list.end() );
|
||||
}
|
||||
|
||||
//[captureDevices release];
|
||||
return cfg_list;
|
||||
}
|
||||
|
||||
CameraEngine* AVfoundationCamera::getCamera(CameraConfig *cam_cfg) {
|
||||
|
||||
int dev_count = getDeviceCount();
|
||||
if (dev_count==0) return NULL;
|
||||
|
||||
if ((cam_cfg->device==SETTING_MIN) || (cam_cfg->device==SETTING_DEFAULT)) cam_cfg->device=0;
|
||||
else if (cam_cfg->device==SETTING_MAX) cam_cfg->device=dev_count-1;
|
||||
|
||||
std::vector<CameraConfig> cfg_list = AVfoundationCamera::getCameraConfigs(cam_cfg->device);
|
||||
if (cam_cfg->cam_format==FORMAT_UNKNOWN) cam_cfg->cam_format = cfg_list[0].cam_format;
|
||||
setMinMaxConfig(cam_cfg,cfg_list);
|
||||
|
||||
if (cam_cfg->force) return new AVfoundationCamera(cam_cfg);
|
||||
|
||||
for (int i=0;i<cfg_list.size();i++) {
|
||||
|
||||
if (cam_cfg->cam_format != cfg_list[i].cam_format) continue;
|
||||
if ((cam_cfg->cam_width >=0) && (cam_cfg->cam_width != cfg_list[i].cam_width)) continue;
|
||||
if ((cam_cfg->cam_height >=0) && (cam_cfg->cam_height != cfg_list[i].cam_height)) continue;
|
||||
if ((cam_cfg->cam_fps >=0) && (cam_cfg->cam_fps != cfg_list[i].cam_fps)) continue;
|
||||
|
||||
return new AVfoundationCamera(cam_cfg);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::initCamera() {
|
||||
|
||||
int dev_count = getDeviceCount();
|
||||
if ((dev_count==0) || (cfg->device < 0) || (cfg->device>=dev_count)) return false;
|
||||
|
||||
NSMutableArray *videoDevices = [NSMutableArray arrayWithCapacity:dev_count];
|
||||
NSArray *dev_list0 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
|
||||
for (AVCaptureDevice* dev in dev_list0) [videoDevices addObject:dev];
|
||||
NSArray *dev_list1 = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];
|
||||
for (AVCaptureDevice* dev in dev_list1) [videoDevices addObject:dev];
|
||||
|
||||
videoDevice = [videoDevices objectAtIndex:cfg->device];
|
||||
if (videoDevice==NULL) return false;
|
||||
//else [videoDevices release];
|
||||
|
||||
if ([videoDevice localizedName]!=NULL)
|
||||
sprintf(cfg->name,"%s",[[videoDevice localizedName] cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
else sprintf(cfg->name,"unknown");
|
||||
|
||||
session = [[AVCaptureSession alloc] init];
|
||||
if (session==NULL) return false;
|
||||
|
||||
NSError *error = nil;
|
||||
videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
|
||||
if (videoDeviceInput == NULL) return false;
|
||||
|
||||
std::vector<CameraConfig> cfg_list = getCameraConfigs(cfg->device);
|
||||
if (cfg->cam_format==FORMAT_UNKNOWN) cfg->cam_format = cfg_list[0].cam_format;
|
||||
setMinMaxConfig(cfg, cfg_list);
|
||||
|
||||
AVCaptureDeviceFormat *selectedFormat = NULL;
|
||||
AVFrameRateRange *selectedFrameRateRange = NULL;
|
||||
NSArray *videoDeviceFormats = [videoDevice formats];
|
||||
for (AVCaptureDeviceFormat *format in videoDeviceFormats) {
|
||||
|
||||
CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[format formatDescription]);
|
||||
|
||||
if ((dim.width!=cfg->cam_width) || (dim.height!=cfg->cam_height)) continue; // wrong size
|
||||
|
||||
int cam_format=0;
|
||||
int32_t codec = CMVideoFormatDescriptionGetCodecType((CMVideoFormatDescriptionRef)[format formatDescription]);
|
||||
if (codec == '420f') codec = '420v';
|
||||
|
||||
for (int i=FORMAT_MAX-1;i>0;i--) {
|
||||
|
||||
if ((codec == codec_table[i]) && (cfg->cam_format==i)) {
|
||||
cam_format = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cam_format) continue; // wrong format
|
||||
else selectedFormat = format;
|
||||
|
||||
for (AVFrameRateRange *frameRateRange in [selectedFormat videoSupportedFrameRateRanges]) {
|
||||
float framerate = roundf([frameRateRange maxFrameRate]*10)/10.0f;
|
||||
if (framerate==cfg->cam_fps) { // found exact framerate
|
||||
selectedFrameRateRange = frameRateRange;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedFrameRateRange) break;
|
||||
}
|
||||
|
||||
if ((selectedFrameRateRange==NULL) || (selectedFormat==NULL)) return false;
|
||||
|
||||
[videoDevice lockForConfiguration:&error];
|
||||
[videoDevice setActiveFormat:selectedFormat];
|
||||
if ([[[videoDevice activeFormat] videoSupportedFrameRateRanges] containsObject:selectedFrameRateRange]) {
|
||||
//[videoDevice setActiveVideoMaxFrameDuration:[selectedFrameRateRange maxFrameDuration]];
|
||||
[videoDevice setActiveVideoMinFrameDuration:[selectedFrameRateRange minFrameDuration]];
|
||||
}
|
||||
[videoDevice unlockForConfiguration];
|
||||
|
||||
CMVideoDimensions dimensions =
|
||||
CMVideoFormatDescriptionGetDimensions((CMVideoFormatDescriptionRef)[[videoDevice activeFormat] formatDescription]);
|
||||
|
||||
cfg->cam_width = dimensions.width;
|
||||
cfg->cam_height = dimensions.height;
|
||||
|
||||
for (AVFrameRateRange *frameRateRange in [[videoDevice activeFormat] videoSupportedFrameRateRanges])
|
||||
{
|
||||
cfg->cam_fps = roundf([frameRateRange maxFrameRate]*10)/10.0f;
|
||||
if (CMTIME_COMPARE_INLINE([frameRateRange minFrameDuration], ==, [videoDevice activeVideoMinFrameDuration])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
videoOutput = [[AVCaptureVideoDataOutput alloc] init];
|
||||
|
||||
unsigned int pixelformat = kCVPixelFormatType_422YpCbCr8_yuvs;
|
||||
cfg->src_format = FORMAT_YUYV;
|
||||
if (cfg->color) {
|
||||
pixelformat = kCVPixelFormatType_24RGB;
|
||||
cfg->src_format = FORMAT_RGB;
|
||||
}
|
||||
|
||||
NSDictionary *pixelBufferOptions = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithDouble:cfg->cam_width], (id)kCVPixelBufferWidthKey,
|
||||
[NSNumber numberWithDouble:cfg->cam_height], (id)kCVPixelBufferHeightKey,
|
||||
[NSNumber numberWithUnsignedInt: pixelformat ],
|
||||
(id)kCVPixelBufferPixelFormatTypeKey, nil];
|
||||
|
||||
[videoOutput setVideoSettings:pixelBufferOptions];
|
||||
|
||||
videoOutput.alwaysDiscardsLateVideoFrames = YES;
|
||||
[session addInput:videoDeviceInput];
|
||||
[session addOutput:videoOutput];
|
||||
|
||||
// configure output.
|
||||
setupFrame();
|
||||
dispatch_queue_t queue = dispatch_queue_create("queue", NULL);
|
||||
if (cfg->frame) {
|
||||
grabber = [[FrameGrabber alloc] initWithCropSize:cfg->cam_width :cfg->cam_height :cfg->buf_format :cfg->frame_width :cfg->frame_height :cfg->frame_xoff :cfg->frame_yoff];
|
||||
} else {
|
||||
grabber = [[FrameGrabber alloc] initWithCameraSize:cfg->cam_width :cfg->cam_height: cfg->buf_format];
|
||||
}
|
||||
[videoOutput setSampleBufferDelegate:grabber queue:queue];
|
||||
dispatch_release(queue);
|
||||
|
||||
NSString *uniqueID = [videoDevice uniqueID];
|
||||
if (uniqueID!=NULL) {
|
||||
uvcController = [[VVUVCController alloc] initWithDeviceIDString:[videoDevice uniqueID]];
|
||||
if (uvcController) [uvcController resetParamsToDefaults];
|
||||
} // else std::cout << "VVUVCController NULL" << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned char* AVfoundationCamera::getFrame()
|
||||
{
|
||||
unsigned char *cambuffer = [grabber getFrame];
|
||||
if (cambuffer!=NULL) {
|
||||
timeout=100;
|
||||
lost_frames=0;
|
||||
return cambuffer;
|
||||
} else {
|
||||
usleep(10000);
|
||||
lost_frames++;
|
||||
if (lost_frames>timeout) {
|
||||
disconnected=true;
|
||||
running=false;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::startCamera()
|
||||
{
|
||||
[session startRunning];
|
||||
applyCameraSettings();
|
||||
running = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::stopCamera()
|
||||
{
|
||||
[session stopRunning];
|
||||
running=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::stillRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::resetCamera()
|
||||
{
|
||||
return (stopCamera() && startCamera());
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::closeCamera()
|
||||
{
|
||||
if ((uvcController) && (!disconnected)) {
|
||||
updateSettings();
|
||||
// CameraTool::saveSettings();
|
||||
}
|
||||
[session release];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::showSettingsDialog(bool lock) {
|
||||
|
||||
if (uvcController) {
|
||||
[uvcController closeSettingsWindow];
|
||||
[uvcController openSettingsWindow];
|
||||
}
|
||||
|
||||
return lock;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::hasCameraSettingAuto(int mode) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
|
||||
switch (mode) {
|
||||
case EXPOSURE:
|
||||
return [uvcController autoExposureModeSupported];
|
||||
case WHITE:
|
||||
return [uvcController autoWhiteBalanceSupported];
|
||||
case FOCUS:
|
||||
return [uvcController autoFocusSupported];
|
||||
case COLOR_HUE:
|
||||
return [uvcController autoHueSupported];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::getCameraSettingAuto(int mode) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
if (!hasCameraSettingAuto(mode)) return false;
|
||||
|
||||
switch (mode) {
|
||||
case EXPOSURE:
|
||||
if ([uvcController autoExposureMode]>UVC_AEMode_Manual) return true;
|
||||
else return false;
|
||||
case WHITE:
|
||||
return [uvcController autoWhiteBalance];
|
||||
case FOCUS:
|
||||
return [uvcController autoFocus];
|
||||
case COLOR_HUE:
|
||||
return [uvcController autoHue];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::setCameraSettingAuto(int mode, bool flag) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
if (!hasCameraSettingAuto(mode)) return false;
|
||||
|
||||
switch (mode) {
|
||||
case EXPOSURE:
|
||||
if (flag==true) [uvcController setAutoExposureMode:UVC_AEMode_Auto];
|
||||
else [uvcController setAutoExposureMode:UVC_AEMode_Manual];
|
||||
return true;
|
||||
case WHITE:
|
||||
[uvcController setAutoWhiteBalance:flag];
|
||||
return true;
|
||||
case FOCUS:
|
||||
[uvcController setAutoFocus:flag];
|
||||
return true;
|
||||
case COLOR_HUE:
|
||||
[uvcController setAutoHue:flag];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::hasCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: return [uvcController brightSupported];
|
||||
case CONTRAST: return [uvcController contrastSupported];
|
||||
case SHARPNESS: return [uvcController sharpnessSupported];
|
||||
case GAMMA: return [uvcController gammaSupported];
|
||||
case GAIN: return [uvcController gainSupported];
|
||||
case AUTO_GAIN: return hasCameraSettingAuto(GAIN);
|
||||
case EXPOSURE: return [uvcController exposureTimeSupported];
|
||||
case AUTO_EXPOSURE: return hasCameraSettingAuto(EXPOSURE);
|
||||
case FOCUS: return [uvcController focusSupported];
|
||||
case AUTO_FOCUS: return hasCameraSettingAuto(FOCUS);
|
||||
case WHITE: return [uvcController whiteBalanceSupported];
|
||||
case AUTO_WHITE: return hasCameraSettingAuto(WHITE);
|
||||
case BACKLIGHT: return [uvcController backlightSupported];
|
||||
case SATURATION: return [uvcController saturationSupported];
|
||||
case COLOR_HUE: return [uvcController hueSupported];
|
||||
case AUTO_HUE: return hasCameraSettingAuto(COLOR_HUE);
|
||||
case POWERLINE: return [uvcController powerLineSupported];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::setCameraSetting(int mode, int setting) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
if (!hasCameraSetting(mode)) return false;
|
||||
setCameraSettingAuto(mode, false);
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: [uvcController setBright:setting]; return true;
|
||||
case CONTRAST: [uvcController setContrast:setting]; return true;
|
||||
case SHARPNESS: [uvcController setSharpness:setting]; return true;
|
||||
case GAIN: [uvcController setGain:setting]; return true;
|
||||
case GAMMA: [uvcController setGamma:setting]; return true;
|
||||
case EXPOSURE: [uvcController setExposureTime:setting]; return true;
|
||||
case FOCUS: [uvcController setFocus:setting]; return true;
|
||||
case WHITE: [uvcController setWhiteBalance:setting]; return true;
|
||||
case BACKLIGHT: [uvcController setBacklight:setting]; return true;
|
||||
case SATURATION: [uvcController setSaturation:setting]; return true;
|
||||
case COLOR_HUE: [uvcController setHue:setting]; return true;
|
||||
case POWERLINE: [uvcController setPowerLine:setting]; return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return 0;
|
||||
if (!hasCameraSetting(mode)) return 0;
|
||||
//if (getCameraSettingAuto(mode)) return 0;
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: return [uvcController bright];
|
||||
case CONTRAST: return [uvcController contrast];
|
||||
case SHARPNESS: return [uvcController sharpness];
|
||||
case GAIN: return [uvcController gain];
|
||||
case GAMMA: return [uvcController gamma];
|
||||
case EXPOSURE: return [uvcController exposureTime];
|
||||
case FOCUS: return [uvcController focus];
|
||||
case WHITE: return [uvcController whiteBalance];
|
||||
case BACKLIGHT: return [uvcController backlight];
|
||||
case SATURATION: return [uvcController saturation];
|
||||
case COLOR_HUE: return [uvcController hue];
|
||||
case POWERLINE: return [uvcController powerLine];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getMaxCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return 0;
|
||||
if (!hasCameraSetting(mode)) return 0;
|
||||
//if (getCameraSettingAuto(mode)) return 0;
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: return [uvcController maxBright];
|
||||
case CONTRAST: return [uvcController maxContrast];
|
||||
case SHARPNESS: return [uvcController maxSharpness];
|
||||
case GAIN: return [uvcController maxGain];
|
||||
case GAMMA: return [uvcController maxGamma];
|
||||
case EXPOSURE: return [uvcController maxExposureTime];
|
||||
case FOCUS: return [uvcController maxFocus];
|
||||
case WHITE: return [uvcController maxWhiteBalance];
|
||||
case BACKLIGHT: return [uvcController maxBacklight];
|
||||
case SATURATION: return [uvcController maxSaturation];
|
||||
case COLOR_HUE: return [uvcController maxHue];
|
||||
case POWERLINE: return [uvcController maxPowerLine];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getMinCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return 0;
|
||||
if (!hasCameraSetting(mode)) return 0;
|
||||
//if (getCameraSettingAuto(mode)) return 0;
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: return [uvcController minBright];
|
||||
case CONTRAST: return [uvcController minContrast];
|
||||
case GAIN: return [uvcController minGain];
|
||||
case GAMMA: return [uvcController minGamma];
|
||||
case EXPOSURE: return [uvcController minExposureTime];
|
||||
case SHARPNESS: return [uvcController minSharpness];
|
||||
case FOCUS: return [uvcController minFocus];
|
||||
case WHITE: return [uvcController minWhiteBalance];
|
||||
case BACKLIGHT: return [uvcController minBacklight];
|
||||
case SATURATION: return [uvcController minSaturation];
|
||||
case COLOR_HUE: return [uvcController minHue];
|
||||
case POWERLINE: return [uvcController minPowerLine];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AVfoundationCamera::setDefaultCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return false;
|
||||
if (!hasCameraSetting(mode)) return false;
|
||||
setCameraSettingAuto(mode, false);
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS:
|
||||
[uvcController resetBright];
|
||||
default_brightness = [uvcController bright];
|
||||
break;
|
||||
case CONTRAST:
|
||||
[uvcController resetContrast];
|
||||
default_contrast = [uvcController contrast];
|
||||
break;
|
||||
case SHARPNESS:
|
||||
[uvcController resetSharpness];
|
||||
default_sharpness = [uvcController sharpness];
|
||||
break;
|
||||
case GAIN:
|
||||
[uvcController resetGain];
|
||||
default_gain = [uvcController gain];
|
||||
break;
|
||||
case GAMMA:
|
||||
[uvcController resetGamma];
|
||||
default_gamma = [uvcController gamma];
|
||||
break;
|
||||
case EXPOSURE:
|
||||
[uvcController resetExposureTime];
|
||||
default_exposure = [uvcController exposureTime];
|
||||
break;
|
||||
case FOCUS:
|
||||
[uvcController resetFocus];
|
||||
default_focus = [uvcController focus];
|
||||
break;
|
||||
case WHITE:
|
||||
[uvcController resetWhiteBalance];
|
||||
default_white = [uvcController whiteBalance];
|
||||
break;
|
||||
case BACKLIGHT:
|
||||
[uvcController resetBacklight];
|
||||
default_backlight = [uvcController backlight];
|
||||
break;
|
||||
case SATURATION:
|
||||
[uvcController resetSaturation];
|
||||
default_saturation = [uvcController saturation];
|
||||
break;
|
||||
case COLOR_HUE:
|
||||
[uvcController resetHue];
|
||||
default_hue = [uvcController hue];
|
||||
break;
|
||||
case POWERLINE:
|
||||
[uvcController resetPowerLine];
|
||||
default_powerline = [uvcController powerLine];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getDefaultCameraSetting(int mode) {
|
||||
|
||||
if (uvcController==NULL) return 0;
|
||||
if (!hasCameraSetting(mode)) return 0;
|
||||
|
||||
switch (mode) {
|
||||
case BRIGHTNESS: return default_brightness;
|
||||
case CONTRAST: return default_contrast;
|
||||
case GAIN: return default_gain;
|
||||
case GAMMA: return default_gamma;
|
||||
case EXPOSURE: return default_exposure;
|
||||
case SHARPNESS: return default_sharpness;
|
||||
case FOCUS: return default_focus;
|
||||
case WHITE: return default_white;
|
||||
case BACKLIGHT: return default_backlight;
|
||||
case SATURATION: return default_saturation;
|
||||
case COLOR_HUE: return default_hue;
|
||||
case POWERLINE: return default_powerline;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AVfoundationCamera::getCameraSettingStep(int mode) {
|
||||
if (!hasCameraSetting(mode)) return 0;
|
||||
return 1;
|
||||
}
|
||||
697
src/mynteye/uvc/macosx/CameraEngine.cpp
Normal file
697
src/mynteye/uvc/macosx/CameraEngine.cpp
Normal file
@@ -0,0 +1,697 @@
|
||||
// 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 <vector>
|
||||
#include "CameraEngine.h"
|
||||
|
||||
const char* dstr[] = { "default","dc1394","ps3eye","raspi","uvccam","","","","","","file","folder"};
|
||||
|
||||
const char* fstr[] = { "unknown", "mono8", "mono16", "rgb8", "rgb16", "mono16s", "rgb16s", "raw8", "raw16", "rgba", "yuyv", "uyvy", "yuv411", "yuv444", "yuv420p", "yuv410p", "yvyu", "yuv211", "", "", "jpeg", "mjpeg", "mpeg", "mpeg2", "mpeg4", "h263", "h264", "", "", "", "dvpal", "dvntsc" };
|
||||
|
||||
|
||||
void CameraEngine::printInfo() {
|
||||
printf("camera: %s\n",cfg->name);
|
||||
printf("driver: %s\n",dstr[cfg->driver]);
|
||||
printf("codec: %s\n",fstr[cfg->cam_format]);
|
||||
if (cfg->frame_mode<0) {
|
||||
if (cfg->cam_fps==(int)cfg->cam_fps) printf("format: %dx%d, %dfps\n",cfg->frame_width,cfg->frame_height,(int)cfg->cam_fps);
|
||||
else printf("format: %dx%d, %.1ffps\n",cfg->frame_width,cfg->frame_height,cfg->cam_fps);
|
||||
}
|
||||
else printf("format7_%d: %dx%d\n",cfg->frame_mode,cfg->frame_width,cfg->frame_height);
|
||||
}
|
||||
|
||||
void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list) {
|
||||
if ((cam_cfg->cam_width>0) && (cam_cfg->cam_height>0) && (cam_cfg->cam_fps>0)) return;
|
||||
|
||||
int max_width = 0;
|
||||
int max_height = 0;
|
||||
int min_width = INT_MAX;
|
||||
int min_height = INT_MAX;
|
||||
float max_fps = 0;
|
||||
float min_fps = INT_MAX;
|
||||
|
||||
for (unsigned int i=0;i<cfg_list.size();i++) {
|
||||
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
|
||||
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
|
||||
|
||||
if (cfg_list[i].cam_width>max_width) max_width = cfg_list[i].cam_width;
|
||||
if (cfg_list[i].cam_width<min_width) min_width = cfg_list[i].cam_width;
|
||||
|
||||
if (cfg_list[i].cam_height>max_height) max_height = cfg_list[i].cam_height;
|
||||
if (cfg_list[i].cam_width<min_height) min_height = cfg_list[i].cam_height;
|
||||
}
|
||||
|
||||
if ((cam_cfg->cam_width==SETTING_MAX) || (cam_cfg->cam_width>max_width)) cam_cfg->cam_width = max_width;
|
||||
else if ((cam_cfg->cam_width==SETTING_MIN) || (cam_cfg->cam_width<min_width)) cam_cfg->cam_width = min_width;
|
||||
if ((cam_cfg->cam_height==SETTING_MAX) || (cam_cfg->cam_height>max_height)) cam_cfg->cam_height = max_height;
|
||||
else if ((cam_cfg->cam_height==SETTING_MIN) || (cam_cfg->cam_height<min_height)) cam_cfg->cam_height = min_height;
|
||||
|
||||
if (cam_cfg->cam_fps>0) return;
|
||||
|
||||
for (unsigned int i=0;i<cfg_list.size();i++) {
|
||||
if (cfg_list[i].cam_format!=cam_cfg->cam_format) continue; // wrong format
|
||||
if (cfg_list[i].frame_mode!=cam_cfg->frame_mode) continue; // wrong format7
|
||||
if ((cfg_list[i].cam_width!=cam_cfg->cam_width) || (cfg_list[i].cam_height!=cam_cfg->cam_height)) continue; // wrong size
|
||||
|
||||
if (cfg_list[i].cam_fps>max_fps) max_fps = cfg_list[i].cam_fps;
|
||||
if (cfg_list[i].cam_fps<min_fps) min_fps = cfg_list[i].cam_fps;
|
||||
}
|
||||
|
||||
if ((cam_cfg->cam_fps==SETTING_MAX) || (cam_cfg->cam_fps>max_fps)) cam_cfg->cam_fps = max_fps;
|
||||
if ((cam_cfg->cam_fps==SETTING_MIN) || (cam_cfg->cam_fps<min_fps)) cam_cfg->cam_fps = min_fps;
|
||||
}
|
||||
|
||||
bool CameraEngine::showSettingsDialog(bool lock) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CameraEngine::control(unsigned char key) {
|
||||
if(!settingsDialog) return;
|
||||
|
||||
int step = 0;
|
||||
switch(key) {
|
||||
case VALUE_DECREASE:
|
||||
step = getCameraSettingStep(currentCameraSetting);
|
||||
if (step==1) step = (int)((float)ctrl_max/256.0f);
|
||||
if (step<1) step=1;
|
||||
ctrl_val -= step;
|
||||
if (ctrl_val<ctrl_min) ctrl_val=ctrl_min;
|
||||
setCameraSetting(currentCameraSetting,ctrl_val);
|
||||
break;
|
||||
case VALUE_INCREASE:
|
||||
step = getCameraSettingStep(currentCameraSetting);
|
||||
if (step==1) step = (int)((float)ctrl_max/256.0f);
|
||||
if (step<1) step=1;
|
||||
ctrl_val += step;
|
||||
if (ctrl_val>ctrl_max) ctrl_val=ctrl_max;
|
||||
setCameraSetting(currentCameraSetting,ctrl_val);
|
||||
break;
|
||||
case SETTING_PREVIOUS:
|
||||
currentCameraSetting--;
|
||||
if(currentCameraSetting<0) {
|
||||
if (cfg->color) currentCameraSetting=COLOR_BLUE;
|
||||
else currentCameraSetting=BACKLIGHT;
|
||||
}
|
||||
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
|
||||
control(SETTING_PREVIOUS);
|
||||
break;
|
||||
case SETTING_NEXT:
|
||||
currentCameraSetting++;
|
||||
if ((cfg->color) && (currentCameraSetting>COLOR_BLUE)) currentCameraSetting=0;
|
||||
else if ((!cfg->color) && (currentCameraSetting>BACKLIGHT)) currentCameraSetting=0;
|
||||
if ((!hasCameraSetting(currentCameraSetting)) || (getCameraSettingAuto(currentCameraSetting)))
|
||||
control(SETTING_NEXT);
|
||||
break;
|
||||
case KEY_D:
|
||||
resetCameraSettings();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
ctrl_val = getCameraSetting(currentCameraSetting);
|
||||
ctrl_max = getMaxCameraSetting(currentCameraSetting);
|
||||
ctrl_min = getMinCameraSetting(currentCameraSetting);
|
||||
}
|
||||
|
||||
void CameraEngine::uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
for (int i=height*width/2;i>0;i--) {
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_uyvy2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 2*x_off;
|
||||
for (int j=frm_w/2;j>0;j--) {
|
||||
cam_buf++;
|
||||
*frm_buf++ = *cam_buf++;
|
||||
cam_buf++;
|
||||
*frm_buf++ = *cam_buf++;
|
||||
}
|
||||
cam_buf += 2*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
for (int i=height*width/2;i>0;i--) {
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_yuyv2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 2*x_off;
|
||||
for (int j=frm_w/2;j>0;j--) {
|
||||
*frm_buf++ = *cam_buf++;
|
||||
cam_buf++;
|
||||
*frm_buf++ = *cam_buf++;
|
||||
cam_buf++;
|
||||
}
|
||||
cam_buf += 2*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
//void yuv2rgb_conv(int Y1, int Y2, int U, int V, unsigned char *dest) {
|
||||
void yuv2rgb_conv(int Y, int U, int V, unsigned char *dest) {
|
||||
|
||||
/*int R = (int)(Y + 1.370705f * V);
|
||||
int G = (int)(Y - 0.698001f * V - 0.337633f * U);
|
||||
int B = (int)(Y + 1.732446f * U);*/
|
||||
|
||||
// integer method is twice as fast
|
||||
int C = 298*(Y - 16);
|
||||
int R = (C + 409*V + 128) >> 8;
|
||||
int G = (C - 100*U - 208*V + 128) >> 8;
|
||||
int B = (C + 516*U + 128) >> 8;
|
||||
|
||||
SAT(R);
|
||||
SAT(G);
|
||||
SAT(B);
|
||||
|
||||
*dest++ = R;
|
||||
*dest++ = G;
|
||||
*dest++ = B;
|
||||
}
|
||||
|
||||
void CameraEngine::uyvy2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
int Y1,Y2,U,V;
|
||||
|
||||
for(int i=width*height/2;i>0;i--) {
|
||||
// U and V are +-0.5
|
||||
U = *src++ - 128;
|
||||
Y1 = *src++;
|
||||
V = *src++ - 128;
|
||||
Y2 = *src++;
|
||||
|
||||
yuv2rgb_conv(Y1,U,V,dest);
|
||||
yuv2rgb_conv(Y2,U,V,dest+=3);
|
||||
dest+=3;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_uyvy2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
int Y1,Y2,U,V;
|
||||
|
||||
cam_buf += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 2*x_off;
|
||||
for (int j=frm_w/2;j>0;j--) {
|
||||
// U and V are +-0.5
|
||||
U = *cam_buf++ - 128;
|
||||
Y1 = *cam_buf++;
|
||||
V = *cam_buf++ - 128;
|
||||
Y2 = *cam_buf++;
|
||||
|
||||
yuv2rgb_conv(Y1,U,V,frm_buf);
|
||||
yuv2rgb_conv(Y2,U,V,frm_buf+=3);
|
||||
frm_buf+=3;
|
||||
}
|
||||
cam_buf += 2*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
int Y1,Y2,U,V;
|
||||
|
||||
for(int i=width*height/2;i>0;i--) {
|
||||
|
||||
Y1 = *src++;
|
||||
U = *src++ - 128;
|
||||
Y2 = *src++;
|
||||
V = *src++ - 128;
|
||||
|
||||
yuv2rgb_conv(Y1,U,V,dest);
|
||||
yuv2rgb_conv(Y2,U,V,dest+=3);
|
||||
dest+=3;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_yuyv2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
int Y1,Y2,U,V;
|
||||
|
||||
cam_buf += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 2*x_off;
|
||||
for (int j=frm_w/2;j>0;j--) {
|
||||
// U and V are +-0.5
|
||||
Y1 = *cam_buf++;
|
||||
U = *cam_buf++ - 128;
|
||||
Y2 = *cam_buf++;
|
||||
V = *cam_buf++ - 128;
|
||||
|
||||
yuv2rgb_conv(Y1,U,V,frm_buf);
|
||||
yuv2rgb_conv(Y2,U,V,frm_buf+=3);
|
||||
frm_buf+=3;
|
||||
}
|
||||
cam_buf += 2*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::gray2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
int size = width*height;
|
||||
for (int i=size;i>0;i--) {
|
||||
unsigned char pixel = *src++;
|
||||
*dest++ = pixel;
|
||||
*dest++ = pixel;
|
||||
*dest++ = pixel;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_gray2rgb(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += x_off;
|
||||
for (int j=frm_w;j>0;j--) {
|
||||
unsigned char pixel = *cam_buf++;
|
||||
*frm_buf++ = pixel;
|
||||
*frm_buf++ = pixel;
|
||||
*frm_buf++ = pixel;
|
||||
}
|
||||
cam_buf += x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
unsigned short src_pixel;
|
||||
unsigned char dest_pixel;
|
||||
unsigned char pixel;
|
||||
|
||||
for(int i=width*height;i>0;i--) {
|
||||
pixel = *src++ ;
|
||||
src_pixel = pixel | (*src++ << 8);
|
||||
dest_pixel = (unsigned char)(src_pixel/4);
|
||||
*dest++ = dest_pixel;
|
||||
*dest++ = dest_pixel;
|
||||
*dest++ = dest_pixel;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_grayw2rgb(int cam_w, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
unsigned short src_pixel;
|
||||
unsigned char dest_pixel;
|
||||
unsigned char pixel;
|
||||
|
||||
src += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
src += 2*x_off;
|
||||
for (int j=frm_w;j>0;j--) {
|
||||
pixel = *src++;
|
||||
src_pixel = pixel | (*src++ << 8);
|
||||
dest_pixel = (unsigned char)(src_pixel/4);
|
||||
|
||||
*dest++ = dest_pixel;
|
||||
*dest++ = dest_pixel;
|
||||
*dest++ = dest_pixel;
|
||||
}
|
||||
src += 2*x_end;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CameraEngine::grayw2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
unsigned short value;
|
||||
unsigned char pixel;
|
||||
|
||||
for(int i=width*height;i>0;i--) {
|
||||
pixel = *src++;
|
||||
value = pixel | (*src++ << 8);
|
||||
*dest++ = (unsigned char)(value/4);
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop_grayw2gray(int cam_w, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
unsigned short src_pixel;
|
||||
unsigned char pixel;
|
||||
|
||||
src += 2*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
src += 2*x_off;
|
||||
for (int j=frm_w;j>0;j--) {
|
||||
pixel = *src++;
|
||||
src_pixel = pixel | (*src++ << 8);
|
||||
*dest++ = (unsigned char)(src_pixel/4);
|
||||
}
|
||||
src += 2*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += b*(y_off*cam_w + x_off);
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
memcpy(frm_buf, cam_buf, b*cam_w);
|
||||
|
||||
cam_buf += b*cam_w;
|
||||
frm_buf += b*frm_w;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::flip(int width, int height, unsigned char *src, unsigned char *dest, int b) {
|
||||
|
||||
int size = b*width*height;
|
||||
dest += size-1;
|
||||
for(int i=size;i>0;i--) {
|
||||
*dest-- = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::flip_crop(int cam_w, int cam_h, unsigned char *cam_buf, unsigned char *frm_buf, int b) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += b*y_off*cam_w;
|
||||
frm_buf += b*frm_w*frm_h-1;
|
||||
int xend = (cam_w-(frm_w+x_off));
|
||||
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += b*x_off;
|
||||
for (int j=b*frm_w;j>0;j--) {
|
||||
*frm_buf-- = *cam_buf++;
|
||||
}
|
||||
cam_buf += b*xend;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
int R,G,B;
|
||||
for (int i=width*height;i>0;i--) {
|
||||
|
||||
R = *src++;
|
||||
G = *src++;
|
||||
B = *src++;
|
||||
*dest++ = HBT(R*77 + G*151 + B*28);
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest) {
|
||||
|
||||
int size = width*height;
|
||||
dest += size-1;
|
||||
|
||||
int R,G,B;
|
||||
for (int i=size;i>0;i--) {
|
||||
|
||||
R = *src++;
|
||||
G = *src++;
|
||||
B = *src++;
|
||||
*dest-- = HBT(R*77 + G*151 + B*28);
|
||||
}
|
||||
}
|
||||
void CameraEngine::crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += 3*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
|
||||
int R,G,B;
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 3*x_off;
|
||||
for (int j=frm_w;j>0;j--) {
|
||||
R = *cam_buf++;
|
||||
G = *cam_buf++;
|
||||
B = *cam_buf++;
|
||||
*frm_buf++ = HBT(R*77 + G*151 + B*28);
|
||||
}
|
||||
cam_buf += 3*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::flip_crop_rgb2gray(int cam_w, unsigned char *cam_buf, unsigned char *frm_buf) {
|
||||
|
||||
if(!cfg->frame) return;
|
||||
int x_off = cfg->frame_xoff;
|
||||
int y_off = cfg->frame_yoff;
|
||||
int frm_w = cfg->frame_width;
|
||||
int frm_h = cfg->frame_height;
|
||||
|
||||
cam_buf += 3*y_off*cam_w;
|
||||
int x_end = cam_w-(frm_w+x_off);
|
||||
frm_buf += frm_w*frm_h-1;
|
||||
|
||||
int R,G,B;
|
||||
for (int i=frm_h;i>0;i--) {
|
||||
|
||||
cam_buf += 3*x_off;
|
||||
for (int j=frm_w;j>0;j--) {
|
||||
R = *cam_buf++;
|
||||
G = *cam_buf++;
|
||||
B = *cam_buf++;
|
||||
*frm_buf-- = HBT(R*77 + G*151 + B*28);
|
||||
}
|
||||
cam_buf += 3*x_end;
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::setupFrame() {
|
||||
|
||||
if(!cfg->frame) {
|
||||
cfg->frame_width = cfg->cam_width;
|
||||
cfg->frame_height = cfg->cam_height;
|
||||
return;
|
||||
}
|
||||
|
||||
// size sanity check
|
||||
if (cfg->frame_width%2!=0) cfg->frame_width--;
|
||||
if (cfg->frame_height%2!=0) cfg->frame_height--;
|
||||
|
||||
if (cfg->frame_width<=0) cfg->frame_width = cfg->cam_width;
|
||||
if (cfg->frame_height<=0) cfg->frame_height = cfg->cam_height;
|
||||
|
||||
if (cfg->frame_width > cfg->cam_width) cfg->frame_width = cfg->cam_width;
|
||||
if (cfg->frame_height > cfg->cam_height) cfg->frame_height = cfg->cam_height;
|
||||
|
||||
// no cropping if same size
|
||||
if ((cfg->frame_width==cfg->cam_width) && (cfg->frame_height==cfg->cam_height)) {
|
||||
|
||||
cfg->frame_width = cfg->cam_width;
|
||||
cfg->frame_height = cfg->cam_height;
|
||||
cfg->frame = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// offset sanity check
|
||||
int xdiff = cfg->cam_width-cfg->frame_width;
|
||||
if (xdiff<0) cfg->frame_xoff = 0;
|
||||
else if (cfg->frame_xoff > xdiff) cfg->frame_xoff = xdiff;
|
||||
int ydiff = cfg->cam_height-cfg->frame_height;
|
||||
if (ydiff<0) cfg->frame_yoff = 0;
|
||||
else if (cfg->frame_yoff > ydiff) cfg->frame_yoff = ydiff;
|
||||
|
||||
}
|
||||
|
||||
void CameraEngine::applyCameraSetting(int mode, int value) {
|
||||
|
||||
if (!hasCameraSetting(mode)) return;
|
||||
|
||||
switch (value) {
|
||||
case SETTING_AUTO:
|
||||
if (hasCameraSettingAuto(mode)) {
|
||||
setCameraSettingAuto(mode,true);
|
||||
return;
|
||||
}
|
||||
case SETTING_OFF:
|
||||
case SETTING_DEFAULT:
|
||||
setDefaultCameraSetting(mode);
|
||||
return;
|
||||
case SETTING_MIN:
|
||||
setCameraSettingAuto(mode,false);
|
||||
setCameraSetting(mode,getMinCameraSetting(mode)); return;
|
||||
case SETTING_MAX:
|
||||
setCameraSettingAuto(mode,false);
|
||||
setCameraSetting(mode,getMaxCameraSetting(mode)); return;
|
||||
default: {
|
||||
int max = getMaxCameraSetting(mode);
|
||||
int min = getMinCameraSetting(mode);
|
||||
if (value<min) value = min;
|
||||
else if (value>max) value = max;
|
||||
setCameraSettingAuto(mode,false);
|
||||
setCameraSetting(mode,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CameraEngine::resetCameraSettings() {
|
||||
|
||||
for (int mode=MODE_MIN;mode<=MODE_MAX;mode++)
|
||||
setDefaultCameraSetting(mode);
|
||||
}
|
||||
|
||||
void CameraEngine::applyCameraSettings() {
|
||||
|
||||
resetCameraSettings();
|
||||
|
||||
applyCameraSetting(BRIGHTNESS,cfg->brightness);
|
||||
applyCameraSetting(CONTRAST,cfg->contrast);
|
||||
applyCameraSetting(SHARPNESS,cfg->sharpness);
|
||||
applyCameraSetting(GAIN,cfg->gain);
|
||||
applyCameraSetting(EXPOSURE,cfg->exposure);
|
||||
applyCameraSetting(SHUTTER,cfg->shutter);
|
||||
applyCameraSetting(FOCUS,cfg->focus);
|
||||
applyCameraSetting(WHITE,cfg->white);
|
||||
applyCameraSetting(POWERLINE,cfg->powerline);
|
||||
applyCameraSetting(BACKLIGHT,cfg->backlight);
|
||||
applyCameraSetting(GAMMA,cfg->gamma);
|
||||
|
||||
applyCameraSetting(SATURATION,cfg->saturation);
|
||||
applyCameraSetting(COLOR_HUE,cfg->hue);
|
||||
applyCameraSetting(COLOR_RED,cfg->red);
|
||||
applyCameraSetting(COLOR_GREEN,cfg->green);
|
||||
applyCameraSetting(COLOR_BLUE,cfg->blue);
|
||||
}
|
||||
|
||||
int CameraEngine::updateSetting(int mode) {
|
||||
|
||||
if (!hasCameraSetting(mode)) return SETTING_OFF;
|
||||
if (getCameraSettingAuto(mode)) return SETTING_AUTO;
|
||||
|
||||
int value = getCameraSetting(mode);
|
||||
if (value==getDefaultCameraSetting(mode)) value = SETTING_DEFAULT;
|
||||
else if (value==getMinCameraSetting(mode)) value = SETTING_MIN;
|
||||
else if (value==getMaxCameraSetting(mode)) value = SETTING_MAX;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void CameraEngine::updateSettings() {
|
||||
|
||||
cfg->brightness = updateSetting(BRIGHTNESS);
|
||||
cfg->contrast = updateSetting(CONTRAST);
|
||||
cfg->sharpness = updateSetting(SHARPNESS);
|
||||
|
||||
cfg->gain = updateSetting(GAIN);
|
||||
cfg->exposure = updateSetting(EXPOSURE);
|
||||
cfg->shutter = updateSetting(SHUTTER);
|
||||
cfg->focus = updateSetting(FOCUS);
|
||||
cfg->white = updateSetting(WHITE);
|
||||
cfg->backlight = updateSetting(BACKLIGHT);
|
||||
cfg->powerline = updateSetting(POWERLINE);
|
||||
cfg->gamma = updateSetting(GAMMA);
|
||||
|
||||
if (cfg->color) {
|
||||
cfg->saturation = updateSetting(SATURATION);
|
||||
cfg->hue = updateSetting(COLOR_HUE);
|
||||
cfg->red = updateSetting(COLOR_RED);
|
||||
cfg->green = updateSetting(COLOR_GREEN);
|
||||
cfg->blue = updateSetting(COLOR_BLUE);
|
||||
} else {
|
||||
cfg->saturation = SETTING_OFF;
|
||||
cfg->hue = SETTING_OFF;
|
||||
cfg->red = SETTING_OFF;
|
||||
cfg->green = SETTING_OFF;
|
||||
cfg->blue = SETTING_OFF;
|
||||
}
|
||||
|
||||
}
|
||||
306
src/mynteye/uvc/macosx/CameraEngine.h
Normal file
306
src/mynteye/uvc/macosx/CameraEngine.h
Normal file
@@ -0,0 +1,306 @@
|
||||
// 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 CAMERAENGINE_H
|
||||
#define CAMERAENGINE_H
|
||||
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
|
||||
#define SAT(c) \
|
||||
if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
|
||||
#define HBT(x) (unsigned char)((x)>>8)
|
||||
|
||||
#define KEY_A 4
|
||||
#define KEY_B 5
|
||||
#define KEY_C 6
|
||||
#define KEY_D 7
|
||||
#define KEY_E 8
|
||||
#define KEY_F 9
|
||||
#define KEY_G 10
|
||||
#define KEY_H 11
|
||||
#define KEY_I 12
|
||||
#define KEY_J 13
|
||||
#define KEY_K 14
|
||||
#define KEY_L 15
|
||||
#define KEY_M 16
|
||||
#define KEY_N 17
|
||||
#define KEY_O 18
|
||||
#define KEY_P 19
|
||||
#define KEY_Q 20
|
||||
#define KEY_R 21
|
||||
#define KEY_S 22
|
||||
#define KEY_T 23
|
||||
#define KEY_U 24
|
||||
#define KEY_V 25
|
||||
#define KEY_W 26
|
||||
#define KEY_X 27
|
||||
#define KEY_Y 29
|
||||
#define KEY_Z 28
|
||||
|
||||
#define KEY_SPACE 44
|
||||
#define KEY_RIGHT 79
|
||||
#define KEY_LEFT 80
|
||||
#define KEY_DOWN 81
|
||||
#define KEY_UP 82
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
|
||||
#define SETTING_DEFAULT -100000
|
||||
#define SETTING_AUTO -200000
|
||||
#define SETTING_MIN -300000
|
||||
#define SETTING_MAX -400000
|
||||
#define SETTING_OFF -500000
|
||||
|
||||
#define FORMAT_UNSUPPORTED -1
|
||||
#define FORMAT_UNKNOWN 0
|
||||
#define FORMAT_GRAY 1
|
||||
#define FORMAT_GRAY16 2
|
||||
#define FORMAT_RGB 3
|
||||
#define FORMAT_RGB16 4
|
||||
#define FORMAT_GRAY16S 5
|
||||
#define FORMAT_RGB16S 6
|
||||
#define FORMAT_RAW8 7
|
||||
#define FORMAT_RAW16 8
|
||||
#define FORMAT_RGBA 9
|
||||
#define FORMAT_YUYV 10
|
||||
#define FORMAT_UYVY 11
|
||||
#define FORMAT_YUV411 12
|
||||
#define FORMAT_YUV444 13
|
||||
#define FORMAT_420P 14
|
||||
#define FORMAT_410P 15
|
||||
#define FORMAT_YVYU 16
|
||||
#define FORMAT_YUV211 17
|
||||
#define FORMAT_JPEG 20
|
||||
#define FORMAT_MJPEG 21
|
||||
#define FORMAT_MPEG 22
|
||||
#define FORMAT_MPEG2 23
|
||||
#define FORMAT_MPEG4 24
|
||||
#define FORMAT_H263 25
|
||||
#define FORMAT_H264 26
|
||||
#define FORMAT_DVPAL 30
|
||||
#define FORMAT_DVNTSC 31
|
||||
#define FORMAT_MAX 31
|
||||
|
||||
extern const char* fstr[];
|
||||
extern const char* dstr[];
|
||||
|
||||
#define DRIVER_DEFAULT 0
|
||||
#define DRIVER_DC1394 1
|
||||
#define DRIVER_PS3EYE 2
|
||||
#define DRIVER_RASPI 3
|
||||
#define DRIVER_UVCCAM 4
|
||||
#define DRIVER_FILE 10
|
||||
#define DRIVER_FOLDER 11
|
||||
|
||||
#define VALUE_INCREASE 79
|
||||
#define VALUE_DECREASE 80
|
||||
#define SETTING_NEXT 81
|
||||
#define SETTING_PREVIOUS 82
|
||||
|
||||
enum CameraSetting { BRIGHTNESS, CONTRAST, SHARPNESS, AUTO_GAIN, GAIN, AUTO_EXPOSURE, EXPOSURE, SHUTTER, AUTO_FOCUS, FOCUS, AUTO_WHITE, WHITE, GAMMA, POWERLINE, BACKLIGHT, SATURATION, AUTO_HUE, COLOR_HUE, COLOR_RED, COLOR_GREEN, COLOR_BLUE };
|
||||
#define MODE_MIN BRIGHTNESS
|
||||
#define MODE_MAX COLOR_BLUE
|
||||
|
||||
struct CameraConfig {
|
||||
|
||||
char path[256];
|
||||
|
||||
int driver;
|
||||
int device;
|
||||
|
||||
char name[256];
|
||||
char src[256];
|
||||
|
||||
bool color;
|
||||
bool frame;
|
||||
|
||||
int cam_format;
|
||||
int src_format;
|
||||
int buf_format;
|
||||
|
||||
int cam_width;
|
||||
int cam_height;
|
||||
float cam_fps;
|
||||
|
||||
int frame_width;
|
||||
int frame_height;
|
||||
int frame_xoff;
|
||||
int frame_yoff;
|
||||
int frame_mode;
|
||||
|
||||
int brightness;
|
||||
int contrast;
|
||||
int sharpness;
|
||||
|
||||
int gain;
|
||||
int shutter;
|
||||
int exposure;
|
||||
int focus;
|
||||
int gamma;
|
||||
int white;
|
||||
int powerline;
|
||||
int backlight;
|
||||
|
||||
int saturation;
|
||||
int hue;
|
||||
int red;
|
||||
int blue;
|
||||
int green;
|
||||
|
||||
bool force;
|
||||
|
||||
bool operator < (const CameraConfig& c) const {
|
||||
|
||||
//if (device < c.device) return true;
|
||||
//if (cam_format < c.cam_format) return true;
|
||||
|
||||
if (cam_width > c.cam_width || (cam_width == c.cam_width && cam_height < c.cam_height))
|
||||
return true;
|
||||
|
||||
if (cam_width == c.cam_width && cam_height == c.cam_height) {
|
||||
return (cam_fps > c.cam_fps);
|
||||
} else return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class CameraEngine
|
||||
{
|
||||
public:
|
||||
|
||||
CameraEngine(CameraConfig *cam_cfg) {
|
||||
cfg = cam_cfg;
|
||||
settingsDialog=false;
|
||||
|
||||
if (cfg->color) cfg->buf_format=FORMAT_RGB;
|
||||
else cfg->buf_format=FORMAT_GRAY;
|
||||
}
|
||||
|
||||
virtual ~CameraEngine() {};
|
||||
|
||||
virtual bool initCamera() = 0;
|
||||
virtual bool startCamera() = 0;
|
||||
virtual unsigned char* getFrame() = 0;
|
||||
virtual bool stopCamera() = 0;
|
||||
virtual bool resetCamera() = 0;
|
||||
virtual bool closeCamera() = 0;
|
||||
virtual bool stillRunning() = 0;
|
||||
|
||||
void printInfo();
|
||||
static void setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list);
|
||||
|
||||
virtual int getCameraSettingStep(int mode) = 0;
|
||||
virtual int getMinCameraSetting(int mode) = 0;
|
||||
virtual int getMaxCameraSetting(int mode) = 0;
|
||||
virtual int getCameraSetting(int mode) = 0;
|
||||
virtual bool setCameraSetting(int mode, int value) = 0;
|
||||
virtual bool setCameraSettingAuto(int mode, bool flag) = 0;
|
||||
virtual bool getCameraSettingAuto(int mode) = 0;
|
||||
virtual bool setDefaultCameraSetting(int mode) = 0;
|
||||
virtual int getDefaultCameraSetting(int mode) = 0;
|
||||
virtual bool hasCameraSetting(int mode) = 0;
|
||||
virtual bool hasCameraSettingAuto(int mode) = 0;
|
||||
|
||||
virtual bool showSettingsDialog(bool lock);
|
||||
virtual void control(unsigned char key);
|
||||
|
||||
int getId() { return cfg->device; }
|
||||
int getFps() { return (int)floor(cfg->cam_fps+0.5f); }
|
||||
int getWidth() { return cfg->frame_width; }
|
||||
int getHeight() { return cfg->frame_height; }
|
||||
int getFormat() { return cfg->buf_format; }
|
||||
char* getName() { return cfg->name; }
|
||||
|
||||
protected:
|
||||
|
||||
CameraConfig *cfg;
|
||||
|
||||
unsigned char* frm_buffer;
|
||||
unsigned char* cam_buffer;
|
||||
|
||||
int lost_frames, timeout;
|
||||
|
||||
bool running;
|
||||
bool settingsDialog;
|
||||
int currentCameraSetting;
|
||||
|
||||
void crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
||||
void flip(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
||||
void flip_crop(int width, int height, unsigned char *src, unsigned char *dest, int bytes);
|
||||
|
||||
void rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
void flip_rgb2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void flip_crop_rgb2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
|
||||
void uyvy2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_uyvy2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
void yuyv2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_yuyv2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
void yuv2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_yuv2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
|
||||
void gray2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_gray2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||
void uyvy2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_uyvy2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||
void yuyv2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_yuyv2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||
|
||||
void grayw2rgb(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_grayw2rgb(int width, unsigned char *src, unsigned char *dest);
|
||||
void grayw2gray(int width, int height, unsigned char *src, unsigned char *dest);
|
||||
void crop_grayw2gray(int width, unsigned char *src, unsigned char *dest);
|
||||
|
||||
void resetCameraSettings();
|
||||
void applyCameraSettings();
|
||||
void applyCameraSetting(int mode, int value);
|
||||
void updateSettings();
|
||||
int updateSetting(int mode);
|
||||
|
||||
void setupFrame();
|
||||
|
||||
int default_brightness;
|
||||
int default_contrast;
|
||||
int default_sharpness;
|
||||
|
||||
int default_gain;
|
||||
int default_shutter;
|
||||
int default_exposure;
|
||||
int default_focus;
|
||||
int default_gamma;
|
||||
int default_powerline;
|
||||
int default_white;
|
||||
int default_backlight;
|
||||
|
||||
int default_saturation;
|
||||
int default_hue;
|
||||
int default_red;
|
||||
int default_blue;
|
||||
int default_green;
|
||||
|
||||
int ctrl_min;
|
||||
int ctrl_max;
|
||||
int ctrl_val;
|
||||
};
|
||||
#endif
|
||||
1
src/mynteye/uvc/macosx/USBBusProber.framework/Headers
Symbolic link
1
src/mynteye/uvc/macosx/USBBusProber.framework/Headers
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
1
src/mynteye/uvc/macosx/USBBusProber.framework/Resources
Symbolic link
1
src/mynteye/uvc/macosx/USBBusProber.framework/Resources
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
1
src/mynteye/uvc/macosx/USBBusProber.framework/USBBusProber
Symbolic link
1
src/mynteye/uvc/macosx/USBBusProber.framework/USBBusProber
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/USBBusProber
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface BusProbeClass : NSObject {
|
||||
UInt8 _classNum;
|
||||
UInt8 _subclassNum;
|
||||
UInt8 _protocolNum;
|
||||
NSString * _className;
|
||||
NSString * _subclassName;
|
||||
NSString * _protocolName;
|
||||
}
|
||||
|
||||
+ (BusProbeClass *)withClass:(UInt8)classNum subclass:(UInt8)subclassNum protocol:(UInt8)protocolNum;
|
||||
- (UInt8)classNum;
|
||||
- (void)setClassNum:(UInt8)classNum;
|
||||
- (UInt8)subclassNum;
|
||||
- (void)setSubclassNum:(UInt8)subclassNum;
|
||||
- (UInt8)protocolNum;
|
||||
- (void)setProtocolNum:(UInt8)protocolNum;
|
||||
- (NSString *)className;
|
||||
- (void)setClassName:(NSString *)deviceClass;
|
||||
- (NSString *)subclassName;
|
||||
- (void)setSubclassName:(NSString *)deviceSubclass;
|
||||
- (NSString *)protocolName;
|
||||
- (void)setProtocolName:(NSString *)deviceProtocol;
|
||||
- (NSString *)classDescription;
|
||||
- (NSString *)subclassDescription;
|
||||
- (NSString *)protocolDescription;
|
||||
|
||||
-(NSMutableDictionary *)dictionaryVersionOfMe;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOKit/usb/USB.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "OutlineViewNode.h"
|
||||
#import "BusProbeClass.h"
|
||||
|
||||
@interface BusProbeDevice : NSObject {
|
||||
OutlineViewNode * _rootNode;
|
||||
UInt8 _speed;
|
||||
USBDeviceAddress _address;
|
||||
UInt32 _locationID;
|
||||
UInt32 _vendorID;
|
||||
UInt32 _productID;
|
||||
UInt16 _usbRelease;
|
||||
BusProbeClass * _deviceClassInfo;
|
||||
BusProbeClass * _lastInterfaceClassInfo;
|
||||
UInt8 _lastInterfaceSubclass;
|
||||
int _currentInterfaceNumber;
|
||||
uint32_t _portInfo;
|
||||
}
|
||||
|
||||
- (OutlineViewNode *)rootNode;
|
||||
- (void)addProperty:(char *)property withValue:(char *)value atDepth:(int)depth;
|
||||
- (void)addNumberProperty:(char *)property value:(UInt32)value size:(int)sizeInBytes atDepth:(int)depth usingStyle:(int)style;
|
||||
- (void)addStringProperty:(char *)property fromStringIndex:(UInt8)strIndex fromDeviceInterface:(IOUSBDeviceRef)deviceIntf atDepth:(int)depth;
|
||||
|
||||
- (NSString *)deviceName;
|
||||
- (void)setDeviceName:(NSString *)name;
|
||||
- (NSString *)deviceDescription;
|
||||
- (void)setDeviceDescription:(NSString *)description;
|
||||
- (UInt8)speed;
|
||||
- (void)setSpeed:(UInt8)speed;
|
||||
- (USBDeviceAddress)address;
|
||||
- (void)setAddress:(USBDeviceAddress)address;
|
||||
- (uint32_t)portInfo;
|
||||
- (void)setPortInfo:(uint32_t)portInfo;
|
||||
//- (UInt32)locationID;
|
||||
//- (void)setLocationID:(UInt32)locationID;
|
||||
- (UInt32)vendorID;
|
||||
- (void)setVendorID:(UInt32)vendorID;
|
||||
- (UInt32)productID;
|
||||
- (void)setProductID:(UInt32)productID;
|
||||
- (UInt32)locationID;
|
||||
- (void)setLocationID:(UInt32)locationID;
|
||||
- (BusProbeClass *)deviceClassInfo;
|
||||
- (void)setDeviceClassInfo:(BusProbeClass *)classInfo;
|
||||
- (BusProbeClass *)lastInterfaceClassInfo;
|
||||
- (void)setLastInterfaceClassInfo:(BusProbeClass *)classInfo;
|
||||
- (int)currentInterfaceNumber;
|
||||
- (void)setCurrentInterfaceNumber:(int)currentNum;
|
||||
- (UInt16)usbRelease;
|
||||
- (void)setUSBRelease:(UInt16)usbRelease;
|
||||
|
||||
- (NSString *)descriptionForName:(NSString*)name;
|
||||
- (NSString *)description;
|
||||
- (NSMutableDictionary *)dictionaryVersionOfMe;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOKit/usb/IOUSBLib.h>
|
||||
#import <IOKit/usb/USB.h>
|
||||
#import <IOKit/usb/USBSpec.h>
|
||||
#import <IOKit/IOCFPlugIn.h>
|
||||
#import <mach/mach_port.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "OutlineViewNode.h"
|
||||
#import "BusProbeDevice.h"
|
||||
#import "BusProbeClass.h"
|
||||
|
||||
#import "DescriptorDecoder.h"
|
||||
|
||||
@interface BusProber : NSObject {
|
||||
id _listener;
|
||||
|
||||
NSMutableArray * _devicesArray;
|
||||
CFRunLoopSourceRef _runLoopSource;
|
||||
}
|
||||
|
||||
- (BOOL)registerForUSBNotifications;
|
||||
- (void)unregisterForUSBNotifications;
|
||||
|
||||
- (void)refreshData:(BOOL)shouldForce;
|
||||
|
||||
- (void)processDevice:(IOUSBDeviceRef)deviceIntf deviceNumber:(int)deviceNumber usbName:(NSString*)usbName;
|
||||
- (void)PrintPortInfo: (uint32_t)portInfo forDevice:(BusProbeDevice *)thisDevice;
|
||||
- (void)GetAndPrintNumberOfEndpoints:(IOUSBDeviceRef)deviceIntf forDevice:(BusProbeDevice *)thisDevice portInfo:(UInt32)portInfo;
|
||||
|
||||
- (NSMutableArray *) devicesArray;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@protocol BusProberListener <NSObject>
|
||||
|
||||
- (void)busProberInformationDidChange:(BusProber *)aProber;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOKit/usb/IOUSBLib.h>
|
||||
#import <IOKit/usb/USB.h>
|
||||
#import <IOKit/usb/USBSpec.h>
|
||||
#import <IOKit/IOCFPlugIn.h>
|
||||
#import "BusProbeClass.h"
|
||||
|
||||
typedef struct IOUSBDeviceStruct320** IOUSBDeviceRef ;
|
||||
typedef struct IOUSBInterfaceStruct220** IOUSBInterfaceRef ;
|
||||
|
||||
#define ROOT_LEVEL 0
|
||||
#define DEVICE_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
|
||||
#define CONFIGURATION_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
|
||||
#define INTERFACE_LEVEL CONFIGURATION_DESCRIPTOR_LEVEL + 1
|
||||
#define ENDPOINT_LEVEL INTERFACE_LEVEL + 1
|
||||
#define HID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
|
||||
#define DFU_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
|
||||
#define CCID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
|
||||
#define HUB_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
|
||||
#define DEVICE_QUAL_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
|
||||
#define BOS_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
|
||||
|
||||
enum {
|
||||
kIntegerOutputStyle = 0,
|
||||
kHexOutputStyle = 1
|
||||
};
|
||||
|
||||
IOReturn GetNumberOfConfigurations( IOUSBDeviceRef deviceIntf, uint8_t * numberOfConfigs );
|
||||
IOReturn GetConfigurationDescriptor( IOUSBDeviceRef deviceIntf, uint8_t config, IOUSBConfigurationDescriptorPtr * description );
|
||||
IOReturn GetConfiguration( IOUSBDeviceRef deviceIntf, uint8_t * currentConfig );
|
||||
IOReturn GetPortInformation( IOUSBDeviceRef deviceIntf, uint32_t * portInfo );
|
||||
int GetDeviceLocationID( IOUSBDeviceRef deviceIntf, UInt32 * locationID );
|
||||
int GetDeviceSpeed( IOUSBDeviceRef deviceIntf, UInt8 * speed );
|
||||
int GetDeviceAddress( IOUSBDeviceRef deviceIntf, USBDeviceAddress * address );
|
||||
int SuspendDevice( IOUSBDeviceRef deviceIntf, BOOL suspend );
|
||||
IOReturn GetDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len, IOReturn *actError);
|
||||
int GetStringDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descIndex, void *buf, UInt16 len, UInt16 lang);
|
||||
int GetClassDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len);
|
||||
int GetDescriptorFromInterface(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, UInt16 wIndex, void *buf, UInt16 len, Boolean inCurrentConfig);
|
||||
int GetCurrentConfiguration(IOUSBDeviceRef deviceIntf);
|
||||
|
||||
BusProbeClass * GetDeviceClassAndSubClass(UInt8 * pcls);
|
||||
BusProbeClass * GetInterfaceClassAndSubClass(UInt8 * pcls);
|
||||
char * GetStringFromNumber(UInt32 value, int sizeInBytes, int style);
|
||||
char * GetStringFromIndex(UInt8 strIndex, IOUSBDeviceRef deviceIntf);
|
||||
NSString * VendorNameFromVendorID(NSString * intValueAsString);
|
||||
NSString * GetUSBProductNameFromRegistry(io_registry_entry_t entry);
|
||||
|
||||
void FreeString(char * cstr);
|
||||
UInt16 Swap16(void *p);
|
||||
uint32_t Swap32(void *p);
|
||||
uint64_t Swap64(void *p);
|
||||
uint32_t Swap24(void *p);
|
||||
|
||||
const char * USBErrorToString(IOReturn status);
|
||||
|
||||
IOUSBDescriptorHeader * NextDescriptor(const void *desc);
|
||||
IOUSBDescriptorHeader* FindNextDescriptor(IOUSBConfigurationDescriptor *curConfDesc, const void *cur, UInt8 descType);
|
||||
IOReturn FindNextInterfaceDescriptor(const IOUSBConfigurationDescriptor *configDescIn, const IOUSBInterfaceDescriptor *intfDesc,IOUSBInterfaceDescriptor **descOut);
|
||||
|
||||
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
#define kUSBAudioInterfaceDesc (0x24)
|
||||
#define kUSBAudioEndPointDesc (0x25)
|
||||
|
||||
// <rdar://10009579>
|
||||
#define kUSBAudioDescriptorBytesPerLine 16
|
||||
// String buffer size to log desciptor:
|
||||
// Each byte in descriptor requires 3 chars: 2 for nibbles + a space char
|
||||
// One byte for null terminator
|
||||
#define kUSBAudioMaxDescriptorStringSize ( ( kUSBAudioDescriptorBytesPerLine * 3 ) + 1 ) * sizeof ( char )
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descContents[32];
|
||||
} GenericAudioDescriptor, *GenericAudioDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
enum AudioClassSpecific {
|
||||
ACS_HEADER = 0x01,
|
||||
ACS_INPUT_TERMINAL = 0x02,
|
||||
ACS_OUTPUT_TERMINAL = 0x03,
|
||||
ACS_MIXER_UNIT = 0x04,
|
||||
ACS_SELECTOR_UNIT = 0x05,
|
||||
ACS_FEATURE_UNIT = 0x06,
|
||||
ACS_PROCESSING_UNIT = 0x07,
|
||||
ACS_EXTENSION_UNIT = 0x08,
|
||||
ACS_UNDEFINED = 0x20,
|
||||
ACS_DEVICE = 0x21,
|
||||
ACS_CONFIGURATION = 0x22,
|
||||
ACS_STRING = 0x23,
|
||||
ACS_INTERFACE = 0x24,
|
||||
ACS_ENDPOINT = 0x25,
|
||||
ACS_FORMAT_TYPE = 0x02,
|
||||
ACS_FORMAT_SPECIFIC = 0x03,
|
||||
ACS_FORMAT_TYPE_UNDEF = 0x00,
|
||||
ACS_FORMAT_TYPE_I = 0x01,
|
||||
ACS_FORMAT_TYPE_II = 0x02,
|
||||
ACS_FORMAT_TYPE_III = 0x03,
|
||||
ACS_ASTREAM_UNDEF = 0x00,
|
||||
ACS_ASTREAM_GENERAL = 0x01,
|
||||
ACS_ASTREAM_TYPE = 0x02,
|
||||
ACS_ASTREAM_SPECIFIC = 0x03,
|
||||
AC_CONTROL_SUBCLASS = 0x01,
|
||||
AC_STREAM_SUBCLASS = 0x02,
|
||||
AC_MIDI_SUBCLASS = 0x03
|
||||
};
|
||||
|
||||
// Standard Audio Stream Isoc Audio Data Endpoint Descriptor
|
||||
// Refer to USB Audio Class Devices pp. 61-62.
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 asAddress;
|
||||
UInt8 asAttributes;
|
||||
UInt16 asMaxPacketSize;
|
||||
UInt8 asInterval;
|
||||
UInt8 asRefresh;
|
||||
UInt8 asSynchAddress;
|
||||
} AS_IsocEndPtDesc, *AS_IsocEndPtDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
// Class Specific Audio Stream Isoc Audio Data Endpoint Descriptor
|
||||
// Refer to USB Audio Class Devices pp. 62-63.
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubtype;
|
||||
UInt8 asAttributes;
|
||||
UInt8 bLockDelayUnits;
|
||||
UInt16 wLockDelay;
|
||||
} CSAS_IsocEndPtDesc, *CSAS_IsocEndPtDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt16 descVersNum;
|
||||
UInt16 descTotalLength;
|
||||
UInt8 descAICNum; /* Number of elements in the Audio Interface Collection. */
|
||||
UInt8 descInterfaceNum[1];
|
||||
} AudioCtrlHdrDescriptor, *AudioCtrlHdrDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descTermID;
|
||||
UInt16 descTermType;
|
||||
UInt8 descOutTermID;
|
||||
UInt8 descNumChannels;
|
||||
UInt16 descChannelConfig;
|
||||
UInt8 descChannelNames;
|
||||
UInt8 descTermName;
|
||||
} AudioCtrlInTermDescriptor, *AudioCtrlInTermDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descTermID;
|
||||
UInt16 descTermType;
|
||||
UInt8 descInTermID;
|
||||
UInt8 descSourceID;
|
||||
UInt8 descTermName;
|
||||
} AudioCtrlOutTermDescriptor, *AudioCtrlOutTermDescriptorPtr;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt8 descNumPins;
|
||||
UInt8 descSourcePID[1];
|
||||
} AudioCtrlMixerDescriptor, *AudioCtrlMixerDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt8 descNumPins;
|
||||
UInt8 descSourcePID[1];
|
||||
} AudioCtrlSelectorDescriptor, *AudioCtrlSelectorDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt8 descSourceID;
|
||||
UInt8 descCtrlSize;
|
||||
UInt8 descControls[1];
|
||||
} AudioCtrlFeatureDescriptor, *AudioCtrlFeatureDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt16 descExtensionCode;
|
||||
UInt8 descNumPins;
|
||||
UInt8 descSourcePID[1];
|
||||
} AudioCtrlExtDescriptor, *AudioCtrlExtDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 terminalID;
|
||||
UInt8 delay;
|
||||
UInt16 formatTag;
|
||||
} CSAS_InterfaceDescriptor, *CSAS_InterfaceDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct acProcessingDescriptor{ // <09><><EFBFBD><EFBFBD> WARNING <20><><EFBFBD> ADDING ELEMENTS WILL KILL CODE!!!
|
||||
UInt8 descLen; // size of this descriptor in bytes
|
||||
UInt8 bDescriptorType; // const CS_INTERFACE
|
||||
UInt8 bDescriptorSubtype; // const FEATURE_UNIT
|
||||
UInt8 bUnitID;
|
||||
UInt16 wProcessType;
|
||||
UInt8 bNrPins;
|
||||
UInt8 bSourceID;
|
||||
}acProcessingDescriptor;
|
||||
#pragma options align=reset
|
||||
typedef acProcessingDescriptor *acProcessingDescriptorPtr;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct acProcessingDescriptorCont{
|
||||
UInt8 bNrChannels;
|
||||
UInt16 wChannelConfig;
|
||||
UInt8 iChannelNames;
|
||||
UInt8 bControlSize;
|
||||
UInt16 bmControls;
|
||||
UInt8 iProcessing;
|
||||
}acProcessingDescriptorCont;
|
||||
#pragma options align=reset
|
||||
typedef acProcessingDescriptorCont *acProcessingDescriptorContPtr;
|
||||
|
||||
/* Refer to USB PDF files for Frmts10.pdf pp. 10 for Type I Format Descriptor. */
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 byte1;
|
||||
UInt8 byte2;
|
||||
UInt8 byte3;
|
||||
} CSAS_Freq3, *CSAS_Freq3Ptr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
CSAS_Freq3 lowerSamFreq;
|
||||
CSAS_Freq3 upperSamFreq;
|
||||
} CSAS_ContTbl, *CSAS_ContTblPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
CSAS_Freq3 samFreq[1];
|
||||
} CSAS_DiscreteTbl, *CSAS_DiscreteTblPtr;
|
||||
#pragma options align=reset
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 formatType;
|
||||
UInt8 numberOfChannels;
|
||||
UInt8 subFrameSize;
|
||||
UInt8 bitResolution;
|
||||
UInt8 sampleFreqType;
|
||||
union {
|
||||
CSAS_ContTbl cont;
|
||||
CSAS_DiscreteTbl discrete;
|
||||
} sampleFreqTables;
|
||||
} CSAS_FormatTypeIDesc, *CSAS_FormatTypeIDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
enum Audio20ClassSpecific {
|
||||
AC20S_HEADER = 0x01,
|
||||
AC20S_INPUT_TERMINAL = 0x02,
|
||||
AC20S_OUTPUT_TERMINAL = 0x03,
|
||||
AC20S_MIXER_UNIT = 0x04,
|
||||
AC20S_SELECTOR_UNIT = 0x05,
|
||||
AC20S_FEATURE_UNIT = 0x06,
|
||||
AC20S_EFFECT_UNIT = 0x07,
|
||||
AC20S_PROCESSING_UNIT = 0x08,
|
||||
AC20S_EXTENSION_UNIT = 0x09,
|
||||
AC20S_CLOCK_SOURCE = 0x0A,
|
||||
AC20S_CLOCK_SELECTOR = 0x0B,
|
||||
AC20S_CLOCK_MULTIPLIER = 0x0C,
|
||||
AC20S_SAMPLE_RATE_CONVERTER = 0x0D,
|
||||
|
||||
AC20S_FORMAT_TYPE_IV = 0x04,
|
||||
AC20S_EXTENDED_FORMAT_TYPE_I = 0x81,
|
||||
AC20S_EXTENDED_FORMAT_TYPE_II = 0x82,
|
||||
AC20S_EXTENDED_FORMAT_TYPE_III = 0x83
|
||||
|
||||
};
|
||||
|
||||
// Standard Audio Stream Isoc Audio Data Endpoint Descriptor
|
||||
// Refer to USB Audio Class Devices pp. 61-62.
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 asAddress;
|
||||
UInt8 asAttributes;
|
||||
UInt16 asMaxPacketSize;
|
||||
UInt8 asInterval;
|
||||
} AS20_IsocEndPtDesc, *AS20_IsocEndPtDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
// Class Specific Audio Stream Isoc Audio Data Endpoint Descriptor
|
||||
// Refer to USB Audio Class Devices pp. 62-63.
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubtype;
|
||||
UInt8 asAttributes;
|
||||
UInt8 bmControls;
|
||||
UInt8 bLockDelayUnits;
|
||||
UInt16 wLockDelay;
|
||||
} CSA20S_IsocEndPtDesc, *CSAS20_IsocEndPtDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt16 descVersNum;
|
||||
UInt8 descCategory;
|
||||
UInt16 descTotalLength;
|
||||
UInt8 descbmControls;
|
||||
} Audio20CtrlHdrDescriptor, *Audio20CtrlHdrDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descTermID;
|
||||
UInt16 descTermType;
|
||||
UInt8 descOutTermID;
|
||||
UInt8 descClockSourceID;
|
||||
UInt8 descNumChannels;
|
||||
UInt32 descChannelConfig;
|
||||
UInt8 descChannelNames;
|
||||
UInt16 descbmControls;
|
||||
UInt8 descTermName;
|
||||
} Audio20CtrlInTermDescriptor, *Audio20CtrlInTermDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descClockID;
|
||||
UInt8 descAttributes;
|
||||
UInt8 descbmControls;
|
||||
UInt8 descAssocTermID;
|
||||
UInt8 desciClockSourceName;
|
||||
} Audio20ClockSourceDescriptor, *Audio20ClockSourceDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descClockID;
|
||||
UInt8 descNumPins;
|
||||
UInt8 descClockPID[1];
|
||||
} Audio20ClockSelectorDescriptor, *Audio20ClockSelectorDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descClockID;
|
||||
UInt8 descClockSourceID;
|
||||
UInt8 descbmControls;
|
||||
UInt8 desciClockMultiplierName;
|
||||
} Audio20ClockMultiplierDescriptor, *Audio20ClockMultiplierDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descTermID;
|
||||
UInt16 descTermType;
|
||||
UInt8 descInTermID;
|
||||
UInt8 descSourceID;
|
||||
UInt8 descClockSourceID;
|
||||
UInt16 bmControls;
|
||||
UInt8 descTermName;
|
||||
} Audio20CtrlOutTermDescriptor, *Audio20CtrlOutTermDescriptorPtr;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt8 descSourceID;
|
||||
UInt8 descControls[1];
|
||||
} Audio20CtrlFeatureDescriptor, *Audio20CtrlFeatureDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 descUnitID;
|
||||
UInt16 descExtensionCode;
|
||||
UInt8 descNumPins;
|
||||
UInt8 descSourcePID[1];
|
||||
} Audio20CtrlExtDescriptor, *Audio20CtrlExtDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 terminalID;
|
||||
UInt8 bmControls;
|
||||
UInt8 formatType;
|
||||
UInt32 bmFormats;
|
||||
UInt8 numChannels;
|
||||
UInt32 channelConfig;
|
||||
UInt8 channelNames;
|
||||
} CS20AS_InterfaceDescriptor, *CS20AS_InterfaceDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ac20ProcessingDescriptor{ // <09><><EFBFBD><EFBFBD> WARNING <20><><EFBFBD> ADDING ELEMENTS WILL KILL CODE!!!
|
||||
UInt8 descLen; // size of this descriptor in bytes
|
||||
UInt8 bDescriptorType; // const CS_INTERFACE
|
||||
UInt8 bDescriptorSubtype; // const FEATURE_UNIT
|
||||
UInt8 bUnitID;
|
||||
UInt16 wProcessType;
|
||||
UInt8 bNrPins;
|
||||
UInt8 bSourceID[1];
|
||||
}ac20ProcessingDescriptor, *ac20ProcessingDescriptorPtr;
|
||||
#pragma options align=reset
|
||||
typedef ac20ProcessingDescriptor *a20cProcessingDescriptorPtr;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct ac20ProcessingDescriptorCont{
|
||||
UInt8 bNrChannels;
|
||||
UInt32 wChannelConfig;
|
||||
UInt8 iChannelNames;
|
||||
UInt16 bmControls;
|
||||
UInt8 iProcessing;
|
||||
}ac20ProcessingDescriptorCont;
|
||||
#pragma options align=reset
|
||||
typedef ac20ProcessingDescriptorCont *ac20ProcessingDescriptorContPtr;
|
||||
|
||||
/* Refer to USB PDF files for Frmts10.pdf pp. 10 for Type I Format Descriptor. */
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UInt8 descLen;
|
||||
UInt8 descType;
|
||||
UInt8 descSubType;
|
||||
UInt8 formatType;
|
||||
UInt8 slotSize;
|
||||
UInt8 bitResolution;
|
||||
} CS20AS_FormatTypeIDesc, *CS20AS_FormatTypeIDescPtr;
|
||||
#pragma options align=reset
|
||||
|
||||
@interface DecodeAudioInterfaceDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+(void)decodeBytes:(UInt8 *)descriptor forDevice:(BusProbeDevice *)thisDevice;
|
||||
void decodeBytes10( UInt8 *descriptor, BusProbeDevice * thisDevice );
|
||||
void decodeBytes20( UInt8 *descriptor, BusProbeDevice * thisDevice );
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright © 2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeBOSDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(IOUSBBOSDescriptor *)bosDescriptor forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeCommClassDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
|
||||
|
||||
@end
|
||||
|
||||
@interface DecodeMassStorageDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeConfigurationDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(IOUSBConfigurationDescHeader *)cfg forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf configNumber:(int)iconfig currentConfig:(int)cconfig isOtherSpeedDesc:(BOOL)isOtherSpeedDesc;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeDeviceDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(IOUSBDeviceDescriptor *)dev forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf wasSuspended:(BOOL)wasSuspended;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeDeviceQualifierDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
enum {
|
||||
kEndpointAddressBit = 7,
|
||||
kEndpointAddressMask = ( 1 << kEndpointAddressBit )
|
||||
};
|
||||
|
||||
@interface DecodeEndpointDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice isOtherSpeedDesc:(BOOL)isOtherSpeedDesc;
|
||||
+ (void)decodeBytesCompanion:(Byte *)p forDevice:(BusProbeDevice *)thisDevice endpoint:(UInt8)epType;
|
||||
@end
|
||||
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOKit/hid/IOHIDUsageTables.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
#define UnpackReportSize(packedByte) ((packedByte) & 0x03)
|
||||
#define UnpackReportType(packedByte) (((packedByte) & 0x0C) >> 2)
|
||||
#define UnpackReportTag(packedByte) (((packedByte) & 0xF0) >> 4)
|
||||
|
||||
enum
|
||||
{
|
||||
kReport_TypeMain = 0,
|
||||
kReport_TypeGlobal = 1,
|
||||
kReport_TypeLocal = 2,
|
||||
kReport_TypeReserved = 3,
|
||||
|
||||
kReport_TagLongItem = 0x0F,
|
||||
|
||||
// main items
|
||||
kReport_TagInput = 0x08,
|
||||
kReport_TagOutput = 0x09,
|
||||
kReport_TagFeature = 0x0B,
|
||||
kReport_TagCollection = 0x0A,
|
||||
kReport_TagEndCollection = 0x0C,
|
||||
|
||||
// global items
|
||||
kReport_TagUsagePage = 0x00,
|
||||
kReport_TagLogicalMin = 0x01,
|
||||
kReport_TagLogicalMax = 0x02,
|
||||
kReport_TagPhysicalMin = 0x03,
|
||||
kReport_TagPhysicalMax = 0x04,
|
||||
kReport_TagUnitExponent = 0x05,
|
||||
kReport_TagUnit = 0x06,
|
||||
kReport_TagReportSize = 0x07,
|
||||
kReport_TagReportID = 0x08,
|
||||
kReport_TagReportCount = 0x09,
|
||||
kReport_TagPush = 0x0A,
|
||||
kReport_TagPop = 0x0B,
|
||||
|
||||
// local items
|
||||
kReport_TagUsage = 0x00,
|
||||
kReport_TagUsageMin = 0x01,
|
||||
kReport_TagUsageMax = 0x02,
|
||||
kReport_TagDesignatorIndex = 0x03,
|
||||
kReport_TagDesignatorMin = 0x04,
|
||||
kReport_TagDesignatorMax = 0x05,
|
||||
kReport_TagStringIndex = 0x07,
|
||||
kReport_TagStringMin = 0x08,
|
||||
kReport_TagStringMax = 0x09,
|
||||
kReport_TagSetDelimiter = 0x0A
|
||||
};
|
||||
|
||||
// Collection constants
|
||||
enum
|
||||
{
|
||||
kCollection_Physical = 0x00,
|
||||
kCollection_Application = 0x01,
|
||||
kCollection_Logical = 0x02
|
||||
};
|
||||
|
||||
// I/O constants (used for Input/Output/Feature tags)
|
||||
enum
|
||||
{
|
||||
kIO_Data_or_Constant = 0x0001,
|
||||
kIO_Array_or_Variable = 0x0002,
|
||||
kIO_Absolute_or_Relative = 0x0004,
|
||||
kIO_NoWrap_or_Wrap = 0x0008,
|
||||
kIO_Linear_or_NonLinear = 0x0010,
|
||||
kIO_PreferredState_or_NoPreferred = 0x0020,
|
||||
kIO_NoNullPosition_or_NullState = 0x0040,
|
||||
kIO_NonVolatile_or_Volatile = 0x0080, // reserved for Input
|
||||
kIO_BitField_or_BufferedBytes = 0x0100
|
||||
};
|
||||
|
||||
// Usage pages from HID Usage Tables spec 1.0
|
||||
enum
|
||||
{
|
||||
kUsage_PageGenericDesktop = 0x01,
|
||||
kUsage_PageSimulationControls = 0x02,
|
||||
kUsage_PageVRControls = 0x03,
|
||||
kUsage_PageSportControls = 0x04,
|
||||
kUsage_PageGameControls = 0x05,
|
||||
kUsage_PageKeyboard = 0x07,
|
||||
kUsage_PageLED = 0x08,
|
||||
kUsage_PageButton = 0x09,
|
||||
kUsage_PageOrdinal = 0x0A,
|
||||
kUsage_PageTelephonyDevice = 0x0B,
|
||||
kUsage_PageConsumer = 0x0C,
|
||||
kUsage_PageDigitizers = 0x0D,
|
||||
kUsage_PagePID = 0x0F,
|
||||
kUsage_PageUnicode = 0x10,
|
||||
kUsage_PageAlphanumericDisplay = 0x14,
|
||||
kUsage_PageMonitor = 0x80,
|
||||
kUsage_PageMonitorEnumeratedValues = 0x81,
|
||||
kUsage_PageMonitorVirtualControl = 0x82,
|
||||
kUsage_PageMonitorReserved = 0x83,
|
||||
kUsage_PagePowerDevice = 0x84,
|
||||
kUsage_PageBatterySystem = 0x85,
|
||||
kUsage_PowerClassReserved = 0x86,
|
||||
kUsage_PowerClassReserved2 = 0x87,
|
||||
kUsage_VendorDefinedStart = 0xff00
|
||||
};
|
||||
|
||||
// Usage constants for Generic Desktop page (01) from HID Usage Tables spec 1.0
|
||||
enum
|
||||
{
|
||||
kUsage_01_Pointer = 0x01,
|
||||
kUsage_01_Mouse = 0x02,
|
||||
kUsage_01_Joystick = 0x04,
|
||||
kUsage_01_GamePad = 0x05,
|
||||
kUsage_01_Keyboard = 0x06,
|
||||
kUsage_01_Keypad = 0x07,
|
||||
|
||||
kUsage_01_X = 0x30,
|
||||
kUsage_01_Y = 0x31,
|
||||
kUsage_01_Z = 0x32,
|
||||
kUsage_01_Rx = 0x33,
|
||||
kUsage_01_Ry = 0x34,
|
||||
kUsage_01_Rz = 0x35,
|
||||
kUsage_01_Slider = 0x36,
|
||||
kUsage_01_Dial = 0x37,
|
||||
kUsage_01_Wheel = 0x38,
|
||||
kUsage_01_HatSwitch = 0x39,
|
||||
kUsage_01_CountedBuffer = 0x3A,
|
||||
kUsage_01_ByteCount = 0x3B,
|
||||
kUsage_01_MotionWakeup = 0x3C,
|
||||
|
||||
kUsage_01_Vx = 0x40,
|
||||
kUsage_01_Vy = 0x41,
|
||||
kUsage_01_Vz = 0x42,
|
||||
kUsage_01_Vbrx = 0x43,
|
||||
kUsage_01_Vbry = 0x44,
|
||||
kUsage_01_Vbrz = 0x45,
|
||||
kUsage_01_Vno = 0x46,
|
||||
|
||||
kUsage_01_SystemControl = 0x80,
|
||||
kUsage_01_SystemPowerDown = 0x81,
|
||||
kUsage_01_SystemSleep = 0x82,
|
||||
kUsage_01_SystemWakeup = 0x83,
|
||||
kUsage_01_SystemContextMenu = 0x84,
|
||||
kUsage_01_SystemMainMenu = 0x85,
|
||||
kUsage_01_SystemAppMenu = 0x86,
|
||||
kUsage_01_SystemMenuHelp = 0x87,
|
||||
kUsage_01_SystemMenuExit = 0x88,
|
||||
kUsage_01_SystemMenuSelect = 0x89,
|
||||
kUsage_01_SystemMenuRight = 0x8A,
|
||||
kUsage_01_SystemMenuLeft = 0x8B,
|
||||
kUsage_01_SystemMenuUp = 0x8C,
|
||||
kUsage_01_SystemMenuDown = 0x8D
|
||||
};
|
||||
|
||||
/*!
|
||||
@typedef IOUSBCCIDDescriptor
|
||||
@discussion USB Device CHIP CARD ID Descriptor. See the USB CCID Specification at <a href="http://www.usb.org"TARGET="_blank">http://www.usb.org</a>.
|
||||
*/
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBCCIDDescriptor
|
||||
{
|
||||
UInt8 bLength;
|
||||
UInt8 bDescriptorType;
|
||||
UInt16 bcdCCID;
|
||||
UInt8 bMaxSlotIndex;
|
||||
UInt8 bVoltageSupport;
|
||||
UInt32 dwProtocols;
|
||||
UInt32 dwDefaultClock;
|
||||
UInt32 dwMaximumClock;
|
||||
UInt8 bNumClockSupported;
|
||||
UInt32 dwDataRate;
|
||||
UInt32 dwMaxDataRate;
|
||||
UInt8 bNumDataRatesSupported;
|
||||
UInt32 dwMaxIFSD;
|
||||
UInt32 dwSyncProtocols;
|
||||
UInt32 dwMechanical;
|
||||
UInt32 dwFeatures;
|
||||
UInt32 dwMaxCCIDMessageLength;
|
||||
UInt8 bClassGetResponse;
|
||||
UInt8 bClassEnvelope;
|
||||
UInt16 wLcdLayout;
|
||||
UInt8 bPINSupport;
|
||||
UInt8 bMaxCCIDBusySlots;
|
||||
};
|
||||
typedef struct IOUSBCCIDDescriptor IOUSBCCIDDescriptor;
|
||||
typedef IOUSBCCIDDescriptor * IOUSBCCIDDescriptorPtr;
|
||||
|
||||
#pragma options align=reset
|
||||
|
||||
|
||||
|
||||
|
||||
/* end HID Constants Spec 1.0 */
|
||||
|
||||
@interface DecodeHIDDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf isinCurrentConfig:(Boolean)inCurrentConfig;
|
||||
|
||||
+(void)decodeHIDReport:(UInt8 *)reportDesc forDevice:(BusProbeDevice *)thisDevice atDepth:(UInt16)depth reportLen:(UInt16)length;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
struct IOUSBHubDescriptor {
|
||||
UInt8 length;
|
||||
UInt8 hubType;
|
||||
UInt8 numPorts;
|
||||
UInt16 characteristics __attribute__((packed));
|
||||
UInt8 powerOnToGood; // Port settling time, in 2ms
|
||||
UInt8 hubCurrent;
|
||||
// These are received packed, will have to be unpacked
|
||||
UInt8 removablePortFlags[9];
|
||||
UInt8 pwrCtlPortFlags[9];
|
||||
};
|
||||
|
||||
typedef struct IOUSBHubDescriptor IOUSBHubDescriptor;
|
||||
|
||||
// To cope with the extra fields in a USB3 hub descriptor
|
||||
|
||||
struct IOUSB3HubDescriptor {
|
||||
UInt8 length;
|
||||
UInt8 hubType;
|
||||
UInt8 numPorts;
|
||||
UInt16 characteristics __attribute__((packed));
|
||||
UInt8 powerOnToGood; // Port settling time, in 2ms
|
||||
UInt8 hubCurrent;
|
||||
UInt8 hubHdrDecLat; // Header decode latency, new 3.0 field
|
||||
UInt16 hubDelay __attribute__((packed)); // new in 3.0
|
||||
|
||||
// These are received packed, will have to be unpacked
|
||||
UInt8 removablePortFlags[9];
|
||||
UInt8 pwrCtlPortFlags[9]; // This field does not exist in the 3.0 descriptor
|
||||
};
|
||||
|
||||
typedef struct IOUSB3HubDescriptor IOUSB3HubDescriptor;
|
||||
|
||||
@interface DecodeHubDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface DecodeInterfaceDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
|
||||
|
||||
@end
|
||||
|
||||
@interface DecodeInterfaceAssociationDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+ (void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,765 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "DescriptorDecoder.h"
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
enum VideoClassSpecific
|
||||
{
|
||||
// Video Interface Class Code
|
||||
CC_VIDEO = 0x0E,
|
||||
|
||||
// Video Interface Subclass Codes
|
||||
//
|
||||
SC_UNDEFINED = 0x00,
|
||||
SC_VIDEOCONTROL = 0x01,
|
||||
SC_VIDEOSTREAMING = 0x02,
|
||||
SC_VIDEO_INTERFACE_COLLECTION = 0x03,
|
||||
|
||||
// Video Interface Protocol Codes
|
||||
//
|
||||
PC_PROTOCOL_UNDEFINED = 0x00,
|
||||
|
||||
// Video Class Specific Descriptor Types
|
||||
//
|
||||
CS_UNDEFINED = 0x20,
|
||||
CS_DEVICE = 0x21,
|
||||
CS_CONFIGURATION = 0x22,
|
||||
CS_STRING = 0x23,
|
||||
// CS_INTERFACE = 0x24,
|
||||
// CS_ENDPOINT = 0x25,
|
||||
|
||||
// Video Class Specific Control Interface Descriptor Types
|
||||
//
|
||||
VC_DESCRIPTOR_UNDEFINED = 0x00,
|
||||
VC_HEADER = 0x01,
|
||||
VC_INPUT_TERMINAL = 0x02,
|
||||
VC_OUTPUT_TERMINAL = 0x03,
|
||||
VC_SELECTOR_UNIT = 0x04,
|
||||
VC_PROCESSING_UNIT = 0x05,
|
||||
VC_EXTENSION_UNIT = 0x06,
|
||||
|
||||
// Video Class Specific Streaming Interface Descriptor Types
|
||||
//
|
||||
VS_UNDEFINED = 0x00,
|
||||
VS_INPUT_HEADER = 0x01,
|
||||
VS_OUTPUT_HEADER = 0x02,
|
||||
VS_STILL_IMAGE_FRAME = 0x03,
|
||||
VS_FORMAT_UNCOMPRESSED = 0x04,
|
||||
VS_FRAME_UNCOMPRESSED = 0x05,
|
||||
VS_FORMAT_MJPEG = 0x06,
|
||||
VS_FRAME_MJPEG = 0x07,
|
||||
VS_FORMAT_MPEG1 = 0x08, // Reserved in 1.1
|
||||
VS_FORMAT_MPEG2PS = 0x09, // Reserved in 1.1
|
||||
VS_FORMAT_MPEG2TS = 0x0a,
|
||||
VS_FORMAT_DV = 0x0c,
|
||||
VS_COLORFORMAT = 0x0d,
|
||||
VS_FORMAT_VENDOR = 0x0e, // Reserved in 1.1
|
||||
VS_FRAME_VENDOR = 0x0f, // Reserved in 1.1
|
||||
VS_FORMAT_FRAME_BASED = 0x10,
|
||||
VS_FRAME_FRAME_BASED = 0x11,
|
||||
VS_FORMAT_STREAM_BASED = 0x12,
|
||||
VS_FORMAT_MPEG4SL = 0xFF, // Undefined in 1.1
|
||||
|
||||
// Video Class Specific Endpoint Descriptor Subtypes
|
||||
//
|
||||
EP_UNDEFINED = 0x00,
|
||||
EP_GENERAL = 0x01,
|
||||
EP_ENDPOINT = 0x02,
|
||||
EP_INTERRUPT = 0x03,
|
||||
|
||||
// Video Class Specific Request Codes
|
||||
//
|
||||
RC_UNDEFINED = 0x00,
|
||||
SET_CUR = 0x01,
|
||||
GET_CUR = 0x81,
|
||||
GET_MIN = 0x82,
|
||||
GET_MAX = 0x83,
|
||||
GET_RES = 0x84,
|
||||
GET_LEN = 0x85,
|
||||
GET_INFO = 0x86,
|
||||
GET_DEF = 0x87,
|
||||
|
||||
// Video Control Interface Control Selectors
|
||||
//
|
||||
VC_CONTROL_UNDEFINED = 0x00,
|
||||
VC_VIDEO_POWER_MODE_CONTROL = 0x01,
|
||||
VC_REQUEST_ERROR_CODE_CONTROL = 0x02,
|
||||
VC_REQUEST_INDICATE_HOST_CLOCK_CONTROL = 0x03,
|
||||
|
||||
// Terminal Control Selectors
|
||||
//
|
||||
TE_CONTROL_UNDEFINED = 0x00,
|
||||
|
||||
// Selector Unit Control Selectors
|
||||
//
|
||||
SU_CONTROL_UNDEFINED = 0x00,
|
||||
SU_INPUT_SELECT_CONTROL = 0x01,
|
||||
|
||||
// Camera Terminal Control Selectors
|
||||
//
|
||||
CT_CONTROL_UNDEFINED = 0x00,
|
||||
CT_SCANNING_MODE_CONTROL = 0x01,
|
||||
CT_AE_MODE_CONTROL = 0x02,
|
||||
CT_AE_PRIORITY_CONTROL = 0x03,
|
||||
CT_EXPOSURE_TIME_ABSOLUTE_CONTROL = 0x04,
|
||||
CT_EXPOSURE_TIME_RELATIVE_CONTROL = 0x05,
|
||||
CT_FOCUS_ABSOLUTE_CONTROL = 0x06,
|
||||
CT_FOCUS_RELATIVE_CONTROL = 0x07,
|
||||
CT_FOCUS_AUTO_CONTROL = 0x08,
|
||||
CT_IRIS_ABSOLUTE_CONTROL = 0x09,
|
||||
CT_IRIS_RELATIVE_CONTROL = 0x0A,
|
||||
CT_ZOOM_ABSOLUTE_CONTROL = 0x0B,
|
||||
CT_ZOOM_RELATIVE_CONTROL = 0x0C,
|
||||
CT_PANTILT_ABSOLUTE_CONTROL = 0x0D,
|
||||
CT_PANTILT_RELATIVE_CONTROL = 0x0E,
|
||||
CT_ROLL_ABSOLUTE_CONTROL = 0x0F,
|
||||
CT_ROLL_RELATIVE_CONTROL = 0x10,
|
||||
CT_PRIVACY_CONTROL = 0x11,
|
||||
|
||||
// Processing Unit Control Selectors
|
||||
//
|
||||
PU_CONTROL_UNDEFINED = 0x00,
|
||||
PU_BACKLIGHT_COMPENSATION_CONTROL = 0x01,
|
||||
PU_BRIGHTNESS_CONTROL = 0x02,
|
||||
PU_CONTRAST_CONTROL = 0x03,
|
||||
PU_GAIN_CONTROL = 0x04,
|
||||
PU_POWER_LINE_FREQUENCY_CONTROL = 0x05,
|
||||
PU_HUE_CONTROL = 0x06,
|
||||
PU_SATURATION_CONTROL = 0x07,
|
||||
PU_SHARPNESS_CONTROL = 0x08,
|
||||
PU_GAMMA_CONTROL = 0x09,
|
||||
PU_WHITE_BALANCE_TEMPERATURE_CONTROL = 0x0A,
|
||||
PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL = 0x0B,
|
||||
PU_WHITE_BALANCE_COMPONENT_CONTROL = 0x0C,
|
||||
PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL = 0x0D,
|
||||
PU_DIGITAL_MULTIPLIER_CONTROL = 0x0E,
|
||||
PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL = 0x0F,
|
||||
PU_HUE_AUTO_CONTROL = 0x10,
|
||||
|
||||
// Extension Unit Control Selectors
|
||||
//
|
||||
XU_CONTROL_UNDEFINED = 0x00,
|
||||
|
||||
// Video Streaming Interface Control Selectors
|
||||
//
|
||||
VS_CONTROL_UNDEFINED = 0x00,
|
||||
VS_PROBE_CONTROL = 0x01,
|
||||
VS_COMMIT_CONTROL = 0x02,
|
||||
VS_STILL_PROBE_CONTROL = 0x03,
|
||||
VS_STILL_COMMIT_CONTROL = 0x04,
|
||||
VS_STILL_IMAGE_TRIGGER_CONTROL = 0x05,
|
||||
VS_STREAM_ERROR_CODE_CONTROL = 0x06,
|
||||
VS_GENERATE_KEY_FRAME_CONTROL = 0x07,
|
||||
VS_UPDATE_FRAME_SEGMENT_CONTROL = 0x08,
|
||||
VS_SYNCH_DELAY_CONTROL = 0x09,
|
||||
|
||||
// USB Terminal Types
|
||||
//
|
||||
TT_VENDOR_SPECIFIC = 0x0100,
|
||||
TT_STREAMING = 0x0101,
|
||||
|
||||
// Input Terminal Types
|
||||
//
|
||||
ITT_VENDOR_SPECIFIC = 0x0200,
|
||||
ITT_CAMERA = 0x0201,
|
||||
ITT_MEDIA_TRANSPORT_UNIT = 0x0202,
|
||||
|
||||
// Output Terminal Types
|
||||
//
|
||||
OTT_VENDOR_SPECIFIC = 0x0300,
|
||||
OTT_DISPLAY = 0x0301,
|
||||
OTT_MEDIA_TRANSPORT_OUTPUT = 0x0302,
|
||||
|
||||
// External Terminal Types
|
||||
//
|
||||
EXTERNAL_VENDOR_SPECIFIC = 0x0400,
|
||||
COMPOSITE_CONNECTOR = 0x0401,
|
||||
SVIDEO_CONNECTOR = 0x0402,
|
||||
COMPONENT_CONNECTOR = 0x0403,
|
||||
|
||||
// Media Transport Terminal Control Selectors
|
||||
//
|
||||
MTT_CONTROL_UNDEFINED = 0x00,
|
||||
TRANSPORT_CONTROL = 0X01,
|
||||
ATN_INFORMATION_CONTROL = 0X02,
|
||||
MEDIA_INFORMATION_CONTROL = 0X03,
|
||||
TIME_CODE_INFORMATION_CONTROL = 0X04,
|
||||
|
||||
|
||||
};
|
||||
|
||||
enum UncompressedFormatGUID
|
||||
{
|
||||
UNCOMPRESSED_YUV2_HI = 0x3259555900000010ULL,
|
||||
UNCOMPRESSED_YUV2_LO = 0x800000aa00389b71ULL,
|
||||
UNCOMPRESSED_NV12_HI = 0x3231564E00000010ULL,
|
||||
UNCOMPRESSED_NV12_LO = 0x800000aa00389b71ULL,
|
||||
};
|
||||
|
||||
// Standard Video Class Control Interface Descriptor
|
||||
//
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCInterfaceDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint16_t bcdVDC;
|
||||
uint16_t wTotalLength;
|
||||
uint32_t dwClockFrequency;
|
||||
uint8_t bInCollection; // Number of Video Streaming Interfaces in the collection
|
||||
uint8_t baInterfaceNr[1];
|
||||
};
|
||||
typedef struct IOUSBVCInterfaceDescriptor IOUSBVCInterfaceDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
// Video Control Standard Input Terminal Descriptor
|
||||
//
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCInputTerminalDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t iTerminal;
|
||||
};
|
||||
typedef struct IOUSBVCInputTerminalDescriptor IOUSBVCInputTerminalDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
// Video Class Standard Output Terminal Descriptor
|
||||
//
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCOutputTerminalDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t bSourceID;
|
||||
uint8_t iTerminal;
|
||||
};
|
||||
typedef struct IOUSBVCOutputTerminalDescriptor IOUSBVCOutputTerminalDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
// Video Class Camera Terminal Descriptor
|
||||
//
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCCameraTerminalDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t iTerminal;
|
||||
uint16_t wObjectiveFocalLengthMin;
|
||||
uint16_t wObjectiveFocalLengthMax;
|
||||
uint16_t wOcularFocalLength;
|
||||
uint8_t bControlSize; // Size of the bmControls field
|
||||
uint8_t bmControls[1];
|
||||
};
|
||||
typedef struct IOUSBVCCameraTerminalDescriptor IOUSBVCCameraTerminalDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
// Video Class Selector Unit Descriptor
|
||||
//
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCSelectorUnitDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bUnitID;
|
||||
uint8_t bNrInPins;
|
||||
uint8_t baSourceID[1];
|
||||
};
|
||||
typedef struct IOUSBVCSelectorUnitDescriptor IOUSBVCSelectorUnitDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCSelectorUnit2Descriptor
|
||||
{
|
||||
uint8_t iSelector;
|
||||
};
|
||||
typedef struct IOUSBVCSelectorUnit2Descriptor IOUSBVCSelectorUnit2Descriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCProcessingUnitDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bUnitID;
|
||||
uint8_t bSourceID;
|
||||
uint16_t wMaxMultiplier;
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmControls[1];
|
||||
};
|
||||
typedef struct IOUSBVCProcessingUnitDescriptor IOUSBVCProcessingUnitDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCProcessingUnit2Descriptor
|
||||
{
|
||||
uint8_t iProcessing;
|
||||
};
|
||||
typedef struct IOUSBVCProcessingUnit2Descriptor IOUSBVCProcessingUnit2Descriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCExtensionUnitDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bUnitID;
|
||||
uint8_t guidFormat[16];
|
||||
uint8_t bNumControls;
|
||||
uint8_t bNrInPins;
|
||||
uint8_t baSourceID[1];
|
||||
};
|
||||
typedef struct IOUSBVCExtensionUnitDescriptor IOUSBVCExtensionUnitDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCExtensionUnit2Descriptor
|
||||
{
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmControls[1];
|
||||
};
|
||||
typedef struct IOUSBVCExtensionUnit2Descriptor IOUSBVCExtensionUnit2Descriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCExtensionUnit3Descriptor
|
||||
{
|
||||
uint8_t iExtension;
|
||||
};
|
||||
typedef struct IOUSBVCExtensionUnit3Descriptor IOUSBVCExtensionUnit3Descriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVCInterruptEndpointDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint16_t wMaxTransferSize;
|
||||
};
|
||||
typedef struct IOUSBVCInterruptEndpointDescriptor IOUSBVCInterruptEndpointDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVSInputHeaderDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bNumFormats;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmInfo;
|
||||
uint8_t bTerminalLink;
|
||||
uint8_t bStillCaptureMethod;
|
||||
uint8_t bTriggerSupport;
|
||||
uint8_t bTriggerUsage;
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmControls[1];
|
||||
};
|
||||
typedef struct IOUSBVSInputHeaderDescriptor IOUSBVSInputHeaderDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVSOutputHeaderDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bNumFormats;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bTerminalLink;
|
||||
};
|
||||
typedef struct IOUSBVSOutputHeaderDescriptor IOUSBVSOutputHeaderDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MJPEGFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t bmFlags;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bAspectRatioX;
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
};
|
||||
typedef struct IOUSBVDC_MJPEGFormatDescriptor IOUSBVDC_MJPEGFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
struct IOSUBVDC_StillImageSize
|
||||
{
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
};
|
||||
typedef struct IOSUBVDC_StillImageSize IOSUBVDC_StillImageSize;
|
||||
|
||||
struct IOSUBVDC_StillImageCompressionPattern
|
||||
{
|
||||
uint8_t bNumCompressionPattern;
|
||||
uint8_t bCompression[1];
|
||||
};
|
||||
typedef struct IOSUBVDC_StillImageCompressionPattern IOSUBVDC_StillImageCompressionPattern;
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_StillImageFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bNumImageSizePatterns;
|
||||
IOSUBVDC_StillImageSize dwSize[1];
|
||||
};
|
||||
typedef struct IOUSBVDC_StillImageFrameDescriptor IOUSBVDC_StillImageFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MJPEGFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwMinFrameInterval;
|
||||
uint32_t dwMaxFrameInterval;
|
||||
uint32_t dwFrameIntervalStep;
|
||||
};
|
||||
typedef struct IOUSBVDC_MJPEGFrameDescriptor IOUSBVDC_MJPEGFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MJPEGDiscreteFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval[1];
|
||||
};
|
||||
typedef struct IOUSBVDC_MJPEGDiscreteFrameDescriptor IOUSBVDC_MJPEGDiscreteFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_UncompressedFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t guidFormat[16];
|
||||
uint8_t bBitsPerPixel;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bAspectRatioX;
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
};
|
||||
typedef struct IOUSBVDC_UncompressedFormatDescriptor IOUSBVDC_UncompressedFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_UncompressedFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwMinFrameInterval;
|
||||
uint32_t dwMaxFrameInterval;
|
||||
uint32_t dwFrameIntervalStep;
|
||||
};
|
||||
typedef struct IOUSBVDC_UncompressedFrameDescriptor IOUSBVDC_UncompressedFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_UncompressedDiscreteFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval[1];
|
||||
};
|
||||
typedef struct IOUSBVDC_UncompressedDiscreteFrameDescriptor IOUSBVDC_UncompressedDiscreteFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_VendorFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t guidMajorFormat[16];
|
||||
uint8_t guidSubFormat[16];
|
||||
uint8_t guidSpecifierFormat[16];
|
||||
uint8_t bPayloadClass;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bCopyProtect;
|
||||
};
|
||||
typedef struct IOUSBVDC_VendorFormatDescriptor IOUSBVDC_VendorFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_VendorFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwMinFrameInterval;
|
||||
uint32_t dwMaxFrameInterval;
|
||||
uint32_t dwFrameIntervalStep;
|
||||
};
|
||||
typedef struct IOUSBVDC_VendorFrameDescriptor IOUSBVDC_VendorFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_VendorDiscreteFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval[1];
|
||||
};
|
||||
typedef struct IOUSBVDC_VendorDiscreteFrameDescriptor IOUSBVDC_VendorDiscreteFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_DVFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint32_t dwMaxVideoFrameBufferSize;
|
||||
uint8_t bFormatType;
|
||||
};
|
||||
typedef struct IOUSBVDC_DVFormatDescriptor IOUSBVDC_DVFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MPEG1SSFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint16_t wPacketLength;
|
||||
uint16_t wPackLength;
|
||||
uint8_t bPackDataType;
|
||||
};
|
||||
typedef struct IOUSBVDC_MPEG1SSFormatDescriptor IOUSBVDC_MPEG1SSFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MPEG2PSFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint16_t wPacketLength;
|
||||
uint16_t wPackLength;
|
||||
uint8_t bPackDataType;
|
||||
};
|
||||
typedef struct IOUSBVDC_MPEG2PSFormatDescriptor IOUSBVDC_MPEG2PSFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_MPEG2PTSFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bDataOffset;
|
||||
uint8_t bPacketLength;
|
||||
uint8_t bStrideLength;
|
||||
};
|
||||
typedef struct IOUSBVDC_MPEG2PTSFormatDescriptor IOUSBVDC_MPEG2PTSFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_ColorFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bColorPrimaries;
|
||||
uint8_t bTransferCharacteristics;
|
||||
uint8_t bMatrixCoefficients;
|
||||
};
|
||||
typedef struct IOUSBVDC_ColorFormatDescriptor IOUSBVDC_ColorFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_FrameBasedFormatDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t guidFormat[16];
|
||||
uint8_t bBitsPerPixel;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bAspectRatioX;
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
uint8_t bVariableSize;
|
||||
};
|
||||
typedef struct IOUSBVDC_FrameBasedFormatDescriptor IOUSBVDC_FrameBasedFormatDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_FrameBasedFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwBytesPerLine;
|
||||
uint32_t dwMinFrameInterval;
|
||||
uint32_t dwMaxFrameInterval;
|
||||
uint32_t dwFrameIntervalStep;
|
||||
};
|
||||
typedef struct IOUSBVDC_FrameBasedFrameDescriptor IOUSBVDC_FrameBasedFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
#pragma pack(1)
|
||||
struct IOUSBVDC_DiscreteFrameBasedFrameDescriptor
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwBytesPerLine;
|
||||
uint32_t dwMinFrameInterval;
|
||||
uint32_t dwMaxFrameInterval;
|
||||
uint32_t dwFrameInterval[1];
|
||||
};
|
||||
typedef struct IOUSBVDC_DiscreteFrameBasedFrameDescriptor IOUSBVDC_DiscreteFrameBasedFrameDescriptor;
|
||||
#pragma options align=reset
|
||||
|
||||
@interface DecodeVideoInterfaceDescriptor : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+(void)decodeBytes:(uint8_t *)descriptor forDevice:(BusProbeDevice *)thisDevice withDeviceInterface:(IOUSBDeviceRef)deviceIntf;
|
||||
char MapNumberToVersion( int i );
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BusProberSharedFunctions.h"
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
#import "DecodeDeviceDescriptor.h"
|
||||
#import "DecodeConfigurationDescriptor.h"
|
||||
#import "DecodeInterfaceDescriptor.h"
|
||||
#import "DecodeEndpointDescriptor.h"
|
||||
#import "DecodeHIDDescriptor.h"
|
||||
#import "DecodeHubDescriptor.h"
|
||||
#import "DecodeDeviceQualifierDescriptor.h"
|
||||
#import "DecodeAudioInterfaceDescriptor.h"
|
||||
#import "DecodeVideoInterfaceDescriptor.h"
|
||||
#import "DecodeCommClassDescriptor.h"
|
||||
#import "DecodeBOSDescriptor.h"
|
||||
|
||||
#define HID_DESCRIPTOR 0x21
|
||||
#define DFU_FUNCTIONAL_DESCRIPTOR 0x21
|
||||
#define CCID_DESCRIPTOR 0x21
|
||||
|
||||
enum ClassSpecific {
|
||||
CS_INTERFACE = 0x24,
|
||||
CS_ENDPOINT = 0x25
|
||||
};
|
||||
|
||||
@interface DescriptorDecoder : NSObject {
|
||||
|
||||
}
|
||||
|
||||
+(void)decodeBytes:(Byte *)p forDevice:(BusProbeDevice *)thisDevice deviceInterface:(IOUSBDeviceRef)deviceIntf userInfo:(void *)userInfo isOtherSpeedDesc:(BOOL)isOtherSpeedDesc isinCurrentConfig:(Boolean)inCurrentConfig;
|
||||
+(void)dumpRawDescriptor:(Byte *)p forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
|
||||
+(void)dumpRawConfigDescriptor:(IOUSBConfigurationDescriptor*)cfg forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
|
||||
+(void)dump:(int)n byte:(Byte *)p forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
|
||||
+(void)dumpRawBOSDescriptor:(IOUSBBOSDescriptor*)bos forDevice:(BusProbeDevice *)thisDevice atDepth:(int)depth;
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright © 2011-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface ExtensionSelector : NSView
|
||||
{
|
||||
NSPopUpButton *extensionSelectionButton;
|
||||
NSSavePanel *theSavePanel;
|
||||
NSDictionary *itemDictionary;
|
||||
}
|
||||
@property (nonatomic, retain) NSPopUpButton *extensionSelectionButton;
|
||||
@property (nonatomic, retain) NSSavePanel *theSavePanel;
|
||||
@property (nonatomic, retain) NSDictionary *itemDictionary;
|
||||
|
||||
-(void)populatePopuButtonWithArray:(NSDictionary *)addItems;
|
||||
-(void)setCurrentSelection:(NSString *)currentSelection;
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "BusProbeDevice.h"
|
||||
|
||||
|
||||
@interface NSOutlineView(OutlineViewAdditions)
|
||||
|
||||
- (void)itemDoubleClicked;
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface OutlineViewNode : NSObject {
|
||||
NSString * _name;
|
||||
NSString * _value;
|
||||
NSMutableArray * _children;
|
||||
NSString * _tempName;
|
||||
NSString * _tempValue;
|
||||
}
|
||||
|
||||
- init;
|
||||
- initWithName:(NSString *)name value:(NSString *)value;
|
||||
- (void)dealloc;
|
||||
|
||||
|
||||
// Accessor methods for the strings
|
||||
- (NSString *)name;
|
||||
- (NSString *)value;
|
||||
- (void)setName:(NSString *)aString;
|
||||
- (void)setValue:(NSString *)aString;
|
||||
|
||||
// Accessors for the children
|
||||
- (void)addChild:(OutlineViewNode *)aNode;
|
||||
- (int)childrenCount;
|
||||
- (NSArray *)children;
|
||||
- (OutlineViewNode *)childAtIndex:(int)i;
|
||||
- (void)removeAllChildren;
|
||||
|
||||
- (void)addNode:(OutlineViewNode *)aNode atDepth:(int)depth;
|
||||
- (void)addNodeWithName:(char *)name value:(char *)value atDepth:(int)depth;
|
||||
|
||||
// Other properties
|
||||
- (BOOL)isExpandable;
|
||||
|
||||
- (OutlineViewNode *)deepestChild;
|
||||
|
||||
- (NSString*)stringRepresentation:(NSString*)name startingLevel:(int)startingLevel;
|
||||
- (NSString *)stringRepresentation:(int)startingLevel;
|
||||
- (NSString *)stringRepresentationOfValues:(int)startingLevel;
|
||||
- (NSMutableDictionary *)dictionaryVersionOfMe;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright <20> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
* file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface TableViewWithCopying : NSTableView {
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)copy:(id)sender;
|
||||
- (NSString *)stringRepresentation;
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
#import "BusProberSharedFunctions.h"
|
||||
//#import "BusProbeController.h"
|
||||
#import "BusProber.h"
|
||||
//#import "BusProbeDevice.h"
|
||||
//#import "BusProbeClass.h"
|
||||
@@ -0,0 +1,372 @@
|
||||
/*!
|
||||
\page AppleLicense
|
||||
|
||||
APPLE PUBLIC SOURCE LICENSE
|
||||
Version 2.0 - August 6, 2003
|
||||
|
||||
Please read this License carefully before downloading this software.
|
||||
By downloading or using this software, you are agreeing to be bound by
|
||||
the terms of this License. If you do not or cannot agree to the terms
|
||||
of this License, please do not download or use the software.
|
||||
|
||||
1. General; Definitions. This License applies to any program or other
|
||||
work which Apple Computer, Inc. ("Apple") makes publicly available and
|
||||
which contains a notice placed by Apple identifying such program or
|
||||
work as "Original Code" and stating that it is subject to the terms of
|
||||
this Apple Public Source License version 2.0 ("License"). As used in
|
||||
this License:
|
||||
|
||||
1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
|
||||
the grantor of rights, (i) claims of patents that are now or hereafter
|
||||
acquired, owned by or assigned to Apple and (ii) that cover subject
|
||||
matter contained in the Original Code, but only to the extent
|
||||
necessary to use, reproduce and/or distribute the Original Code
|
||||
without infringement; and (b) in the case where You are the grantor of
|
||||
rights, (i) claims of patents that are now or hereafter acquired,
|
||||
owned by or assigned to You and (ii) that cover subject matter in Your
|
||||
Modifications, taken alone or in combination with Original Code.
|
||||
|
||||
1.2 "Contributor" means any person or entity that creates or
|
||||
contributes to the creation of Modifications.
|
||||
|
||||
1.3 "Covered Code" means the Original Code, Modifications, the
|
||||
combination of Original Code and any Modifications, and/or any
|
||||
respective portions thereof.
|
||||
|
||||
1.4 "Externally Deploy" means: (a) to sublicense, distribute or
|
||||
otherwise make Covered Code available, directly or indirectly, to
|
||||
anyone other than You; and/or (b) to use Covered Code, alone or as
|
||||
part of a Larger Work, in any way to provide a service, including but
|
||||
not limited to delivery of content, through electronic communication
|
||||
with a client other than You.
|
||||
|
||||
1.5 "Larger Work" means a work which combines Covered Code or portions
|
||||
thereof with code not governed by the terms of this License.
|
||||
|
||||
1.6 "Modifications" mean any addition to, deletion from, and/or change
|
||||
to, the substance and/or structure of the Original Code, any previous
|
||||
Modifications, the combination of Original Code and any previous
|
||||
Modifications, and/or any respective portions thereof. When code is
|
||||
released as a series of files, a Modification is: (a) any addition to
|
||||
or deletion from the contents of a file containing Covered Code;
|
||||
and/or (b) any new file or other representation of computer program
|
||||
statements that contains any part of Covered Code.
|
||||
|
||||
1.7 "Original Code" means (a) the Source Code of a program or other
|
||||
work as originally made available by Apple under this License,
|
||||
including the Source Code of any updates or upgrades to such programs
|
||||
or works made available by Apple under this License, and that has been
|
||||
expressly identified by Apple as such in the header file(s) of such
|
||||
work; and (b) the object code compiled from such Source Code and
|
||||
originally made available by Apple under this License.
|
||||
|
||||
1.8 "Source Code" means the human readable form of a program or other
|
||||
work that is suitable for making modifications to it, including all
|
||||
modules it contains, plus any associated interface definition files,
|
||||
scripts used to control compilation and installation of an executable
|
||||
(object code).
|
||||
|
||||
1.9 "You" or "Your" means an individual or a legal entity exercising
|
||||
rights under this License. For legal entities, "You" or "Your"
|
||||
includes any entity which controls, is controlled by, or is under
|
||||
common control with, You, where "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of fifty percent
|
||||
(50%) or more of the outstanding shares or beneficial ownership of
|
||||
such entity.
|
||||
|
||||
2. Permitted Uses; Conditions & Restrictions. Subject to the terms
|
||||
and conditions of this License, Apple hereby grants You, effective on
|
||||
the date You accept this License and download the Original Code, a
|
||||
world-wide, royalty-free, non-exclusive license, to the extent of
|
||||
Apple's Applicable Patent Rights and copyrights covering the Original
|
||||
Code, to do the following:
|
||||
|
||||
2.1 Unmodified Code. You may use, reproduce, display, perform,
|
||||
internally distribute within Your organization, and Externally Deploy
|
||||
verbatim, unmodified copies of the Original Code, for commercial or
|
||||
non-commercial purposes, provided that in each instance:
|
||||
|
||||
(a) You must retain and reproduce in all copies of Original Code the
|
||||
copyright and other proprietary notices and disclaimers of Apple as
|
||||
they appear in the Original Code, and keep intact all notices in the
|
||||
Original Code that refer to this License; and
|
||||
|
||||
(b) You must include a copy of this License with every copy of Source
|
||||
Code of Covered Code and documentation You distribute or Externally
|
||||
Deploy, and You may not offer or impose any terms on such Source Code
|
||||
that alter or restrict this License or the recipients' rights
|
||||
hereunder, except as permitted under Section 6.
|
||||
|
||||
2.2 Modified Code. You may modify Covered Code and use, reproduce,
|
||||
display, perform, internally distribute within Your organization, and
|
||||
Externally Deploy Your Modifications and Covered Code, for commercial
|
||||
or non-commercial purposes, provided that in each instance You also
|
||||
meet all of these conditions:
|
||||
|
||||
(a) You must satisfy all the conditions of Section 2.1 with respect to
|
||||
the Source Code of the Covered Code;
|
||||
|
||||
(b) You must duplicate, to the extent it does not already exist, the
|
||||
notice in Exhibit A in each file of the Source Code of all Your
|
||||
Modifications, and cause the modified files to carry prominent notices
|
||||
stating that You changed the files and the date of any change; and
|
||||
|
||||
(c) If You Externally Deploy Your Modifications, You must make
|
||||
Source Code of all Your Externally Deployed Modifications either
|
||||
available to those to whom You have Externally Deployed Your
|
||||
Modifications, or publicly available. Source Code of Your Externally
|
||||
Deployed Modifications must be released under the terms set forth in
|
||||
this License, including the license grants set forth in Section 3
|
||||
below, for as long as you Externally Deploy the Covered Code or twelve
|
||||
(12) months from the date of initial External Deployment, whichever is
|
||||
longer. You should preferably distribute the Source Code of Your
|
||||
Externally Deployed Modifications electronically (e.g. download from a
|
||||
web site).
|
||||
|
||||
2.3 Distribution of Executable Versions. In addition, if You
|
||||
Externally Deploy Covered Code (Original Code and/or Modifications) in
|
||||
object code, executable form only, You must include a prominent
|
||||
notice, in the code itself as well as in related documentation,
|
||||
stating that Source Code of the Covered Code is available under the
|
||||
terms of this License with information on how and where to obtain such
|
||||
Source Code.
|
||||
|
||||
2.4 Third Party Rights. You expressly acknowledge and agree that
|
||||
although Apple and each Contributor grants the licenses to their
|
||||
respective portions of the Covered Code set forth herein, no
|
||||
assurances are provided by Apple or any Contributor that the Covered
|
||||
Code does not infringe the patent or other intellectual property
|
||||
rights of any other entity. Apple and each Contributor disclaim any
|
||||
liability to You for claims brought by any other entity based on
|
||||
infringement of intellectual property rights or otherwise. As a
|
||||
condition to exercising the rights and licenses granted hereunder, You
|
||||
hereby assume sole responsibility to secure any other intellectual
|
||||
property rights needed, if any. For example, if a third party patent
|
||||
license is required to allow You to distribute the Covered Code, it is
|
||||
Your responsibility to acquire that license before distributing the
|
||||
Covered Code.
|
||||
|
||||
3. Your Grants. In consideration of, and as a condition to, the
|
||||
licenses granted to You under this License, You hereby grant to any
|
||||
person or entity receiving or distributing Covered Code under this
|
||||
License a non-exclusive, royalty-free, perpetual, irrevocable license,
|
||||
under Your Applicable Patent Rights and other intellectual property
|
||||
rights (other than patent) owned or controlled by You, to use,
|
||||
reproduce, display, perform, modify, sublicense, distribute and
|
||||
Externally Deploy Your Modifications of the same scope and extent as
|
||||
Apple's licenses under Sections 2.1 and 2.2 above.
|
||||
|
||||
4. Larger Works. You may create a Larger Work by combining Covered
|
||||
Code with other code not governed by the terms of this License and
|
||||
distribute the Larger Work as a single product. In each such instance,
|
||||
You must make sure the requirements of this License are fulfilled for
|
||||
the Covered Code or any portion thereof.
|
||||
|
||||
5. Limitations on Patent License. Except as expressly stated in
|
||||
Section 2, no other patent rights, express or implied, are granted by
|
||||
Apple herein. Modifications and/or Larger Works may require additional
|
||||
patent licenses from Apple which Apple may grant in its sole
|
||||
discretion.
|
||||
|
||||
6. Additional Terms. You may choose to offer, and to charge a fee for,
|
||||
warranty, support, indemnity or liability obligations and/or other
|
||||
rights consistent with the scope of the license granted herein
|
||||
("Additional Terms") to one or more recipients of Covered Code.
|
||||
However, You may do so only on Your own behalf and as Your sole
|
||||
responsibility, and not on behalf of Apple or any Contributor. You
|
||||
must obtain the recipient's agreement that any such Additional Terms
|
||||
are offered by You alone, and You hereby agree to indemnify, defend
|
||||
and hold Apple and every Contributor harmless for any liability
|
||||
incurred by or claims asserted against Apple or such Contributor by
|
||||
reason of any such Additional Terms.
|
||||
|
||||
7. Versions of the License. Apple may publish revised and/or new
|
||||
versions of this License from time to time. Each version will be given
|
||||
a distinguishing version number. Once Original Code has been published
|
||||
under a particular version of this License, You may continue to use it
|
||||
under the terms of that version. You may also choose to use such
|
||||
Original Code under the terms of any subsequent version of this
|
||||
License published by Apple. No one other than Apple has the right to
|
||||
modify the terms applicable to Covered Code created under this
|
||||
License.
|
||||
|
||||
8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
|
||||
part pre-release, untested, or not fully tested works. The Covered
|
||||
Code may contain errors that could cause failures or loss of data, and
|
||||
may be incomplete or contain inaccuracies. You expressly acknowledge
|
||||
and agree that use of the Covered Code, or any portion thereof, is at
|
||||
Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
|
||||
WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
|
||||
APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
|
||||
PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
|
||||
ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
|
||||
MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
|
||||
PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
|
||||
PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
|
||||
INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
|
||||
FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
|
||||
THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
|
||||
ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
|
||||
ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
|
||||
AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
|
||||
You acknowledge that the Covered Code is not intended for use in the
|
||||
operation of nuclear facilities, aircraft navigation, communication
|
||||
systems, or air traffic control machines in which case the failure of
|
||||
the Covered Code could lead to death, personal injury, or severe
|
||||
physical or environmental damage.
|
||||
|
||||
9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
|
||||
EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
|
||||
TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
|
||||
ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
|
||||
TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
|
||||
APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
|
||||
REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
|
||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
|
||||
TO YOU. In no event shall Apple's total liability to You for all
|
||||
damages (other than as may be required by applicable law) under this
|
||||
License exceed the amount of fifty dollars ($50.00).
|
||||
|
||||
10. Trademarks. This License does not grant any rights to use the
|
||||
trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
|
||||
"QuickTime", "QuickTime Streaming Server" or any other trademarks,
|
||||
service marks, logos or trade names belonging to Apple (collectively
|
||||
"Apple Marks") or to any trademark, service mark, logo or trade name
|
||||
belonging to any Contributor. You agree not to use any Apple Marks in
|
||||
or as part of the name of products derived from the Original Code or
|
||||
to endorse or promote products derived from the Original Code other
|
||||
than as expressly permitted by and in strict compliance at all times
|
||||
with Apple's third party trademark usage guidelines which are posted
|
||||
at http://www.apple.com/legal/guidelinesfor3rdparties.html.
|
||||
|
||||
11. Ownership. Subject to the licenses granted under this License,
|
||||
each Contributor retains all rights, title and interest in and to any
|
||||
Modifications made by such Contributor. Apple retains all rights,
|
||||
title and interest in and to the Original Code and any Modifications
|
||||
made by or on behalf of Apple ("Apple Modifications"), and such Apple
|
||||
Modifications will not be automatically subject to this License. Apple
|
||||
may, at its sole discretion, choose to license such Apple
|
||||
Modifications under this License, or on different terms from those
|
||||
contained in this License or may choose not to license them at all.
|
||||
|
||||
12. Termination.
|
||||
|
||||
12.1 Termination. This License and the rights granted hereunder will
|
||||
terminate:
|
||||
|
||||
(a) automatically without notice from Apple if You fail to comply with
|
||||
any term(s) of this License and fail to cure such breach within 30
|
||||
days of becoming aware of such breach;
|
||||
|
||||
(b) immediately in the event of the circumstances described in Section
|
||||
13.5(b); or
|
||||
|
||||
(c) automatically without notice from Apple if You, at any time during
|
||||
the term of this License, commence an action for patent infringement
|
||||
against Apple; provided that Apple did not first commence
|
||||
an action for patent infringement against You in that instance.
|
||||
|
||||
12.2 Effect of Termination. Upon termination, You agree to immediately
|
||||
stop any further use, reproduction, modification, sublicensing and
|
||||
distribution of the Covered Code. All sublicenses to the Covered Code
|
||||
which have been properly granted prior to termination shall survive
|
||||
any termination of this License. Provisions which, by their nature,
|
||||
should remain in effect beyond the termination of this License shall
|
||||
survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
|
||||
12.2 and 13. No party will be liable to any other for compensation,
|
||||
indemnity or damages of any sort solely as a result of terminating
|
||||
this License in accordance with its terms, and termination of this
|
||||
License will be without prejudice to any other right or remedy of
|
||||
any party.
|
||||
|
||||
13. Miscellaneous.
|
||||
|
||||
13.1 Government End Users. The Covered Code is a "commercial item" as
|
||||
defined in FAR 2.101. Government software and technical data rights in
|
||||
the Covered Code include only those rights customarily provided to the
|
||||
public as defined in this License. This customary commercial license
|
||||
in technical data and software is provided in accordance with FAR
|
||||
12.211 (Technical Data) and 12.212 (Computer Software) and, for
|
||||
Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
|
||||
Commercial Items) and 227.7202-3 (Rights in Commercial Computer
|
||||
Software or Computer Software Documentation). Accordingly, all U.S.
|
||||
Government End Users acquire Covered Code with only those rights set
|
||||
forth herein.
|
||||
|
||||
13.2 Relationship of Parties. This License will not be construed as
|
||||
creating an agency, partnership, joint venture or any other form of
|
||||
legal association between or among You, Apple or any Contributor, and
|
||||
You will not represent to the contrary, whether expressly, by
|
||||
implication, appearance or otherwise.
|
||||
|
||||
13.3 Independent Development. Nothing in this License will impair
|
||||
Apple's right to acquire, license, develop, have others develop for
|
||||
it, market and/or distribute technology or products that perform the
|
||||
same or similar functions as, or otherwise compete with,
|
||||
Modifications, Larger Works, technology or products that You may
|
||||
develop, produce, market or distribute.
|
||||
|
||||
13.4 Waiver; Construction. Failure by Apple or any Contributor to
|
||||
enforce any provision of this License will not be deemed a waiver of
|
||||
future enforcement of that or any other provision. Any law or
|
||||
regulation which provides that the language of a contract shall be
|
||||
construed against the drafter will not apply to this License.
|
||||
|
||||
13.5 Severability. (a) If for any reason a court of competent
|
||||
jurisdiction finds any provision of this License, or portion thereof,
|
||||
to be unenforceable, that provision of the License will be enforced to
|
||||
the maximum extent permissible so as to effect the economic benefits
|
||||
and intent of the parties, and the remainder of this License will
|
||||
continue in full force and effect. (b) Notwithstanding the foregoing,
|
||||
if applicable law prohibits or restricts You from fully and/or
|
||||
specifically complying with Sections 2 and/or 3 or prevents the
|
||||
enforceability of either of those Sections, this License will
|
||||
immediately terminate and You must immediately discontinue any use of
|
||||
the Covered Code and destroy all copies of it that are in your
|
||||
possession or control.
|
||||
|
||||
13.6 Dispute Resolution. Any litigation or other dispute resolution
|
||||
between You and Apple relating to this License shall take place in the
|
||||
Northern District of California, and You and Apple hereby consent to
|
||||
the personal jurisdiction of, and venue in, the state and federal
|
||||
courts within that District with respect to this License. The
|
||||
application of the United Nations Convention on Contracts for the
|
||||
International Sale of Goods is expressly excluded.
|
||||
|
||||
13.7 Entire Agreement; Governing Law. This License constitutes the
|
||||
entire agreement between the parties with respect to the subject
|
||||
matter hereof. This License shall be governed by the laws of the
|
||||
United States and the State of California, except that body of
|
||||
California law concerning conflicts of law.
|
||||
|
||||
Where You are located in the province of Quebec, Canada, the following
|
||||
clause applies: The parties hereby confirm that they have requested
|
||||
that this License and all related documents be drafted in English. Les
|
||||
parties ont exige que le present contrat et tous les documents
|
||||
connexes soient rediges en anglais.
|
||||
|
||||
EXHIBIT A.
|
||||
|
||||
"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
|
||||
Reserved.
|
||||
|
||||
This file contains Original Code and/or Modifications of Original Code
|
||||
as defined in and that are subject to the Apple Public Source License
|
||||
Version 2.0 (the 'License'). You may not use this file except in
|
||||
compliance with the License. Please obtain a copy of the License at
|
||||
http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
file.
|
||||
|
||||
The Original Code and all software distributed under the License are
|
||||
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
Please see the License for the specific language governing rights and
|
||||
limitations under the License."
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>17F77</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>USBBusProber</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.Vidvox.USBBusProber</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>USBBusProber</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>9C40b</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>17C76</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.13</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0920</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>9C40b</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2014 Vidvox. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
src/mynteye/uvc/macosx/USBBusProber.framework/Versions/A/USBBusProber
Executable file
BIN
src/mynteye/uvc/macosx/USBBusProber.framework/Versions/A/USBBusProber
Executable file
Binary file not shown.
1
src/mynteye/uvc/macosx/USBBusProber.framework/Versions/Current
Symbolic link
1
src/mynteye/uvc/macosx/USBBusProber.framework/Versions/Current
Symbolic link
@@ -0,0 +1 @@
|
||||
A
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright <EFBFBD> 1998-2012 Apple Inc. All rights reserved.
|
||||
* Copyright <EFBFBD> 1998-2012 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_LICENSE_HEADER_START@
|
||||
*
|
||||
|
||||
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Headers
Symbolic link
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Headers
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Resources
Symbolic link
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Resources
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
1
src/mynteye/uvc/macosx/VVUVCKit.framework/VVUVCKit
Symbolic link
1
src/mynteye/uvc/macosx/VVUVCKit.framework/VVUVCKit
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/VVUVCKit
|
||||
@@ -0,0 +1,405 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOMessage.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#include <IOKit/usb/IOUSBLib.h>
|
||||
#import <USBBusProber/USBBusProber.h>
|
||||
//#import <QTKit/QTKit.h>
|
||||
#import "VVUVCKitStringAdditions.h"
|
||||
|
||||
/**
|
||||
\defgroup VVUVCController
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
@protocol VVUVCControllerDelegate
|
||||
- (void) VVUVCControllerParamsUpdated:(id)c;
|
||||
@end
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\ingroup VVUVCController
|
||||
Auto-exposure modes described by the USB spec, put in a typedef/enum for convenience
|
||||
*/
|
||||
typedef enum {
|
||||
UVC_AEMode_Undefined = 0x00, /// undefined auto exposure mode
|
||||
UVC_AEMode_Manual = 0x01, /// manual exposure, manual iris
|
||||
UVC_AEMode_Auto = 0x02, /// auto exposure, auto iris
|
||||
UVC_AEMode_ShutterPriority = 0x04, /// manual exposure, auto iris
|
||||
UVC_AEMode_AperturePriority = 0x08 /// auto exposure, manual iris
|
||||
} UVC_AEMode;
|
||||
|
||||
|
||||
/* this struct contains all the info necessary to get/set vals from a video control parameter (either terminal/hardware or
|
||||
processing/software)- but it does not contain info about the value at all! think of this struct as a sort of function
|
||||
description for the hardware which will be sent out directly via USB. instances of this struct are populated by values
|
||||
from the USB specification! */
|
||||
typedef struct {
|
||||
int unit; // describes whether terminal/hardware or processing/software
|
||||
int selector; // the address of the "parameter" being changed-
|
||||
int intendedSize;
|
||||
BOOL hasMin; // whether or not the video control parameter described by this struct has a min val
|
||||
BOOL hasMax; // whether or not the video control parameter described by this struct has a max
|
||||
BOOL hasDef; // whether or not the video control parameter described by this struct has a default
|
||||
BOOL isSigned; // whether or not the video control parameter described by this struct is a signed val
|
||||
BOOL isRelative; // whether or not the video control parameter described by this struct is a relative val
|
||||
} uvc_control_info_t;
|
||||
|
||||
|
||||
/* these variables contain enough info to send data to/get data from the implied attribute. the
|
||||
variables are global to the class (the contents won't change from instance to instance), and
|
||||
conceptually act like function descriptions (instances of this class can pass references to these
|
||||
variables, which can be used to get/set values). these are populated when the class is
|
||||
initialized by values described in the USB specification. if uvc_control_info_t is a function
|
||||
description, these variables are essentially pointers to a bunch of different functions. */
|
||||
extern uvc_control_info_t _scanCtrl;
|
||||
extern uvc_control_info_t _autoExposureModeCtrl;
|
||||
extern uvc_control_info_t _autoExposurePriorityCtrl;
|
||||
extern uvc_control_info_t _exposureTimeCtrl;
|
||||
extern uvc_control_info_t _irisCtrl;
|
||||
extern uvc_control_info_t _autoFocusCtrl;
|
||||
extern uvc_control_info_t _focusCtrl;
|
||||
extern uvc_control_info_t _zoomCtrl;
|
||||
extern uvc_control_info_t _panTiltCtrl;
|
||||
extern uvc_control_info_t _panTiltRelCtrl;
|
||||
extern uvc_control_info_t _rollCtrl;
|
||||
extern uvc_control_info_t _rollRelCtrl;
|
||||
|
||||
extern uvc_control_info_t _backlightCtrl;
|
||||
extern uvc_control_info_t _brightCtrl;
|
||||
extern uvc_control_info_t _contrastCtrl;
|
||||
extern uvc_control_info_t _gainCtrl;
|
||||
extern uvc_control_info_t _powerLineCtrl;
|
||||
extern uvc_control_info_t _autoHueCtrl;
|
||||
extern uvc_control_info_t _hueCtrl;
|
||||
extern uvc_control_info_t _saturationCtrl;
|
||||
extern uvc_control_info_t _sharpnessCtrl;
|
||||
extern uvc_control_info_t _gammaCtrl;
|
||||
extern uvc_control_info_t _whiteBalanceAutoTempCtrl;
|
||||
extern uvc_control_info_t _whiteBalanceTempCtrl;
|
||||
|
||||
|
||||
/* this struct describes a parameter- it contains a pointer to the control info that describes
|
||||
which parameter, as well as the min/max/default/current value. an instance of this struct will
|
||||
contain the value of the parameter and the uvc_control_info_t struct necessary to communicate with
|
||||
this parameter in a camera. */
|
||||
typedef struct {
|
||||
BOOL supported; // if YES, this parameter is supported. if NO, either the camera doesn't support this parameter, or the "inputTerminalID" or "processingUnitID" of the camera is wrong!
|
||||
long min; // the paramter's actual min val
|
||||
long max; // the parameter's actual max val
|
||||
long val; // the parameter's actual val
|
||||
long def; // the parameter's default val
|
||||
int actualSize;
|
||||
uvc_control_info_t *ctrlInfo;
|
||||
} uvc_param;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// An instance of VVUVCController will control the UVC params for a single USB video device. This is probably the only class you'll have to create or work with in this framework.
|
||||
/**
|
||||
\ingroup VVUVCController
|
||||
This is probably the only class you'll have to work with in this framework. The basic idea is that you create a VVUVCController for an enabled USB video device, and then either tell the controller to open its settings window or interact with it programmatically. If you're looking for a more "embedded" feel, you can remove the VVUVCController's "settingsView" from its superview and add it into your application's NSView hierarchy.
|
||||
*/
|
||||
@interface VVUVCController : NSObject {
|
||||
IOUSBInterfaceInterface190 **interface;
|
||||
UInt32 deviceLocationID;
|
||||
UInt8 interfaceNumber; // pulled from interface on generalInit!
|
||||
int inputTerminalID; // the "address" of the terminal unit, which handles hardware controls like aperture/focus. if this val is wrong, the hardware controls won't be available.
|
||||
int processingUnitID; // the "address" of the processing unit, which handles software controls like contrast/hue. if this val is wrong, the software controls won't be available.
|
||||
|
||||
//id <VVUVCControllerDelegate>delegate;
|
||||
uvc_param scanningMode;
|
||||
uvc_param autoExposureMode; // mode functionality described by the type UVC_AEMode
|
||||
uvc_param autoExposurePriority; // if 1, framerate may be varied. if 0, framerate must remain constant.
|
||||
uvc_param exposureTime;
|
||||
uvc_param iris;
|
||||
uvc_param autoFocus;
|
||||
uvc_param focus;
|
||||
uvc_param zoom;
|
||||
uvc_param panTilt;
|
||||
uvc_param panTiltRel;
|
||||
uvc_param roll;
|
||||
uvc_param rollRel;
|
||||
|
||||
uvc_param backlight;
|
||||
uvc_param bright;
|
||||
uvc_param contrast;
|
||||
uvc_param gain;
|
||||
uvc_param powerLine;
|
||||
uvc_param autoHue;
|
||||
uvc_param hue;
|
||||
uvc_param saturation;
|
||||
uvc_param sharpness;
|
||||
uvc_param gamma;
|
||||
uvc_param autoWhiteBalance;
|
||||
uvc_param whiteBalance;
|
||||
|
||||
// this class has its own .nib which contains a UI for interacting with the class that may be opened directly in a window, or accessed as an NSView instance for use in other UIs/software
|
||||
NSNib *theNib;
|
||||
NSArray *nibTopLevelObjects;
|
||||
|
||||
IBOutlet id uiCtrlr; // created & owned by the nib!
|
||||
IBOutlet NSWindow *settingsWindow; // by default, the UI is in a window (it's easiest to just open and close it)
|
||||
IBOutlet NSView *settingsView; // you can also access the view which contains the UI so you can embed it in other apps
|
||||
}
|
||||
|
||||
/// Use this method to init an instance of VVUVCController from an NSString returned by the AVFoundation or QTCapture APIs as the device's unique ID.
|
||||
/**
|
||||
@param n The "deviceIDString" is a string returned by QuickTime and AVFoundation as the unique ID for the USB video device. Technically, this is a hex value with sixteen digits (16 hex digits = an unsigned 64-bit integer). The first 8 hex digits is the USB device's "locationID", the next 4 hex digits is the device's vendor ID, and the last 4 digits are the device's product ID. Only the locationID is needed to create the necessary USB interfaces...
|
||||
*/
|
||||
- (id) initWithDeviceIDString:(NSString *)n;
|
||||
/// Use this method to init an instance of VVUVCController from the USB location ID.
|
||||
/**
|
||||
@param locationID The location ID of the USB device you want this instance of VVUVCController to control.
|
||||
*/
|
||||
- (id) initWithLocationID:(UInt32)locationID;
|
||||
- (IOUSBInterfaceInterface190 **) _getControlInferaceWithDeviceInterface:(IOUSBDeviceInterface **)deviceInterface;
|
||||
- (void) generalInit;
|
||||
|
||||
/// Returns a mutable dict representing the current state of the video input parameters
|
||||
- (NSMutableDictionary *) createSnapshot;
|
||||
/// Loads a saved state dict created with the "createSnapshot" method
|
||||
- (void) loadSnapshot:(NSDictionary *)s;
|
||||
|
||||
- (BOOL) _sendControlRequest:(IOUSBDevRequest *)controlRequest;
|
||||
- (int) _requestValType:(int)requestType forControl:(const uvc_control_info_t *)ctrl returnVal:(void **)ret;
|
||||
- (BOOL) _setBytes:(void *)bytes sized:(int)size toControl:(const uvc_control_info_t *)ctrl;
|
||||
- (void) _populateAllParams; // populates all the uvc_param variables in this instance, loading their min/max/default vals and determining if they're supported or not
|
||||
- (void) _populateParam:(uvc_param *)param;
|
||||
- (BOOL) _pushParamToDevice:(uvc_param *)param;
|
||||
- (void) _resetParamToDefault:(uvc_param *)param;
|
||||
|
||||
/// Resets the parameters to their default values. The default values are supplied by/stored in the device.
|
||||
- (void) resetParamsToDefaults;
|
||||
/// Opens a window with a GUI for interacting with the camera parameters
|
||||
- (void) openSettingsWindow;
|
||||
/// Closes the GUI window (if it's open).
|
||||
- (void) closeSettingsWindow;
|
||||
|
||||
- (void) setInterlaced:(BOOL)n;
|
||||
- (BOOL) interlaced;
|
||||
- (BOOL) interlacedSupported;
|
||||
- (void) resetInterlaced;
|
||||
/// Sets the auto exposure mode using one of the basic auto exposure modes defined in the header (vals pulled from the USB spec)
|
||||
- (void) setAutoExposureMode:(UVC_AEMode)n;
|
||||
/// Gets the auto exposure mode
|
||||
- (UVC_AEMode) autoExposureMode;
|
||||
/// Whether or not this camera supports the use of alternate auto exposure modes
|
||||
- (BOOL) autoExposureModeSupported;
|
||||
/// Resets the auto exposure mode to the hardware-defined default
|
||||
- (void) resetAutoExposureMode;
|
||||
/// Sets whether or not auto exposure will be given priority
|
||||
- (void) setAutoExposurePriority:(BOOL)n;
|
||||
/// Gets whether or not the camera is giving auto exposure priority
|
||||
- (BOOL) autoExposurePriority;
|
||||
/// Whether or not this camera supports the use of auto exposure priority
|
||||
- (BOOL) autoExposurePrioritySupported;
|
||||
/// Resets the auto exposure priority to the hardware-defined default
|
||||
- (void) resetAutoExposurePriority;
|
||||
|
||||
/// Sets the exposure time to the passed value
|
||||
- (void) setExposureTime:(long)n;
|
||||
/// Gets the current exposure time value being used by the camera
|
||||
- (long) exposureTime;
|
||||
/// Whether or not this camera supports the exposure time parameter
|
||||
- (BOOL) exposureTimeSupported;
|
||||
/// Resets the exposure time value to the hardware-defined default
|
||||
- (void) resetExposureTime;
|
||||
/// The min exposure time value
|
||||
- (long) minExposureTime;
|
||||
/// The max exposure time value
|
||||
- (long) maxExposureTime;
|
||||
/// Sets the iris to the passed value
|
||||
- (void) setIris:(long)n;
|
||||
/// Gets the current iris value being used by the camera
|
||||
- (long) iris;
|
||||
/// Whether or not this camera supports the iris parameter
|
||||
- (BOOL) irisSupported;
|
||||
/// Resets the iris value to the hardware-defined default
|
||||
- (void) resetIris;
|
||||
/// The min iris value
|
||||
- (long) minIris;
|
||||
/// The max iris value
|
||||
- (long) maxIris;
|
||||
/// Sets the auto focus to the passed value
|
||||
- (void) setAutoFocus:(BOOL)n;
|
||||
/// Gets the auto focus value being used by the camera
|
||||
- (BOOL) autoFocus;
|
||||
/// Whether or not this camera supports the auto focus parameter
|
||||
- (BOOL) autoFocusSupported;
|
||||
/// Resets the auto focus value to the hardware-defined default.
|
||||
- (void) resetAutoFocus;
|
||||
/// Sets the focus value
|
||||
- (void) setFocus:(long)n;
|
||||
/// Gets the focus value currently being used by the camera
|
||||
- (long) focus;
|
||||
/// Whether or not this camera supports the focus parameter
|
||||
- (BOOL) focusSupported;
|
||||
/// Resets the focus value to the hardware-defined default
|
||||
- (void) resetFocus;
|
||||
/// The min focus value
|
||||
- (long) minFocus;
|
||||
/// The max focus value
|
||||
- (long) maxFocus;
|
||||
/// Sets the zoom value
|
||||
- (void) setZoom:(long)n;
|
||||
/// Gets the current zoom value being used by the camera
|
||||
- (long) zoom;
|
||||
/// Whether or not this camera supports the zoom parameter
|
||||
- (BOOL) zoomSupported;
|
||||
/// Resets the zoom value to the hardware-defined default
|
||||
- (void) resetZoom;
|
||||
/// The min zoom value
|
||||
- (long) minZoom;
|
||||
/// The max zoom value
|
||||
- (long) maxZoom;
|
||||
|
||||
// pan/tilt/roll aren't enabled
|
||||
- (BOOL) panSupported;
|
||||
- (BOOL) tiltSupported;
|
||||
- (BOOL) rollSupported;
|
||||
|
||||
/// Sets the backlight to the passed value
|
||||
- (void) setBacklight:(long)n;
|
||||
/// Gets the backlight value currently being used by the camera
|
||||
- (long) backlight;
|
||||
/// Whether or not this camera supports the backlight parameter
|
||||
- (BOOL) backlightSupported;
|
||||
/// Resets the backlight value to the hardware-defined default
|
||||
- (void) resetBacklight;
|
||||
/// The min backlight value
|
||||
- (long) minBacklight;
|
||||
/// The max backlight value
|
||||
- (long) maxBacklight;
|
||||
/// Sets the bright value to the passed value
|
||||
- (void) setBright:(long)n;
|
||||
/// Gets the bright value currently being used by the camera
|
||||
- (long) bright;
|
||||
/// Whether or not this camera supports the bright parameter
|
||||
- (BOOL) brightSupported;
|
||||
/// Resets the bright parameter to the hardware-defined default
|
||||
- (void) resetBright;
|
||||
/// The min bright value
|
||||
- (long) minBright;
|
||||
/// The max bright value
|
||||
- (long) maxBright;
|
||||
/// Sets the contrast to the passed value
|
||||
- (void) setContrast:(long)n;
|
||||
/// Gets the contrast value currently being used by the camera
|
||||
- (long) contrast;
|
||||
/// Whether or not this camera supports the contrast parameter
|
||||
- (BOOL) contrastSupported;
|
||||
/// Resets the contrast to the hardware-defined default
|
||||
- (void) resetContrast;
|
||||
/// The min contrast value
|
||||
- (long) minContrast;
|
||||
/// The max contrast value
|
||||
- (long) maxContrast;
|
||||
/// Sets the gain to the passed value
|
||||
- (void) setGain:(long)n;
|
||||
/// Gets the gain value currently being used by the camera
|
||||
- (long) gain;
|
||||
/// Whether or not this camera supports the gain parameter
|
||||
- (BOOL) gainSupported;
|
||||
/// Resets the gain value to the hardware-defined default
|
||||
- (void) resetGain;
|
||||
/// The min gain value
|
||||
- (long) minGain;
|
||||
/// The max gain value
|
||||
- (long) maxGain;
|
||||
/// Sets the powerline to the passed value
|
||||
- (void) setPowerLine:(long)n;
|
||||
/// Gets the powerline value currently being used by the camera
|
||||
- (long) powerLine;
|
||||
/// Whether or not this camera supports the powerline parameter
|
||||
- (BOOL) powerLineSupported;
|
||||
/// Resets the powerline value to the hardware-defined default
|
||||
- (void) resetPowerLine;
|
||||
/// The min powerline value
|
||||
- (long) minPowerLine;
|
||||
/// The max powerline value
|
||||
- (long) maxPowerLine;
|
||||
/// Sets the auto hue to the passed value
|
||||
- (void) setAutoHue:(BOOL)n;
|
||||
/// The auto hue value currently being used by the camera
|
||||
- (BOOL) autoHue;
|
||||
/// Whether or not this camera supports the auto hue parameter
|
||||
- (BOOL) autoHueSupported;
|
||||
/// Resets the auto hue parameter to the hardware-defined default
|
||||
- (void) resetAutoHue;
|
||||
/// Sets the hue to the passed value
|
||||
- (void) setHue:(long)n;
|
||||
/// Gets the hue value currently being used by the camera
|
||||
- (long) hue;
|
||||
/// Whether or not this camera supports the hue parameter
|
||||
- (BOOL) hueSupported;
|
||||
/// Resets the hue parameter to the hardware-defined default
|
||||
- (void) resetHue;
|
||||
/// The min hue value
|
||||
- (long) minHue;
|
||||
/// The max hue value
|
||||
- (long) maxHue;
|
||||
/// Sets the saturation to the passed value
|
||||
- (void) setSaturation:(long)n;
|
||||
/// Gets the saturation value currently being used by the camera
|
||||
- (long) saturation;
|
||||
/// Whether or not this camera supports the saturation parameter
|
||||
- (BOOL) saturationSupported;
|
||||
/// Resets the saturation to the hardware-defined default
|
||||
- (void) resetSaturation;
|
||||
/// The min saturation value
|
||||
- (long) minSaturation;
|
||||
/// The max saturation value
|
||||
- (long) maxSaturation;
|
||||
/// Sets the sharpness to the passed value
|
||||
- (void) setSharpness:(long)n;
|
||||
/// Gets the sharpness value currently being used by the camera
|
||||
- (long) sharpness;
|
||||
/// Whether or not this camera supports the sharpness parameter
|
||||
- (BOOL) sharpnessSupported;
|
||||
/// Resets the sharpness to the hardware-defined default
|
||||
- (void) resetSharpness;
|
||||
/// The min sharpness value
|
||||
- (long) minSharpness;
|
||||
/// The max sharpness value
|
||||
- (long) maxSharpness;
|
||||
/// Sets the gamma to the passed value
|
||||
- (void) setGamma:(long)n;
|
||||
/// Gets the gamma value currently being used by the camera
|
||||
- (long) gamma;
|
||||
/// Whether or not this camera supports the gamma parameter
|
||||
- (BOOL) gammaSupported;
|
||||
/// Resets the gamma value to the hardware-defined default
|
||||
- (void) resetGamma;
|
||||
/// The min gamma value
|
||||
- (long) minGamma;
|
||||
/// The max gamma value
|
||||
- (long) maxGamma;
|
||||
/// Sets the auto white balance to the passed value
|
||||
- (void) setAutoWhiteBalance:(BOOL)n;
|
||||
/// Gets the auto white balance value currently being used by the camera
|
||||
- (BOOL) autoWhiteBalance;
|
||||
/// Whether or not this camera supports the auto white balance parameter
|
||||
- (BOOL) autoWhiteBalanceSupported;
|
||||
/// Resets the auto white balance to the hardware-defined default
|
||||
- (void) resetAutoWhiteBalance;
|
||||
/// Sets the white balance to the passed value
|
||||
- (void) setWhiteBalance:(long)n;
|
||||
/// Gets the white balance value currently being used by the camera
|
||||
- (long) whiteBalance;
|
||||
/// Whether or not this camera supports the white balance parameter
|
||||
- (BOOL) whiteBalanceSupported;
|
||||
/// Resets the white balance value to the hardware-defined default
|
||||
- (void) resetWhiteBalance;
|
||||
/// The min white balance value
|
||||
- (long) minWhiteBalance;
|
||||
/// The max white balance value
|
||||
- (long) maxWhiteBalance;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
// this is the only class you should need to explicitly instantiate!
|
||||
#import "VVUVCController.h"
|
||||
@@ -0,0 +1,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSString (VVUVCKitStringAdditions)
|
||||
|
||||
- (BOOL) containsString:(NSString *)n;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,44 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "VVUVCUIElement.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@interface VVUVCUIController : NSObject <VVUVCUIElementDelegate> {
|
||||
IBOutlet id device;
|
||||
|
||||
IBOutlet NSPopUpButton *autoExpButton;
|
||||
IBOutlet NSButton *expPriorityButton;
|
||||
IBOutlet NSButton *autoFocusButton;
|
||||
//IBOutlet NSSlider *panSlider;
|
||||
//IBOutlet NSSlider *tiltSlider;
|
||||
//IBOutlet NSSlider *rollSlider;
|
||||
|
||||
IBOutlet NSButton *autoHueButton;
|
||||
IBOutlet NSButton *autoWBButton;
|
||||
|
||||
IBOutlet VVUVCUIElement *expElement;
|
||||
IBOutlet VVUVCUIElement *irisElement;
|
||||
IBOutlet VVUVCUIElement *focusElement;
|
||||
IBOutlet VVUVCUIElement *zoomElement;
|
||||
|
||||
IBOutlet VVUVCUIElement *backlightElement;
|
||||
IBOutlet VVUVCUIElement *brightElement;
|
||||
IBOutlet VVUVCUIElement *contrastElement;
|
||||
IBOutlet VVUVCUIElement *powerElement;
|
||||
IBOutlet VVUVCUIElement *gammaElement;
|
||||
IBOutlet VVUVCUIElement *hueElement;
|
||||
IBOutlet VVUVCUIElement *satElement;
|
||||
IBOutlet VVUVCUIElement *sharpElement;
|
||||
IBOutlet VVUVCUIElement *gainElement;
|
||||
IBOutlet VVUVCUIElement *wbElement;
|
||||
}
|
||||
|
||||
- (IBAction) buttonUsed:(id)sender;
|
||||
- (IBAction) popUpButtonUsed:(id)sender;
|
||||
|
||||
- (IBAction) resetToDefaults:(id)sender;
|
||||
|
||||
- (void) _pushCameraControlStateToUI;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
|
||||
|
||||
@protocol VVUVCUIElementDelegate
|
||||
- (void) controlElementChanged:(id)sender;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@interface VVUVCUIElement : NSBox {
|
||||
IBOutlet id delegate;
|
||||
|
||||
BOOL enabled;
|
||||
NSSlider *valSlider;
|
||||
NSTextField *valField;
|
||||
|
||||
int val;
|
||||
int min;
|
||||
int max;
|
||||
}
|
||||
|
||||
- (void) setEnabled:(BOOL)n;
|
||||
|
||||
- (void) _resizeContents;
|
||||
|
||||
- (void) uiItemUsed:(id)sender;
|
||||
|
||||
@property (assign,readwrite) id delegate;
|
||||
@property (assign,readwrite) int val;
|
||||
@property (assign,readwrite) int min;
|
||||
@property (assign,readwrite) int max;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>17F77</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>VVUVCKit</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.Vidvox.VVUVCKit</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>VVUVCKit</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>9C40b</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>17C76</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.13</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0920</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>9C40b</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2014 Vidvox. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/A/Resources/VVUVCController.nib
generated
Normal file
BIN
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/A/Resources/VVUVCController.nib
generated
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/A/VVUVCKit
Executable file
BIN
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/A/VVUVCKit
Executable file
Binary file not shown.
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/Current
Symbolic link
1
src/mynteye/uvc/macosx/VVUVCKit.framework/Versions/Current
Symbolic link
@@ -0,0 +1 @@
|
||||
A
|
||||
90
src/mynteye/uvc/macosx/uvc-vvuvckit.cc
Normal file
90
src/mynteye/uvc/macosx/uvc-vvuvckit.cc
Normal file
@@ -0,0 +1,90 @@
|
||||
// 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 <thread>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include "mynteye/logger.h"
|
||||
#include "mynteye/uvc/uvc.h"
|
||||
#include "libuvc/libuvc.h"
|
||||
#include "AVfoundationCamera.h"
|
||||
|
||||
// #define ENABLE_DEBUG_SPAM
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace uvc {
|
||||
|
||||
// Enumerate devices
|
||||
MYNTEYE_API std::shared_ptr<context> create_context() {
|
||||
//too
|
||||
}
|
||||
MYNTEYE_API std::vector<std::shared_ptr<device>> query_devices(
|
||||
std::shared_ptr<context> context) {
|
||||
//todo
|
||||
}
|
||||
|
||||
// Static device properties
|
||||
MYNTEYE_API std::string get_name(const device &device) {
|
||||
//todo
|
||||
}
|
||||
MYNTEYE_API int get_vendor_id(const device &device) {
|
||||
//todo
|
||||
}
|
||||
MYNTEYE_API int get_product_id(const device &device) {
|
||||
//todo
|
||||
}
|
||||
|
||||
MYNTEYE_API std::string get_video_name(const device &device) {
|
||||
//todo
|
||||
}
|
||||
|
||||
MYNTEYE_API bool pu_control_range(
|
||||
const device &device, Option option, int32_t *min, int32_t *max,
|
||||
int32_t *def) {
|
||||
// todo
|
||||
}
|
||||
MYNTEYE_API bool pu_control_query(
|
||||
const device &device, Option option, pu_query query, int32_t *value) {
|
||||
// todo
|
||||
}
|
||||
|
||||
// Access XU (Extension Unit) controls
|
||||
MYNTEYE_API bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id,
|
||||
int32_t *min, int32_t *max, int32_t *def) {
|
||||
//todo
|
||||
}
|
||||
MYNTEYE_API bool xu_control_query( // XU_QUERY_SET, XU_QUERY_GET
|
||||
const device &device, const xu &xu, uint8_t selector, xu_query query,
|
||||
uint16_t size, uint8_t *data) {
|
||||
//todo
|
||||
}
|
||||
|
||||
MYNTEYE_API void set_device_mode(
|
||||
device &device, int width, int height, int fourcc, int fps, // NOLINT
|
||||
video_channel_callback callback) {
|
||||
//todo
|
||||
}
|
||||
MYNTEYE_API void start_streaming(device &device, int num_transfer_bufs) {
|
||||
//todo
|
||||
}
|
||||
MYNTEYE_API void stop_streaming(device &device) {
|
||||
//todo
|
||||
}
|
||||
|
||||
} // namespace uvc
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
@@ -64,7 +64,8 @@ namespace uvc {
|
||||
|
||||
const std::map<uint32_t, uint32_t> fourcc_map = {
|
||||
{ 0x56595559, 0x32595559 }, // 'VYUY' => '2YUY'
|
||||
{ 0x59555956, 0x59555932 } // 'YUYV' => 'YUY2'
|
||||
{ 0x59555956, 0x59555932 }, // 'YUYV' => 'YUY2'
|
||||
{ 0x33524742, 0x14 }
|
||||
};
|
||||
|
||||
struct throw_error {
|
||||
@@ -756,6 +757,7 @@ void set_device_mode(device &device, int width, int height, int fourcc, int fps,
|
||||
check("IMFMediaType::GetGUID", media_type->GetGUID(MF_MT_SUBTYPE, &subtype));
|
||||
if (subtype.Data1 != fourcc) continue;
|
||||
|
||||
check("MFSetAttributeRatio", MFSetAttributeRatio(media_type, MF_MT_FRAME_RATE, fps, 1));
|
||||
check("MFGetAttributeRatio", MFGetAttributeRatio(media_type, MF_MT_FRAME_RATE, &uvc_fps_num, &uvc_fps_denom));
|
||||
if (uvc_fps_denom == 0) continue;
|
||||
//int uvc_fps = uvc_fps_num / uvc_fps_denom;
|
||||
|
||||
41
src/public/miniglog.cc
Normal file
41
src/public/miniglog.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
// Ceres Solver - A fast non-linear least squares minimizer
|
||||
// Copyright 2012 Google Inc. All rights reserved.
|
||||
// http://code.google.com/p/ceres-solver/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its contributors may be
|
||||
// used to endorse or promote products derived from this software without
|
||||
// specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: keir@google.com (Keir Mierle)
|
||||
|
||||
#include "mynteye/miniglog.h"
|
||||
|
||||
namespace google {
|
||||
|
||||
// This is the set of log sinks. This must be in a separate library to ensure
|
||||
// that there is only one instance of this across the entire program.
|
||||
std::set<google::LogSink *> log_sinks_global;
|
||||
|
||||
int log_severity_global(INFO);
|
||||
|
||||
} // namespace google
|
||||
3
src/public/miniglog.readme
Normal file
3
src/public/miniglog.readme
Normal file
@@ -0,0 +1,3 @@
|
||||
miniglog:
|
||||
* https://github.com/arpg/miniglog
|
||||
* https://github.com/tzutalin/miniglog
|
||||
199
src/uvc/uvc-libuvc.cc
Normal file
199
src/uvc/uvc-libuvc.cc
Normal file
@@ -0,0 +1,199 @@
|
||||
// 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 "uvc/uvc.h" // NOLINT
|
||||
|
||||
#include <libuvc/libuvc.h>
|
||||
|
||||
#include "mynteye/logger.h"
|
||||
// #define ENABLE_DEBUG_SPAM
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace uvc {
|
||||
|
||||
static void check(const char *call, uvc_error_t status) {
|
||||
LOG_IF(FATAL, status < 0)
|
||||
<< call << "(...) returned " << uvc_strerror(status);
|
||||
}
|
||||
#define CALL_UVC(name, ...) check(#name, name(__VA_ARGS__))
|
||||
|
||||
struct context {
|
||||
uvc_context_t *ctx;
|
||||
|
||||
context() : ctx(nullptr) {
|
||||
VLOG(2) << __func__;
|
||||
CALL_UVC(uvc_init, &ctx, nullptr);
|
||||
}
|
||||
|
||||
~context() {
|
||||
VLOG(2) << __func__;
|
||||
if (ctx)
|
||||
uvc_exit(ctx);
|
||||
}
|
||||
};
|
||||
|
||||
struct device {
|
||||
const std::shared_ptr<context> parent;
|
||||
|
||||
uvc_device_t *uvcdevice = nullptr;
|
||||
uvc_device_handle_t *handle = nullptr;
|
||||
|
||||
int vid, pid;
|
||||
|
||||
device(std::shared_ptr<context> parent, uvc_device_t *uvcdevice)
|
||||
: parent(parent), uvcdevice(uvcdevice) {
|
||||
VLOG(2) << __func__;
|
||||
open();
|
||||
|
||||
uvc_device_descriptor_t *desc;
|
||||
CALL_UVC(uvc_get_device_descriptor, uvcdevice, &desc);
|
||||
vid = desc->idVendor;
|
||||
pid = desc->idProduct;
|
||||
uvc_free_device_descriptor(desc);
|
||||
}
|
||||
|
||||
~device() {
|
||||
VLOG(2) << __func__;
|
||||
if (handle)
|
||||
uvc_close(handle);
|
||||
if (uvcdevice)
|
||||
uvc_unref_device(uvcdevice);
|
||||
}
|
||||
|
||||
void open() {
|
||||
if (!handle)
|
||||
CALL_UVC(uvc_open, uvcdevice, &handle);
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<context> create_context() {
|
||||
return std::make_shared<context>();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<device>> query_devices(
|
||||
std::shared_ptr<context> context) {
|
||||
std::vector<std::shared_ptr<device>> devices;
|
||||
|
||||
uvc_device_t **list;
|
||||
CALL_UVC(uvc_get_device_list, context->ctx, &list);
|
||||
for (auto it = list; *it; ++it) {
|
||||
try {
|
||||
auto dev = std::make_shared<device>(context, *it);
|
||||
devices.push_back(dev);
|
||||
} catch (std::runtime_error &e) {
|
||||
LOG(WARNING) << "usb:" << static_cast<int>(uvc_get_bus_number(*it)) << ':'
|
||||
<< static_cast<int>(uvc_get_device_address(*it)) << ": "
|
||||
<< e.what();
|
||||
}
|
||||
}
|
||||
uvc_free_device_list(list, 1);
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
int get_vendor_id(const device &device) {
|
||||
return device.vid;
|
||||
}
|
||||
|
||||
int get_product_id(const device &device) {
|
||||
return device.pid;
|
||||
}
|
||||
|
||||
std::string get_name(const device &device) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string get_video_name(const device &device) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
return "";
|
||||
}
|
||||
|
||||
bool pu_control_range(
|
||||
const device &device, Option option, int32_t *min, int32_t *max,
|
||||
int32_t *def) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(option)
|
||||
UNUSED(min)
|
||||
UNUSED(max)
|
||||
UNUSED(def)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pu_control_query(
|
||||
const device &device, Option option, pu_query query, int32_t *value) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(option)
|
||||
UNUSED(query)
|
||||
UNUSED(value)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool xu_control_range(
|
||||
const device &device, const xu &xu, uint8_t selector, uint8_t id, int32_t *min,
|
||||
int32_t *max, int32_t *def) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(xu)
|
||||
UNUSED(selector)
|
||||
UNUSED(id)
|
||||
UNUSED(min)
|
||||
UNUSED(max)
|
||||
UNUSED(def)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool xu_control_query(
|
||||
const device &device, const xu &xu, uint8_t selector, xu_query query,
|
||||
uint16_t size, uint8_t *data) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(xu)
|
||||
UNUSED(selector)
|
||||
UNUSED(query)
|
||||
UNUSED(size)
|
||||
UNUSED(data)
|
||||
return false;
|
||||
}
|
||||
|
||||
void set_device_mode(
|
||||
device &device, int width, int height, int fourcc, int fps, // NOLINT
|
||||
video_channel_callback callback) {
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(width)
|
||||
UNUSED(height)
|
||||
UNUSED(fourcc)
|
||||
UNUSED(fps)
|
||||
UNUSED(callback)
|
||||
}
|
||||
|
||||
void start_streaming(device &device, int num_transfer_bufs) { // NOLINT
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
UNUSED(num_transfer_bufs)
|
||||
}
|
||||
|
||||
void stop_streaming(device &device) { // NOLINT
|
||||
// TODO(JohnZhao)
|
||||
UNUSED(device)
|
||||
}
|
||||
|
||||
} // namespace uvc
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
||||
@@ -97,10 +97,10 @@ class BinDataset(object):
|
||||
if What.imu in result:
|
||||
imu = result[What.imu]
|
||||
np.array([(
|
||||
imu.timestamp,
|
||||
imu.timestamp, imu.flag,
|
||||
imu.accel_x, imu.accel_y, imu.accel_z,
|
||||
imu.gyro_x, imu.gyro_y, imu.gyro_z
|
||||
)], dtype="f8, f8, f8, f8, f8, f8, f8").tofile(f_imu)
|
||||
)], dtype="f8, i4, f8, f8, f8, f8, f8, f8").tofile(f_imu)
|
||||
imu_count = imu_count + 1
|
||||
has_imu = True
|
||||
sys.stdout.write('\r img: {}, imu: {}'.format(img_count, imu_count))
|
||||
@@ -130,7 +130,7 @@ class BinDataset(object):
|
||||
|
||||
if self.has_imu:
|
||||
imus = np.memmap(self._binimu, dtype=[
|
||||
('t', 'f8'),
|
||||
('t', 'f8'), ('flag', 'i4'),
|
||||
('accel_x', 'f8'), ('accel_y', 'f8'), ('accel_z', 'f8'),
|
||||
('gyro_x', 'f8'), ('gyro_y', 'f8'), ('gyro_z', 'f8'),
|
||||
], mode='r')
|
||||
@@ -145,92 +145,111 @@ class BinDataset(object):
|
||||
print(' img: {}, imu: {}'.format(period_img, period_imu))
|
||||
|
||||
imgs_t_diff = np.diff(imgs['t'])
|
||||
imus_t_diff = np.diff(imus['t'])
|
||||
# imus_t_diff = np.diff(imus['t'])
|
||||
|
||||
accel = imus[imus['flag'] == 1]
|
||||
accel_t_diff = np.diff(accel['t'])
|
||||
gyro = imus[imus['flag'] == 2]
|
||||
gyro_t_diff = np.diff(gyro['t'])
|
||||
|
||||
print('\ncount')
|
||||
print(' imgs: {}, imus: {}, accel: {}, gyro: {}'.format(
|
||||
imgs.size, imus.size, accel.size, gyro.size))
|
||||
print('\ndiff count')
|
||||
print(' imgs: {}, imus: {}'.format(imgs['t'].size, imus['t'].size))
|
||||
print(' imgs_t_diff: {}, imus_t_diff: {}'
|
||||
.format(imgs_t_diff.size, imus_t_diff.size))
|
||||
print(' imgs_t_diff: {}, accel_t_diff: {}, gyro_t_diff: {}'.format(
|
||||
imgs_t_diff.size, accel_t_diff.size, gyro_t_diff.size))
|
||||
|
||||
print('\ndiff where (factor={})'.format(args.factor))
|
||||
|
||||
where = np.argwhere(imgs_t_diff > period_img * (1 + args.factor))
|
||||
print(' imgs where diff > {}*{} ({})'.format(period_img,
|
||||
1 + args.factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], imgs_t_diff[x][0]))
|
||||
|
||||
where = np.argwhere(imgs_t_diff < period_img * (1 - args.factor))
|
||||
print(' imgs where diff < {}*{} ({})'.format(period_img,
|
||||
1 - args.factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], imgs_t_diff[x][0]))
|
||||
|
||||
where = np.argwhere(imus_t_diff > period_imu * (1 + args.factor))
|
||||
print(' imus where diff > {}*{} ({})'.format(period_imu,
|
||||
1 + args.factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], imus_t_diff[x][0]))
|
||||
|
||||
where = np.argwhere(imus_t_diff < period_imu * (1 - args.factor))
|
||||
print(' imus where diff < {}*{} ({})'.format(period_imu,
|
||||
1 - args.factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], imus_t_diff[x][0]))
|
||||
self._print_t_diff_where('imgs', imgs_t_diff, period_img, args.factor)
|
||||
# self._print_t_diff_where('imus', imus_t_diff, period_imu, args.factor)
|
||||
self._print_t_diff_where('accel', accel_t_diff, period_imu, args.factor)
|
||||
self._print_t_diff_where('gyro', gyro_t_diff, period_imu, args.factor)
|
||||
|
||||
import pandas as pd
|
||||
bins = imgs['t']
|
||||
bins_n = imgs['t'].size
|
||||
bins = pd.Series(data=bins).drop_duplicates(keep='first')
|
||||
cats = pd.cut(imus['t'], bins)
|
||||
|
||||
print('\nimage timestamp duplicates: {}'.format(bins_n - bins.size))
|
||||
|
||||
self._plot(outdir, imgs_t_diff, imus_t_diff, cats.value_counts())
|
||||
def _cut_by_imgs_t(imus_t):
|
||||
cats = pd.cut(imus_t, bins)
|
||||
return cats.value_counts()
|
||||
|
||||
def _plot(self, outdir, imgs_t_diff, imus_t_diff, imgs_t_imus):
|
||||
self._plot(
|
||||
outdir,
|
||||
imgs_t_diff,
|
||||
accel_t_diff,
|
||||
_cut_by_imgs_t(
|
||||
accel['t']),
|
||||
gyro_t_diff,
|
||||
_cut_by_imgs_t(
|
||||
gyro['t']))
|
||||
|
||||
def _print_t_diff_where(self, name, t_diff, period, factor):
|
||||
import numpy as np
|
||||
|
||||
where = np.argwhere(t_diff > period * (1 + factor))
|
||||
print(' {} where diff > {}*{} ({})'.format(
|
||||
name, period, 1 + factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], t_diff[x][0]))
|
||||
|
||||
where = np.argwhere(t_diff < period * (1 - factor))
|
||||
print(' {} where diff < {}*{} ({})'.format(
|
||||
name, period, 1 - factor, where.size))
|
||||
for x in where:
|
||||
print(' {:8d}: {:.16f}'.format(x[0], t_diff[x][0]))
|
||||
|
||||
def _plot(self, outdir, imgs_t_diff,
|
||||
accel_t_diff, accel_counts, gyro_t_diff, gyro_counts):
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
fig_1 = plt.figure(1, [16, 6])
|
||||
fig_1 = plt.figure(1, [16, 12])
|
||||
fig_1.suptitle('Stamp Analytics')
|
||||
fig_1.subplots_adjust(
|
||||
left=0.1,
|
||||
right=0.95,
|
||||
top=0.85,
|
||||
bottom=0.15,
|
||||
wspace=0.4)
|
||||
wspace=0.4,
|
||||
hspace=0.4)
|
||||
|
||||
ax_imgs_t_diff = fig_1.add_subplot(131)
|
||||
ax_imgs_t_diff = fig_1.add_subplot(231)
|
||||
ax_imgs_t_diff.set_title('Image Timestamp Diff')
|
||||
ax_imgs_t_diff.set_xlabel('diff index')
|
||||
ax_imgs_t_diff.set_ylabel('diff (s)')
|
||||
ax_imgs_t_diff.axis('auto')
|
||||
|
||||
ax_imus_t_diff = fig_1.add_subplot(132)
|
||||
ax_imus_t_diff.set_title('Imu Timestamp Diff')
|
||||
ax_imus_t_diff.set_xlabel('diff index')
|
||||
ax_imus_t_diff.set_ylabel('diff (s)')
|
||||
ax_imus_t_diff.axis('auto')
|
||||
|
||||
ax_imgs_t_imus = fig_1.add_subplot(133)
|
||||
ax_imgs_t_imus.set_title('Imu Count Per Image Intervel')
|
||||
ax_imgs_t_imus.set_xlabel('intervel index')
|
||||
ax_imgs_t_imus.set_ylabel('imu count')
|
||||
ax_imgs_t_imus.axis('auto')
|
||||
|
||||
ax_imgs_t_diff.set_xlim([0, imgs_t_diff.size])
|
||||
ax_imgs_t_diff.plot(imgs_t_diff)
|
||||
|
||||
ax_imus_t_diff.set_xlim([0, imus_t_diff.size])
|
||||
ax_imus_t_diff.plot(imus_t_diff)
|
||||
def _plot_imus(name, t_diff, counts, pos_offset=0):
|
||||
ax_imus_t_diff = fig_1.add_subplot(232 + pos_offset)
|
||||
ax_imus_t_diff.set_title('{} Timestamp Diff'.format(name))
|
||||
ax_imus_t_diff.set_xlabel('diff index')
|
||||
ax_imus_t_diff.set_ylabel('diff (s)')
|
||||
ax_imus_t_diff.axis('auto')
|
||||
|
||||
# print(imgs_t_imus.values)
|
||||
# imgs_t_imus.plot(kind='line', ax=ax_imgs_t_imus)
|
||||
data = imgs_t_imus.values
|
||||
ax_imgs_t_imus.set_xlim([0, data.size])
|
||||
ax_imgs_t_imus.set_ylim([np.min(data) - 1, np.max(data) + 1])
|
||||
ax_imgs_t_imus.plot(data)
|
||||
ax_imus_t_diff.set_xlim([0, t_diff.size - 1])
|
||||
ax_imus_t_diff.plot(t_diff)
|
||||
|
||||
ax_imus_counts = fig_1.add_subplot(233 + pos_offset)
|
||||
ax_imus_counts.set_title('{} Count Per Image Intervel'.format(name))
|
||||
ax_imus_counts.set_xlabel('intervel index')
|
||||
ax_imus_counts.set_ylabel('imu count')
|
||||
ax_imus_counts.axis('auto')
|
||||
|
||||
# print(counts.values)
|
||||
# counts.plot(kind='line', ax=ax_imus_counts)
|
||||
data = counts.values
|
||||
ax_imus_counts.set_xlim([0, data.size])
|
||||
ax_imus_counts.set_ylim([np.min(data) - 1, np.max(data) + 1])
|
||||
ax_imus_counts.plot(data)
|
||||
|
||||
_plot_imus('Accel', accel_t_diff, accel_counts)
|
||||
_plot_imus('Gyro', gyro_t_diff, gyro_counts, 3)
|
||||
|
||||
if outdir:
|
||||
figpath = os.path.join(outdir, RESULT_FIGURE)
|
||||
@@ -288,14 +307,14 @@ def _parse_args():
|
||||
'--rate-img',
|
||||
dest='rate_img',
|
||||
metavar='RATE',
|
||||
default=25,
|
||||
default=60,
|
||||
type=int,
|
||||
help='the img rate (default: %(default)s)')
|
||||
parser.add_argument(
|
||||
'--rate-imu',
|
||||
dest='rate_imu',
|
||||
metavar='RATE',
|
||||
default=500,
|
||||
default=200,
|
||||
type=int,
|
||||
help='the imu rate (default: %(default)s)')
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -20,13 +20,17 @@ set_outdir(
|
||||
"${OUT_DIR}/bin/${DIR_NAME}"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${PRO_DIR}/src
|
||||
)
|
||||
|
||||
## record
|
||||
|
||||
make_executable(record
|
||||
SRCS record.cc dataset.cc
|
||||
LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
)
|
||||
# make_executable(record
|
||||
# SRCS record.cc dataset.cc
|
||||
# LINK_LIBS mynteye ${OpenCV_LIBS}
|
||||
# DLL_SEARCH_PATHS ${PRO_DIR}/_install/bin ${OpenCV_LIB_SEARCH_PATH}
|
||||
#)
|
||||
|
||||
make_executable(record2
|
||||
SRCS record2.cc dataset.cc
|
||||
|
||||
@@ -13,11 +13,8 @@
|
||||
// limitations under the License.
|
||||
#include "dataset/dataset.h"
|
||||
|
||||
#ifdef WITH_OPENCV2
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#else
|
||||
#include <opencv2/imgcodecs/imgcodecs.hpp>
|
||||
#endif
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
@@ -68,23 +65,53 @@ void Dataset::SaveStreamData(
|
||||
std::stringstream ss;
|
||||
ss << writer->outdir << MYNTEYE_OS_SEP << std::dec
|
||||
<< std::setw(IMAGE_FILENAME_WIDTH) << std::setfill('0') << seq << ".png";
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC1, data.frame->data());
|
||||
cv::imwrite(ss.str(), img);
|
||||
if (data.frame->format() == Format::GREY) {
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC1,
|
||||
data.frame->data());
|
||||
cv::imwrite(ss.str(), img);
|
||||
} else if (data.frame->format() == Format::YUYV) {
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC2,
|
||||
data.frame->data());
|
||||
cv::cvtColor(img, img, cv::COLOR_YUV2BGR_YUY2);
|
||||
cv::imwrite(ss.str(), img);
|
||||
} else if (data.frame->format() == Format::BGR888) {
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC3,
|
||||
data.frame->data());
|
||||
// cv::cvtColor(img, img, CV_BGR2RGB);
|
||||
cv::imwrite(ss.str(), img);
|
||||
} else {
|
||||
cv::Mat img(
|
||||
data.frame->height(), data.frame->width(), CV_8UC1,
|
||||
data.frame->data());
|
||||
cv::imwrite(ss.str(), img);
|
||||
}
|
||||
}
|
||||
++stream_counts_[stream];
|
||||
}
|
||||
|
||||
void Dataset::SaveMotionData(const device::MotionData &data) {
|
||||
auto &&writer = GetMotionWriter();
|
||||
// auto seq = data.imu->serial_number;
|
||||
auto seq = motion_count_;
|
||||
writer->ofs << seq << ", " << data.imu->frame_id << ", "
|
||||
<< data.imu->timestamp << ", " << data.imu->accel[0] << ", "
|
||||
<< data.imu->accel[1] << ", " << data.imu->accel[2] << ", "
|
||||
<< data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", "
|
||||
<< data.imu->gyro[2] << ", " << data.imu->temperature
|
||||
<< std::endl;
|
||||
++motion_count_;
|
||||
if (data.imu->flag == 1 || data.imu->flag == 2) {
|
||||
writer->ofs << seq << ", " << static_cast<int>(data.imu->flag) << ", "
|
||||
<< data.imu->timestamp << ", " << data.imu->accel[0] << ", "
|
||||
<< data.imu->accel[1] << ", " << data.imu->accel[2] << ", "
|
||||
<< data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", "
|
||||
<< data.imu->gyro[2] << ", " << data.imu->temperature
|
||||
<< std::endl;
|
||||
++motion_count_;
|
||||
}
|
||||
/*
|
||||
if(motion_count_ != seq) {
|
||||
LOG(INFO) << "motion_count_ != seq !" << " motion_count_: " << motion_count_
|
||||
<< " seq: " << seq;
|
||||
motion_count_ = seq;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Dataset::SaveStreamData(
|
||||
@@ -105,14 +132,24 @@ void Dataset::SaveStreamData(
|
||||
|
||||
void Dataset::SaveMotionData(const api::MotionData &data) {
|
||||
auto &&writer = GetMotionWriter();
|
||||
// auto seq = data.imu->serial_number;
|
||||
auto seq = motion_count_;
|
||||
writer->ofs << seq << ", " << data.imu->frame_id << ", "
|
||||
<< data.imu->timestamp << ", " << data.imu->accel[0] << ", "
|
||||
<< data.imu->accel[1] << ", " << data.imu->accel[2] << ", "
|
||||
<< data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", "
|
||||
<< data.imu->gyro[2] << ", " << data.imu->temperature
|
||||
<< std::endl;
|
||||
++motion_count_;
|
||||
if (data.imu->flag == 1 || data.imu->flag == 2) {
|
||||
writer->ofs << seq << ", " << static_cast<int>(data.imu->flag) << ", "
|
||||
<< data.imu->timestamp << ", " << data.imu->accel[0] << ", "
|
||||
<< data.imu->accel[1] << ", " << data.imu->accel[2] << ", "
|
||||
<< data.imu->gyro[0] << ", " << data.imu->gyro[1] << ", "
|
||||
<< data.imu->gyro[2] << ", " << data.imu->temperature
|
||||
<< std::endl;
|
||||
++motion_count_;
|
||||
}
|
||||
/*
|
||||
if(motion_count_ != seq) {
|
||||
LOG(INFO) << "motion_count_ != seq !" << " motion_count_: " << motion_count_
|
||||
<< " seq: " << seq;
|
||||
motion_count_ = seq;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Dataset::writer_t Dataset::GetStreamWriter(const Stream &stream) {
|
||||
@@ -151,13 +188,15 @@ Dataset::writer_t Dataset::GetMotionWriter() {
|
||||
|
||||
files::mkdir(writer->outdir);
|
||||
writer->ofs.open(writer->outfile, std::ofstream::out);
|
||||
writer->ofs << "seq, frame_id, timestamp, accel_x, accel_y, accel_z, "
|
||||
writer->ofs << "seq, flag, timestamp, accel_x, accel_y, accel_z, "
|
||||
"gyro_x, gyro_y, gyro_z, temperature"
|
||||
<< std::endl;
|
||||
writer->ofs << FULL_PRECISION;
|
||||
|
||||
motion_writer_ = writer;
|
||||
motion_count_ = 0;
|
||||
accel_count_ = 0;
|
||||
gyro_count_ = 0;
|
||||
}
|
||||
return motion_writer_;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user