From 364bbae3fe83fe9421aea23cdfbc2beb56043adb Mon Sep 17 00:00:00 2001 From: agsantos <aline.gondimsantos@savoirfairelinux.com> Date: Mon, 17 Aug 2020 11:29:56 -0400 Subject: [PATCH] Change preferences on-the-fly Change-Id: Iec444649c958b8c61f766f32292dc659a50658ab --- GreenScreen/CMakeLists.txt | 54 ++++++++++++++++++++--------- GreenScreen/pluginMediaHandler.cpp | 6 ++-- GreenScreen/pluginMediaHandler.h | 8 ++--- GreenScreen/pluginProcessor.cpp | 4 +-- GreenScreen/preferences-tfcc.json | 16 ++++----- GreenScreen/preferences-tflite.json | 16 ++++----- 6 files changed, 61 insertions(+), 43 deletions(-) diff --git a/GreenScreen/CMakeLists.txt b/GreenScreen/CMakeLists.txt index 1f61314..574d9b1 100644 --- a/GreenScreen/CMakeLists.txt +++ b/GreenScreen/CMakeLists.txt @@ -17,9 +17,12 @@ set (JPL_DIRECTORY ${PROJECT_BINARY_DIR}/jpl) if(WIN32) message(OS:\ WINDOWS\ ${CMAKE_SYSTEM_PROCESSOR}) - set (CONTRIB_PLATFORM_CURT ${CMAKE_SYSTEM_PROCESSOR}) + if (NOT ${CMAKE_CL_64}) + message( FATAL_ERROR "\nUse CMake only for x64 Windows" ) + endif() + set (CONTRIB_PLATFORM_CURT x64) set (CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-windows) - set (LIBRARY_FILE_NAME lib${PLUGIN_NAME}.dll) + set (LIBRARY_FILE_NAME ${PLUGIN_NAME}.dll) set (LIBS_DIR $ENV{HOME}/Documents/GITHUB/Libs) set (OPENCV $ENV{HOME}/Documents/GITHUB/opencv/build-bash/) set (FFMPEG ${CONTRIB_PATH}/build/ffmpeg/Build/win32/x64) @@ -77,8 +80,7 @@ set(plugin_SRC main.cpp videoSubscriber.cpp ) -set(plugin_HDR ${ProjectName}Config.h - pluginInference.h +set(plugin_HDR pluginInference.h pluginMediaHandler.h pluginParameters.h pluginProcessor.h @@ -111,8 +113,8 @@ target_include_directories(${ProjectName} PUBLIC ${PROJECT_BINARY_DIR} ${LIBS_DIR}/${TENSORFLOW}/include/third_party/eigen3 ${LIBS_DIR}/${TENSORFLOW}/include/flatbuffers ) - -link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH} +if (WIN32) +target_link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH} ${LIBS_DIR}/${TENSORFLOW}/lib/${CONTRIB_PLATFORM} ${OPENCV}/install/x64/vc16/staticlib ${FFMPEG}/bin @@ -121,11 +123,20 @@ link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH} ${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/opencv4/3rdparty ${LIBS_DIR}/${TENSORFLOW}/lib/${CONTRIB_PLATFORM} ) -if (WIN32) + target_link_libraries(${ProjectName} PUBLIC swscale avutil libpng opencv_imgcodecs411 opencv_imgproc411 opencv_core411 ${TFLIB} zlib) endif() if (UNIX) +link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH} + ${LIBS_DIR}/${TENSORFLOW}/lib/${CONTRIB_PLATFORM} + ${OPENCV}/install/x64/vc16/staticlib + ${FFMPEG}/bin + ${LIBS_DIR} + ${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib + ${CONTRIB_PATH}/${CONTRIB_PLATFORM}/lib/opencv4/3rdparty + ${LIBS_DIR}/${TENSORFLOW}/lib/${CONTRIB_PLATFORM} + ) target_link_libraries(${ProjectName} PUBLIC swscale avutil libpng opencv_imgcodecs opencv_imgproc opencv_core ${TFLIB}) endif() @@ -145,13 +156,22 @@ add_custom_command( COMMENT "Assembling Plugin files" ) -add_custom_command( - TARGET ${ProjectName} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${LIBRARY_FILE_NAME} ${JPL_DIRECTORY}/lib/ - if (WIN32) - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${ProjectName}.lib ${JPL_DIRECTORY}/lib/ - endif() - COMMAND python ${PROJECT_SOURCE_DIR}/../assemblePlugin.py --plugins=GreenScreen - COMMENT "Generating JPL archive" -) +if (WIN32) + add_custom_command( + TARGET ${ProjectName} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${ProjectName}.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${LIBRARY_FILE_NAME} ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND python ${PROJECT_SOURCE_DIR}/../assemblePlugin.py --plugins=GreenScreen + COMMENT "Generating JPL archive" + ) +else() + add_custom_command( + TARGET ${ProjectName} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/Release/${LIBRARY_FILE_NAME} ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND python ${PROJECT_SOURCE_DIR}/../assemblePlugin.py --plugins=GreenScreen + COMMENT "Generating JPL archive" + ) + +endif() \ No newline at end of file diff --git a/GreenScreen/pluginMediaHandler.cpp b/GreenScreen/pluginMediaHandler.cpp index 41e334a..8c5d863 100644 --- a/GreenScreen/pluginMediaHandler.cpp +++ b/GreenScreen/pluginMediaHandler.cpp @@ -88,10 +88,10 @@ PluginMediaHandler::setPreferenceAttribute(const std::string& key, const std::st bool PluginMediaHandler::preferenceMapHasKey(const std::string& key) { - if (ppm_.find(key) == ppm_.end()) { - return false; + if (key == "backgroundlist") { + return true; } - return true; + return false; } void diff --git a/GreenScreen/pluginMediaHandler.h b/GreenScreen/pluginMediaHandler.h index 1a92a6e..3bf71de 100644 --- a/GreenScreen/pluginMediaHandler.h +++ b/GreenScreen/pluginMediaHandler.h @@ -41,13 +41,11 @@ public: virtual void detach() override; virtual void setPreferenceAttribute(const std::string& key, const std::string& value) override; - + virtual bool preferenceMapHasKey(const std::string& key) override; + std::shared_ptr<VideoSubscriber> mVS; - - std::string dataPath() const { return datapath_; } -private: - bool preferenceMapHasKey(const std::string& key); + std::string dataPath() const { return datapath_; } private: const std::string datapath_; diff --git a/GreenScreen/pluginProcessor.cpp b/GreenScreen/pluginProcessor.cpp index ea846e3..991bf81 100644 --- a/GreenScreen/pluginProcessor.cpp +++ b/GreenScreen/pluginProcessor.cpp @@ -43,7 +43,7 @@ namespace jami { PluginProcessor::PluginProcessor(const std::string& dataPath): -pluginInference{TFModel{dataPath + sep + "models/" + mPluginParameters->model}} +pluginInference{TFModel{dataPath + sep + "models" + sep + mPluginParameters->model}} { initModel(); setBackgroundImage(dataPath, mPluginParameters->image); @@ -52,7 +52,7 @@ pluginInference{TFModel{dataPath + sep + "models/" + mPluginParameters->model}} void PluginProcessor::setBackgroundImage(const std::string& dataPath, const std::string& value) { - backgroundPath = dataPath + sep + "backgrounds" + sep + value; + backgroundPath = dataPath + sep + "backgrounds" + sep + value; // cv::Size size = cv::Size{0,0}; if (!backgroundImage.empty()) diff --git a/GreenScreen/preferences-tfcc.json b/GreenScreen/preferences-tfcc.json index 7890955..f18e45a 100644 --- a/GreenScreen/preferences-tfcc.json +++ b/GreenScreen/preferences-tfcc.json @@ -8,10 +8,10 @@ "defaultValue": "out", "entries": ["sent", "received"], "entryValues": ["out", "in"], - "editable": "true" + "scope": "plugin" }, { - "category" : "ModelPreference", + "category" : "models", "type": "List", "key": "modellist", "title": "Model to load", @@ -19,17 +19,17 @@ "defaultValue": "mModel.pb", "entries": ["mModel"], "entryValues": ["mModel.pb"], - "editable": "false" + "scope": "plugin" }, { - "category" : "ImageBackground", - "type": "List", + "category" : "backgrounds", + "type": "UserList", "key": "backgroundlist", "title": "Background image", "summary": "Select the image background to use", "defaultValue": "background2.png", - "entries": ["Painture", "Beach"], - "entryValues": ["background1.png", "background2.png"], - "editable": "true" + "entries": [ "Add new image", "Painture", "Beach" ], + "entryValues": ["", "background1.png", "background2.png"], + "scope": "plugin,Foreground Segmentation" } ] diff --git a/GreenScreen/preferences-tflite.json b/GreenScreen/preferences-tflite.json index 54beba7..505a154 100644 --- a/GreenScreen/preferences-tflite.json +++ b/GreenScreen/preferences-tflite.json @@ -8,10 +8,10 @@ "defaultValue": "out", "entries": ["sent", "received"], "entryValues": ["out", "in"], - "editable": "true" + "scope": "plugin" }, { - "category" : "ModelPreference", + "category" : "models", "type": "List", "key": "modellist", "title": "Model to load", @@ -19,17 +19,17 @@ "defaultValue": "mModel.tflite", "entries": ["mModel"], "entryValues": ["mModel.tflite"], - "editable": "false" + "scope": "plugin" }, { - "category" : "ImageBackground", - "type": "List", + "category" : "backgrounds", + "type": "UserList", "key": "backgroundlist", "title": "Background image", "summary": "Select the image background to use", "defaultValue": "background2.png", - "entries": ["Painture", "Beach"], - "entryValues": ["background1.png", "background2.png"], - "editable": "true" + "entries": [ "Add new image", "Painture", "Beach" ], + "entryValues": ["", "background1.png", "background2.png"], + "scope": "plugin,Foreground Segmentation" } ] -- GitLab