Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

H3DS-72 Move to the new plugin-oriented platform #75

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
00b1cc3
H3DS-68 Fixed device filter format - it supports only dec
rabits Mar 13, 2020
26fa9f0
H3DS-68 Fixed issue with build on modern QTCreator, updated arcore to…
rabits Mar 14, 2020
2d11efe
H3DS-68 Update of the support library to androidx
rabits Mar 17, 2020
73efc69
H3DS-72 Prepared semi-working plugin cmake build system
rabits Jul 5, 2020
53d3060
H3DS-72 Added ability to build for android
rabits Jul 12, 2020
6d3882b
H3DS-72 Added support for QtCreator and loading the plugins
rabits Jul 19, 2020
756d5ae
H3DS-72 Added support for multiple interfaces in the plugin system
rabits Jul 26, 2020
fdc22d7
H3DS-72 Added an ability to activate or deactivate plugins through se…
rabits Aug 2, 2020
47075ed
H3DS-72 Plugins standalone build as aar and loading aar's to platform
rabits Aug 16, 2020
0208cc5
H3DS-72 Created realsense plugin android service - now it's working
rabits Aug 24, 2020
adea44a
H3DS-72 Fixed issue with cleaning after packing classes.jar
rabits Aug 30, 2020
95bc86f
H3DS-72 Fixed issue with plugin android service stop
rabits Aug 30, 2020
ebf26ee
H3DS-72 Fixed interface freeze after stopping the plugin service
rabits Aug 30, 2020
13da765
H3DS-72 Fixed loop in startup loading activated plugins
rabits Aug 30, 2020
c233eea
H3DS-72 Detach the realsense devices on deinit plugin
rabits Aug 30, 2020
20bfcb8
H3DS-72 Added a way to show UI notifications from plugins
rabits Sep 6, 2020
2a30b6f
H3DS-72 Removed not working properly plugins cleaning qt classes
rabits Sep 6, 2020
e308002
H3DS-72 Enabled Capture, workaround for freeze bug and example for ge…
rabits Sep 6, 2020
cc18c5e
H3DS-72 Fixed the plugin loading and made interface for QML
rabits Sep 13, 2020
4d48d95
H3DS-72 Moved QML to direct interaction with the plugin objects
rabits Sep 20, 2020
fb0e388
H3DS-72 Added abitily to get the real streams list from plugin
rabits Sep 20, 2020
93d0b65
H3DS-72 Reenabled Capture and the video stream from realsense plugin
rabits Oct 11, 2020
c6a772e
H3DS-72 Added UI to select the capture stream
rabits Oct 18, 2020
d9f60bb
H3DS-72 Added ability to switch between the streams
rabits Nov 8, 2020
c8d6150
H3DS-72 No need to destroy pipeline - it's working as is
rabits Nov 8, 2020
f4f6327
H3DS-72 Added new supported formats and changed the logic of get avai…
rabits Nov 16, 2020
2b8489d
H3DS-72 Improved the video stream list
rabits Nov 22, 2020
3ffa8a2
H3DS-72 Added status for available streams and fixed destroy of the p…
rabits Nov 23, 2020
cb2e2d3
H3DS-72 Moved to Qt 5.15.2, passed stream fps data, restored PC capture
rabits Feb 22, 2021
70b0f1e
Rewrote PC capture to be more streamlined
rabits Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
BasedOnStyle: Google

UseTab: Never
ColumnLimit: 120
IndentWidth: 4
TabWidth: 4
AccessModifierOffset: -2

SpaceBeforeParens: Never
SpacesInConditionalStatement: true
AllowShortIfStatementsOnASingleLine: Never
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: InlineOnly

BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterFunction: true

ConstructorInitializerAllOnOneLineOrOnePerLine: false
BreakInheritanceList: BeforeComma
BreakConstructorInitializers: BeforeComma

SpaceAfterLogicalNot: true

AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
...
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ CMakeLists.txt.user*
# Build directory
/build*
/lib/src

# Keystore
/android.keystore

# plugin standalone builds
/plugins/build-*
138 changes: 75 additions & 63 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,74 +1,86 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.13)

