Skip to content

Commit

Permalink
v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimo Bernava committed Jun 15, 2021
1 parent 765673e commit 50e5cec
Show file tree
Hide file tree
Showing 67 changed files with 4,037 additions and 4,084 deletions.
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,63 @@
## Installation


## Server

sudo apt install git cmake lua5.1 liblua5.1-0-dev libssl-dev libcurl4-openssl-dev libsqlite3-dev libmicrohttpd-dev libjson-c-dev libenet-dev
## Server Linux

Install the required libraries:
```bash
sudo apt install git cmake libluajit-5.1-dev libssl-dev libcurl4-openssl-dev libjson-c-dev libmicrohttpd-dev libsqlite3-dev libzmq3-dev libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev libopencv-dev
```

Optional install nosql ejdb2 database:
```bash
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:adamansky/ejdb2
sudo apt-get install ejdb2
```

Install Tensorflow Lite:
```bash
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
mkdir tflite_build
cd tflite_build
cmake ../tensorflow_src/tensorflow/lite/c -DTFLITE_ENABLE_GPU=ON
cmake --build . -j
```

Clone repository and use cmake:
```bash
git clone https://github.com/massimobernava/proteo.git
cd proteo/server
mkdir build
cd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
make
```

Update config.json:
```json
{ "version":"0.1",
"basedir":"/usr/local/etc/Proteo/",
"baseurl":"YOUR_LOCAL_IP",
"port":8888,"master":1,"ssl":0,
"server_key":"01234567890123456789012345678901",
"client_key":"01234567890123456789012345678901",
"ssl_key":"",
"ssl_cert":"",
"admin_enabled":1,"plugins":["proteo","admin","edit","deepcrimson","deepindigo"],
"servers":[]
}
```
Install it as a service:
```bash
chmod +x ./install.sh
sudo ./install.sh
```

## Client