project(handy3dscanner LANGUAGES CXX VERSION 0.5.1)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(handy3dscanner)

if(ANDROID)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE STRING "Force to prevent issues" FORCE)
set(ANDROID_STL "c++_shared" CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE STRING "Force to prevent issues" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE STRING "Force to prevent issues" FORCE)
set(ANDROID_STL "c++_shared" CACHE STRING "Force to prevent issues" FORCE)
endif()

add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}")
add_definitions(-DQT_NO_FOREACH)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000)

# Listing the available sources to build
file(GLOB_RECURSE Execution_CPP RELATIVE "${CMAKE_SOURCE_DIR}" src/*.cpp)
file(GLOB_RECURSE Execution_H RELATIVE "${CMAKE_SOURCE_DIR}" src/*.h)

find_package(Qt5 COMPONENTS Core Quick Sensors 3DCore 3DRender 3DInput 3DQuick 3DQuickExtras REQUIRED)

# TODO: use the original PCL instead of this one
include(lib/pcl.cmake)
# Common parameters
include(common.cmake)

## Build plugins
include(plugins.cmake)

message("Configure platform")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/platform)


#if(ANDROID)
# list(REMOVE_DUPLICATES CUSTOM_ANDROID_EXTRA_LIBS)
# string(REPLACE ";" "," CUSTOM_ANDROID_EXTRA_LIBS_STRING "${CUSTOM_ANDROID_EXTRA_LIBS}")
# set(ANDROID_EXTRA_LIBS "${CUSTOM_ANDROID_EXTRA_LIBS_STRING}" CACHE INTERNAL "")
# message("Additional android libs: ${ANDROID_EXTRA_LIBS}")
#
# target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::AndroidExtras GLESv3)
#
# # qtcreator cmake android deployment don't want to set sdkBuildToolsRevision
# add_custom_command(
# TARGET ${PROJECT_NAME} POST_BUILD
# BYPRODUCTS notexisting.file # To build the package anyway
# COMMAND ${CMAKE_COMMAND} -E env
# ANDROID_KEYSTORE_FILE="${CMAKE_SOURCE_DIR}/android.keystore"
# QT_ANDROID="${CMAKE_PREFIX_PATH}"
# ANDROID_SDK_BUILD_TOOLS=29.0.1
# ANDROID_NDK_TOOLCHAIN_ABI=${ANDROID_ABI}
# QML_ROOT_PATH="${CMAKE_SOURCE_DIR}"
# sh "${CMAKE_SOURCE_DIR}/tool/build-apk.sh" $<TARGET_FILE:${PROJECT_NAME}> ${ANDROID_EXTRA_LIBS} ${ANDROID_PACKAGE_SOURCE_DIR}
# )
#endif()


#set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
#
## Add targets to check the source code format
#set(CLANG_FORMAT_BIN_NAME clang-format-10)
#set(CLANG_FORMAT_EXCLUDE_PATTERNS "build/" "/libs/" ${CMAKE_BINARY_DIR})
#find_package(ClangFormat)
#
## Make sure the source code is well formatted
#add_dependencies(${PROJECT_NAME} format-check)


# Packaging
add_custom_target(package ALL
COMMAND ${CMAKE_COMMAND} -E echo "Ok, package of ${PROJECT_NAME} is done"
)

if(ANDROID)
find_package(Qt5 COMPONENTS AndroidExtras REQUIRED)
add_library(${PROJECT_NAME} SHARED ${Execution_CPP} ${Execution_H} src/app.qrc)
set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_BINARY_DIR}/android" CACHE INTERNAL "")
else()
# Excluding android-only sources
list(REMOVE_ITEM Execution_H src/androidwrapper.h src/androidwrapperexception.h src/provider/arcore/arcore.h src/provider/arcore/arcoreworker.h)
list(REMOVE_ITEM Execution_CPP src/android_jni.cpp src/androidwrapper.cpp src/provider/arcore/arcore.cpp src/provider/arcore/arcoreworker.cpp)
add_executable(${PROJECT_NAME} ${Execution_CPP} ${Execution_H} src/app.qrc)
endif()

# Strip binary for release builds
if(CMAKE_BUILD_TYPE STREQUAL Release)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} $<TARGET_FILE:handy3dscanner>)
# TODO Making an addition to the deployment JSON file
file(READ "${CMAKE_BINARY_DIR}/android_deployment_settings.json" deploy_data_in)
string(REPLACE "\"ndk\":"
"\"sdkBuildToolsRevision\": \"${ANDROID_SDK_BUILD_TOOLS}\",\n \"ndk\":" deploy_data_in "${deploy_data_in}")
file(WRITE "${CMAKE_BINARY_DIR}/android_deployment_settings.json" "${deploy_data_in}")
add_custom_command(TARGET package PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_BINARY_DIR}/android-build/${PROJECT_NAME}.apk"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}_$<JOIN:${BUILD_ABIS},->.apk"
)
add_dependencies(package apk)
endif()

# Dependencies build
include(lib/librealsense.cmake)
include(lib/draco.cmake)
include(lib/arcore.cmake)
# Disabled until will be used
#include(pcl.cmake)

include(android.cmake)

target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(${PROJECT_NAME}
PRIVATE Qt5::Core Qt5::Quick Qt5::Sensors Qt5::3DCore Qt5::3DRender Qt5::3DInput Qt5::3DQuick Qt5::3DLogic Qt5::3DQuickExtras)

# Copy plugins
if(ANDROID)
list(REMOVE_DUPLICATES CUSTOM_ANDROID_EXTRA_LIBS)
string(REPLACE ";" "," CUSTOM_ANDROID_EXTRA_LIBS_STRING "${CUSTOM_ANDROID_EXTRA_LIBS}")
set(ANDROID_EXTRA_LIBS "${CUSTOM_ANDROID_EXTRA_LIBS_STRING}" CACHE INTERNAL "")
message("Additional android libs: ${ANDROID_EXTRA_LIBS}")

target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::AndroidExtras GLESv3)

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND sh "${CMAKE_SOURCE_DIR}/tools/build-apk.sh" $<TARGET_FILE:handy3dscanner> ${ANDROID_EXTRA_LIBS} ${ANDROID_PACKAGE_SOURCE_DIR})
add_custom_target(prepare_package ALL
COMMAND ${CMAKE_COMMAND} -E copy plugins/*.aar android-build/libs
DEPENDS ${main_target_name}
)
else()
# TODO: copy plugins for non-android
endif()

add_dependencies(apk prepare_package)
add_dependencies(prepare_package ${PLUGINS_DEPENDS})
115 changes: 13 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ You can find the examples & PCD/glb files on the wiki page: [Example data](https
* Professional 3d scanners: ~$10'000 - $20'000.
* Table laser scanners: ~$70 - $500.

With Intel Realsense D415 (~$140) and mobile app we can get a simple and cheap solution to provide a really
cheap mid-range HD solution with advanced specifications:
With Intel Realsense D415 (~$140) and mobile app we can get a really cheap mid-range HD scanner solution:
* Resolution: 1Mpix (1280x720)
* Frame-rate: 30-60 fps
* Angle: 63°x40°, 85°x58°
* Range: 16cm-10m, 11cm-10m

Means that finally for ~$200 users can get simple solution to build second instagram, now in 3D - and the
last piece is just a userspace software.

### Plans

You can see all the feature requests/bugs on the github page:
Expand Down Expand Up @@ -118,105 +114,20 @@ if you want to use gyroscope.

#### Build in docker

##### For desktop

1. Clone the repository:
```
host$ git clone https://github.com/state-of-the-art/Handy3DScanner.git ~/Build/Handy3DScanner
```
2. Run the docker container:
```
host$ cd ~/Build/Handy3DScanner
host$ docker run -it --rm --name h3ds-build --volume="${PWD}:/home/user/project" rabits/qt:5.13-desktop
```
3. Install the required dependencies:
```
docker$ sudo apt update
docker$ sudo apt install -y libusb-1.0-0-dev
```
4. Create build directory:
```
docker$ mkdir project/build
docker$ cd project/build
```
5. Generate the build scripts
```
docker$ cmake .. -G Ninja "-DCMAKE_PREFIX_PATH:PATH=${QT_DESKTOP}"
```
6. Build the binaries:
```
docker$ cmake --build .
```
7. You can find the compiled binaries in the `build` directory

##### For android

1. Clone the repository:
```
host$ git clone https://github.com/state-of-the-art/Handy3DScanner.git ~/Build/Handy3DScanner
```
2. Run the docker container (use `-armv7` if you need armv7 binaries):
```
host$ cd ~/Build/Handy3DScanner
host$ docker run -it --rm --name h3ds-build --volume="${PWD}:/home/user/project" rabits/qt:5.13-android-arm64
```
3. Install the required dependencies (build-essential for boost build system):
```
docker$ sudo apt update
docker$ sudo apt install -y imagemagick build-essential
```
4. Create build directory:
```
docker$ mkdir project/build
docker$ cd project/build
```
5. Generate the build scripts
```
docker$ cmake .. -G Ninja "-DCMAKE_PREFIX_PATH:PATH=${QT_ANDROID}" "-DCMAKE_TOOLCHAIN_FILE:PATH=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" "-DANDROID_ABI:STRING=${ANDROID_NDK_TOOLCHAIN_ABI}" -DANDROID_NATIVE_API_LEVEL:STRING=29
```
6. Build the binaries:
```
docker$ cmake --build .
```
7. Debug APK will be created automatically with help of `tools/build-apk.sh` - and you will see where it's

#### Build on host

You can use your host:

##### Dependencies

* Ubuntu 18.04 (build is tested only using ubuntu, but you can try something else)
* CMake 3.10
* Ninja (optional, but helpful)
* Qt SDK 5.12 or 5.13
* build-essential (is needed to build host binaries, even for android boost requires to compile the build system)
* android:
* Android SDK android-29 (actually could be built on 21-29 API levels)
* Android NDK r20
* Imagemagick (using `convert` to generate png out of svg)
* desktop:
* libusb-1.0-0-dev (on android we using jni interface, but on desktop the native one)

##### Variables

Already set in the docker images, but you need to set them to build on the host system (there is an examples, you need to choose yours):

* `QT_DESKTOP`: "~/local/Qt/5.13.0/gcc_64" - path to the Qt desktop binaries
* `QT_ANDROID`: "~/local/Qt/5.13.0/android_armv7" - path to the Qt android binaries
* `ANDROID_NDK_PLATFORM`: "android-29" - what the platform to use while android apk build
* `ANDROID_NDK_ROOT`: "~/local/android-sdk/ndk-bundle" - path to the Android NDK
* `ANDROID_NDK_TOOLCHAIN_ABI`: "armeabi-v7a", "arm64-v8a" - binary type

To build the APK for android you need to set the next env variables in addition:

* `ANDROID_SDK_ROOT`: "/opt/android-sdk" - path to the android sdk
* `ANDROID_NDK_HOST`: "linux-x86_64" - ndk host platform
* `ANDROID_SDK_BUILD_TOOLS`: "29.0.1" - version of the sdk build-tools will be used

##### Build

Just follow the docker instructions (but without docker) - and you will be good.
$ git clone https://github.com/state-of-the-art/Handy3DScanner.git && mkdir -p out
```
2. Run the docker container and build the project:
* Linux desktop `x86_64`:
```
$ docker run -it --rm -v "${PWD}/Handy3DScanner:/home/user/project:ro" -v "${PWD}/out:/home/user/out:rw" rabits/qt:5.14-desktop ./project/tool/build-docker-linux.sh
```
* Android `multiarch`:
```
$ docker run -it --rm -v "${PWD}/Handy3DScanner:/home/user/project:ro" -v "${PWD}/out:/home/user/out:rw" rabits/qt:5.14-android ./project/tool/build-docker-android.sh
```
3. Results will be placed in the `out` directory

## Privacy policy

Expand Down
72 changes: 0 additions & 72 deletions android.cmake

This file was deleted.

Loading