Choose, red pill and continue to compile, [blue pill](https://github.com/massimobernava/proteo/releases) and download one of the releases.

### Linux
Test: Ubuntu ... Raspberry ...

Expand Down
102 changes: 90 additions & 12 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ find_package(JSONC REQUIRED)
#find_package(ENet REQUIRED)
find_package(OpenCV REQUIRED)
find_package(ZeroMQ REQUIRED)
find_package(OpenGL)
find_package(GLEW 2.0)

find_path( AVCODEC_INCLUDE_DIR libavcodec/avcodec.h )
find_library( AVCODEC_LIBRARY avcodec )
Expand All @@ -25,27 +27,103 @@ find_library( SWSCALE_LIBRARY swscale )
find_path(AVUTIL_INCLUDE_DIR libavutil/avutil.h)
find_library(AVUTIL_LIBRARY avutil)

include_directories(${SWSCALE_INCLUDE_DIR} ${AVCODEC_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS} ${SDL2_GFX_INCLUDE_DIRS} ${LUAJIT_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${ZMQ_INCLUDE_DIRS}) #${ENET_INCLUDE_DIRS}
find_path(TensorFlowLite_INCLUDE_DIR
NAMES
tensorflow/lite
tensorflow
HINTS
${CMAKE_SOURCE_DIR}/tflite/include
/usr/local/include)

find_library(TensorFlowLite_LIBRARY
NAMES
tensorflowlite_c
tensorflowlite
HINTS
${CMAKE_SOURCE_DIR}/tflite/lib
/usr/lib
/usr/local/lib)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(TFLITE DEFAULT_MSG TensorFlowLite_INCLUDE_DIR)

if(TFLITE_FOUND)
include_directories(${TensorFlowLite_INCLUDE_DIR})
add_definitions(-DTFLITE)
endif()

if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
add_definitions(-DGLEW)
endif()

include_directories( ${SWSCALE_INCLUDE_DIR} ${AVCODEC_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS} ${SDL2_GFX_INCLUDE_DIRS} ${LUAJIT_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${CURL_INCLUDE_DIRS} ${JSONC_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${ZMQ_INCLUDE_DIRS}) #${ENET_INCLUDE_DIRS}

if(ANDROID)
add_executable(proteo SHARED proteo.c)
elseif(APPLE)
set(ICON_NAME "Proteo.icns")
set(ICON_PATH ${CMAKE_SOURCE_DIR}/${ICON_NAME})
set(proteo_ICON ${ICON_PATH})
set_source_files_properties(${proteo_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

set(FONT1_NAME "ColabReg.otf")
set(FONT1_PATH ${CMAKE_SOURCE_DIR}/${FONT1_NAME})
set(proteo_FONT1 ${FONT1_PATH})
set_source_files_properties(${proteo_FONT1} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

set(FONT2_NAME "OpenSans-Regular.ttf")
set(FONT2_PATH ${CMAKE_SOURCE_DIR}/${FONT2_NAME})
set(proteo_FONT2 ${FONT2_PATH})
set_source_files_properties(${proteo_FONT2} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

set(CONFIG_NAME "config.json")
set(CONFIG_PATH ${CMAKE_SOURCE_DIR}/${CONFIG_NAME})
set(proteo_CONFIG ${CONFIG_PATH})
set_source_files_properties(${proteo_CONFIG} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

file(COPY ${ICON_PATH} DESTINATION "proteo.app/Contents/Resources")
add_executable(proteo MACOSX_BUNDLE ${ICON_PATH} ${FONT1_PATH} ${FONT2_PATH} ${CONFIG_PATH} proteo.c proteo_opencv.cpp)
set_target_properties(proteo PROPERTIES MACOSX_BUNDLE_ICONFILE ${ICON_NAME})
set_target_properties(proteo PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/MacOSXBundleInfo.plist.in)

SET(APPS "\${CMAKE_INSTALL_PREFIX}/proteo.app")

#Copia il file nella directory principale
#INSTALL(TARGETS proteo BUNDLE DESTINATION ${CMAKE_SOURCE_DIR} COMPONENT Runtime)

#set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
install(CODE "
MESSAGE(\"Fixup\")
include(BundleUtilities)
fixup_bundle(${CMAKE_SOURCE_DIR}/install/proteo.app \"\" \"\")
" COMPONENT Runtime)
else()
add_executable(proteo proteo.c proteo_opencv.cpp)
endif()

target_link_libraries(proteo ${SWSCALE_LIBRARY} ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_GFX_LIBRARIES} ${OPENSSL_LIBRARIES} ${LUAJIT_LIBRARIES} ${CURL_LIBRARIES} ${JSONC_LIBRARIES} ${OpenCV_LIBS} ${ZMQ_LIBRARIES}) #${ENET_LIBRARIES}
if(TFLITE_FOUND)
target_link_libraries(proteo ${TensorFlowLite_LIBRARY})
endif()

if (GLEW_FOUND)
target_link_libraries(proteo ${GLEW_LIBRARIES} ${OPENGL_gl_LIBRARY})
endif()

target_link_libraries(proteo ${SWSCALE_LIBRARY} ${AVCODEC_LIBRARY} ${AVUTIL_LIBRARY} ${SDL2_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_GFX_LIBRARIES} ${OPENSSL_LIBRARIES} ${LUAJIT_LIBRARIES} ${CURL_LIBRARIES} ${JSONC_LIBRARIES} ${OpenCV_LIBS} ${ZMQ_LIBRARIES}) #${ENET_LIBRARIES}

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")

#set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
#set_property (TARGET proteo PROPERTY XCODE_SCHEME_ARGUMENTS " -g -d")
#set_property (TARGET proteo PROPERTY XCODE_SCHEME_ADDRESS_SANITIZER TRUE)

#include(InstallRequiredSystemLibraries)
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
#set(CPACK_GENERATOR "DragNDrop")
#set(CPACK_PACKAGE_NAME "Proteo")
#set(CPACK_PACKAGE_VERSION,1.0)
#set(CPACK_BUNDLE_NAME "Proteo")
#set(CPACK_BUNDLE_ICON "Proteo.icns")
#set(CPACK_BUNDLE_PLIST "Info.plist")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")
#include(CPack)

set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
set_property (TARGET proteo PROPERTY XCODE_SCHEME_ARGUMENTS " -g -d")
set_property (TARGET proteo PROPERTY XCODE_SCHEME_ADDRESS_SANITIZER TRUE)

include(CPack)

Binary file added client/Logo.ico
Binary file not shown.
Binary file added client/Proteo.icns
Binary file not shown.
1 change: 1 addition & 0 deletions client/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"2.0.0","basedir":"./","server":"http://localhost:8888","username":"demo","password":"demo","script":"","appkey":"01234567890123456789012345678901","ssl":0}
14 changes: 11 additions & 3 deletions client/em.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@

#./emsdk install latest
#./emsdk activate latest
#source ./emsdk_env.sh

#emcc -Iem-include proteo_opencv.c em-lib/liblua.a -o proteo_opencv.html --shell-file ./proteo_shell_minimal.html

if [[ $1 == DEBUG ]]; then
echo "DEBUG MODE"
emcc -Iem-include proteo.c em-lib/liblua.a -lidbfs.js -O2 -g1 -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o index.html --shell-file ./proteo_shell_minimal.html
#emcc -Iem-include proteo_opencv.cpp em-lib/liblua.a em-lib/libopencv_core.a -lidbfs.js -O2 -g1 -s LLD_REPORT_UNDEFINED -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=2 -s WASM=1 -s FETCH=1
emcc -Iem-include proteo_opencv.cpp proteo.c em-lib/liblua.a em-lib/libopencv_*.a -lidbfs.js -O2 -g1 -s LLD_REPORT_UNDEFINED -s ASSERTIONS=2 -s STACK_OVERFLOW_CHECK=2 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o index.html --shell-file ./proteo_shell_minimal.html
elif [[ $1 == SAN ]]; then
echo "SANITIZER MODE"
emcc -Iem-include proteo.c em-lib/liblua.a -lidbfs.js -O2 -g1 -fsanitize=address -s ALLOW_MEMORY_GROWTH -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o index.html --shell-file ./proteo_shell_minimal.html
emcc -Iem-include proteo_opencv.cpp proteo.c em-lib/liblua.a em-lib/libopencv_*.a -lidbfs.js -O2 -g1 -fsanitize=address -s ALLOW_MEMORY_GROWTH -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o index.html --shell-file ./proteo_shell_minimal.html
elif [[ $1 == NOOPENCV ]]; then
echo "NO OPENCV MODE"
emcc -Iem-include proteo.c em-lib/liblua.a -lidbfs.js -Oz -fsanitize=undefined -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 -g1 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback","_image_to_mat"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s NO_DISABLE_EXCEPTION_CATCHING -o index.html --shell-file ./proteo_shell_minimal.html
else
emcc -Iem-include proteo.c em-lib/liblua.a -lidbfs.js -Oz -s ASSERTIONS=1 -g1 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o index.html --shell-file ./proteo_shell_minimal.html
emcc -Iem-include proteo_opencv.cpp proteo.c em-lib/liblua.a em-lib/libopencv_*.a -lidbfs.js -Oz -fsanitize=undefined -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 -g1 -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png"]' -s USE_SDL_TTF=2 -s USE_SDL_GFX=2 -s FETCH=1 -s EXPORTED_FUNCTIONS='["_main","_em_login_function","_em_header_callback","_proteo_get_callback","_proteo_post_callback","_image_to_mat"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s NO_DISABLE_EXCEPTION_CATCHING -o index.html --shell-file ./proteo_shell_minimal.html
fi
2 changes: 2 additions & 0 deletions client/icon.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

MAINICON ICON "Logo.ico"
Loading

0 comments on commit 50e5cec

Please sign in to comment.