commit
7722a2b8a8
35 changed files with 1058 additions and 233 deletions
@ -0,0 +1,62 @@ |
||||
Contours in OpenCV {#tutorial_table_of_contents_contours} |
||||
================== |
||||
|
||||
- @subpage tutorial_find_contours |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn how to find contours of objects in our image |
||||
|
||||
- @subpage tutorial_hull |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn how to get hull contours and draw them |
||||
|
||||
- @subpage tutorial_bounding_rects_circles |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn how to obtain bounding boxes and circles for our contours |
||||
|
||||
- @subpage tutorial_bounding_rotated_ellipses |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn how to obtain rotated bounding boxes and ellipses for our contours |
||||
|
||||
- @subpage tutorial_moments |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn to calculate the moments of an image |
||||
|
||||
- @subpage tutorial_point_polygon_test |
||||
|
||||
*Languages:* C++, Java, Python |
||||
|
||||
*Compatibility:* \> OpenCV 2.0 |
||||
|
||||
*Author:* Ana Huamán |
||||
|
||||
Where we learn how to calculate distances from the image to contours |
@ -0,0 +1,113 @@ |
||||
#!/usr/bin/env python |
||||
"""Algorithm serialization test.""" |
||||
from __future__ import print_function |
||||
import tempfile |
||||
import os |
||||
import cv2 as cv |
||||
import numpy as np |
||||
from tests_common import NewOpenCVTests |
||||
|
||||
class MyData: |
||||
def __init__(self): |
||||
self.A = 97 |
||||
self.X = np.pi |
||||
self.name = 'mydata1234' |
||||
|
||||
def write(self, fs, name): |
||||
fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW) |
||||
fs.write('A', self.A) |
||||
fs.write('X', self.X) |
||||
fs.write('name', self.name) |
||||
fs.endWriteStruct() |
||||
|
||||
def read(self, node): |
||||
if (not node.empty()): |
||||
self.A = int(node.getNode('A').real()) |
||||
self.X = node.getNode('X').real() |
||||
self.name = node.getNode('name').string() |
||||
else: |
||||
self.A = self.X = 0 |
||||
self.name = '' |
||||
|
||||
class filestorage_io_test(NewOpenCVTests): |
||||
strings_data = ['image1.jpg', 'Awesomeness', '../data/baboon.jpg'] |
||||
R0 = np.eye(3,3) |
||||
T0 = np.zeros((3,1)) |
||||
|
||||
def write_data(self, fname): |
||||
fs = cv.FileStorage(fname, cv.FileStorage_WRITE) |
||||
R = self.R0 |
||||
T = self.T0 |
||||
m = MyData() |
||||
|
||||
fs.write('iterationNr', 100) |
||||
|
||||
fs.startWriteStruct('strings', cv.FileNode_SEQ) |
||||
for elem in self.strings_data: |
||||
fs.write('', elem) |
||||
fs.endWriteStruct() |
||||
|
||||
fs.startWriteStruct('Mapping', cv.FileNode_MAP) |
||||
fs.write('One', 1) |
||||
fs.write('Two', 2) |
||||
fs.endWriteStruct() |
||||
|
||||
fs.write('R_MAT', R) |
||||
fs.write('T_MAT', T) |
||||
|
||||
m.write(fs, 'MyData') |
||||
fs.release() |
||||
|
||||
def read_data_and_check(self, fname): |
||||
fs = cv.FileStorage(fname, cv.FileStorage_READ) |
||||
|
||||
n = fs.getNode('iterationNr') |
||||
itNr = int(n.real()) |
||||
self.assertEqual(itNr, 100) |
||||
|
||||
n = fs.getNode('strings') |
||||
self.assertTrue(n.isSeq()) |
||||
self.assertEqual(n.size(), len(self.strings_data)) |
||||
|
||||
for i in range(n.size()): |
||||
self.assertEqual(n.at(i).string(), self.strings_data[i]) |
||||
|
||||
n = fs.getNode('Mapping') |
||||
self.assertEqual(int(n.getNode('Two').real()), 2) |
||||
self.assertEqual(int(n.getNode('One').real()), 1) |
||||
|
||||
R = fs.getNode('R_MAT').mat() |
||||
T = fs.getNode('T_MAT').mat() |
||||
|
||||
self.assertEqual(cv.norm(R, self.R0, cv.NORM_INF), 0) |
||||
self.assertEqual(cv.norm(T, self.T0, cv.NORM_INF), 0) |
||||
|
||||
m0 = MyData() |
||||
m = MyData() |
||||
m.read(fs.getNode('MyData')) |
||||
self.assertEqual(m.A, m0.A) |
||||
self.assertEqual(m.X, m0.X) |
||||
self.assertEqual(m.name, m0.name) |
||||
|
||||
n = fs.getNode('NonExisting') |
||||
self.assertTrue(n.isNone()) |
||||
fs.release() |
||||
|
||||
def run_fs_test(self, ext): |
||||
fd, fname = tempfile.mkstemp(prefix="opencv_python_sample_filestorage", suffix=ext) |
||||
os.close(fd) |
||||
self.write_data(fname) |
||||
self.read_data_and_check(fname) |
||||
os.remove(fname) |
||||
|
||||
def test_xml(self): |
||||
self.run_fs_test(".xml") |
||||
|
||||
def test_yml(self): |
||||
self.run_fs_test(".yml") |
||||
|
||||
def test_json(self): |
||||
self.run_fs_test(".json") |
||||
|
||||
if __name__ == '__main__': |
||||
NewOpenCVTests.bootstrap() |
@ -0,0 +1,202 @@ |
||||
diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt
|
||||
index e7ea6547..7333d19c 100644
|
||||
--- a/inference-engine/CMakeLists.txt
|
||||
+++ b/inference-engine/CMakeLists.txt
|
||||
@@ -72,11 +72,11 @@ if(ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
-add_subdirectory(tools)
|
||||
+#add_subdirectory(tools)
|
||||
|
||||
# gflags and format_reader targets are kept inside of samples directory and
|
||||
# they must be built even if samples build is disabled (required for tests and tools).
|
||||
-add_subdirectory(samples)
|
||||
+#add_subdirectory(samples)
|
||||
|
||||
file(GLOB_RECURSE SAMPLES_SOURCES samples/*.cpp samples/*.hpp samples/*.h)
|
||||
add_cpplint_target(sample_cpplint
|
||||
@@ -154,10 +154,10 @@ endif()
|
||||
# Developer package
|
||||
#
|
||||
|
||||
-ie_developer_export_targets(format_reader)
|
||||
+#ie_developer_export_targets(format_reader)
|
||||
ie_developer_export_targets(${NGRAPH_LIBRARIES})
|
||||
|
||||
-ie_developer_export()
|
||||
+#ie_developer_export()
|
||||
|
||||
configure_file(
|
||||
"${IE_MAIN_SOURCE_DIR}/cmake/developer_package_config.cmake.in"
|
||||
diff --git a/inference-engine/src/legacy_api/CMakeLists.txt b/inference-engine/src/legacy_api/CMakeLists.txt
|
||||
index a03a5f23..63d4f687 100644
|
||||
--- a/inference-engine/src/legacy_api/CMakeLists.txt
|
||||
+++ b/inference-engine/src/legacy_api/CMakeLists.txt
|
||||
@@ -22,7 +22,7 @@ source_group("include" FILES ${PUBLIC_HEADERS})
|
||||
|
||||
# Create object library
|
||||
|
||||
-add_library(${TARGET_NAME}_obj OBJECT
|
||||
+add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
|
||||
${LIBRARY_SRC}
|
||||
${NN_BUILDER_LIBRARY_SRC}
|
||||
${PUBLIC_HEADERS})
|
||||
diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
index 2071c126..015d8ff8 100644
|
||||
--- a/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
+++ b/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
@@ -98,7 +98,7 @@ add_clang_format_target(${TARGET_NAME}_plugin_api_clang_format FOR_SOURCES ${plu
|
||||
|
||||
# Create common base object library
|
||||
|
||||
-add_library(${TARGET_NAME}_common_obj OBJECT
|
||||
+add_library(${TARGET_NAME}_common_obj OBJECT EXCLUDE_FROM_ALL
|
||||
${IE_BASE_SOURCE_FILES})
|
||||
|
||||
target_compile_definitions(${TARGET_NAME}_common_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API)
|
||||
@@ -110,7 +110,7 @@ target_include_directories(${TARGET_NAME}_common_obj SYSTEM PRIVATE
|
||||
|
||||
# Create object library
|
||||
|
||||
-add_library(${TARGET_NAME}_obj OBJECT
|
||||
+add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
|
||||
${LIBRARY_SRC}
|
||||
${LIBRARY_HEADERS}
|
||||
${PUBLIC_HEADERS})
|
||||
@@ -200,7 +200,7 @@ add_clang_format_target(${TARGET_NAME}_nn_builder_clang_format FOR_TARGETS ${TAR
|
||||
|
||||
# Static library used for unit tests which are always built
|
||||
|
||||
-add_library(${TARGET_NAME}_s STATIC
|
||||
+add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL
|
||||
$<TARGET_OBJECTS:${TARGET_NAME}_obj>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME}_common_obj>
|
||||
$<TARGET_OBJECTS:${TARGET_NAME}_legacy_obj>
|
||||
diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
index 52183e86..4fd6d7d4 100644
|
||||
--- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
+++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
@@ -163,9 +163,9 @@ add_library(mkldnn_plugin_layers_no_opt OBJECT ${CROSS_COMPILED_SOURCES})
|
||||
set_ie_threading_interface_for(mkldnn_plugin_layers_no_opt)
|
||||
target_compile_definitions(mkldnn_plugin_layers_no_opt PRIVATE "IMPLEMENT_INFERENCE_ENGINE_PLUGIN")
|
||||
|
||||
-add_library(mkldnn_plugin_layers_no_opt_s OBJECT ${CROSS_COMPILED_SOURCES})
|
||||
-set_ie_threading_interface_for(mkldnn_plugin_layers_no_opt_s)
|
||||
-target_compile_definitions(mkldnn_plugin_layers_no_opt_s PRIVATE "USE_STATIC_IE;IMPLEMENT_INFERENCE_ENGINE_PLUGIN")
|
||||
+#add_library(mkldnn_plugin_layers_no_opt_s OBJECT ${CROSS_COMPILED_SOURCES})
|
||||
+#set_ie_threading_interface_for(mkldnn_plugin_layers_no_opt_s)
|
||||
+#target_compile_definitions(mkldnn_plugin_layers_no_opt_s PRIVATE "USE_STATIC_IE;IMPLEMENT_INFERENCE_ENGINE_PLUGIN")
|
||||
|
||||
set(object_libraries mkldnn_plugin_layers_no_opt)
|
||||
set(mkldnn_plugin_object_libraries mkldnn_plugin_layers_no_opt_s)
|
||||
@@ -190,7 +190,7 @@ if (ENABLE_SSE42)
|
||||
endfunction()
|
||||
|
||||
mkldnn_create_sse42_layers(mkldnn_plugin_layers_sse42)
|
||||
- mkldnn_create_sse42_layers(mkldnn_plugin_layers_sse42_s)
|
||||
+ #mkldnn_create_sse42_layers(mkldnn_plugin_layers_sse42_s)
|
||||
|
||||
list(APPEND object_libraries mkldnn_plugin_layers_sse42)
|
||||
list(APPEND mkldnn_plugin_object_libraries mkldnn_plugin_layers_sse42_s)
|
||||
@@ -216,7 +216,7 @@ if (ENABLE_AVX2)
|
||||
endfunction()
|
||||
|
||||
mkldnn_create_avx2_layers(mkldnn_plugin_layers_avx2)
|
||||
- mkldnn_create_avx2_layers(mkldnn_plugin_layers_avx2_s)
|
||||
+ #mkldnn_create_avx2_layers(mkldnn_plugin_layers_avx2_s)
|
||||
|
||||
list(APPEND object_libraries mkldnn_plugin_layers_avx2)
|
||||
list(APPEND mkldnn_plugin_object_libraries mkldnn_plugin_layers_avx2_s)
|
||||
@@ -242,7 +242,7 @@ if (ENABLE_AVX512F)
|
||||
endfunction()
|
||||
|
||||
mkldnn_create_avx512f_layers(mkldnn_plugin_layers_avx512)
|
||||
- mkldnn_create_avx512f_layers(mkldnn_plugin_layers_avx512_s)
|
||||
+ #mkldnn_create_avx512f_layers(mkldnn_plugin_layers_avx512_s)
|
||||
|
||||
list(APPEND object_libraries mkldnn_plugin_layers_avx512)
|
||||
list(APPEND mkldnn_plugin_object_libraries mkldnn_plugin_layers_avx512_s)
|
||||
@@ -264,7 +264,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE inference_engine inference_engine_l
|
||||
|
||||
# add test object library
|
||||
|
||||
-add_library(${TARGET_NAME}_obj OBJECT ${SOURCES} ${HEADERS})
|
||||
+add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL ${SOURCES} ${HEADERS})
|
||||
|
||||
target_include_directories(${TARGET_NAME}_obj PRIVATE $<TARGET_PROPERTY:inference_engine_preproc_s,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
$<TARGET_PROPERTY:inference_engine_lp_transformations,INTERFACE_INCLUDE_DIRECTORIES>
|
||||
diff --git a/inference-engine/src/preprocessing/CMakeLists.txt b/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
index c3ad1e58..b5913840 100644
|
||||
--- a/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
+++ b/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
@@ -124,7 +124,7 @@ endif()
|
||||
|
||||
# Create object library
|
||||
|
||||
-add_library(${TARGET_NAME}_obj OBJECT
|
||||
+add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
|
||||
${LIBRARY_SRC}
|
||||
${LIBRARY_HEADERS})
|
||||
|
||||
@@ -167,7 +167,7 @@ endif()
|
||||
|
||||
# Static library used for unit tests which are always built
|
||||
|
||||
-add_library(${TARGET_NAME}_s STATIC
|
||||
+add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL
|
||||
$<TARGET_OBJECTS:${TARGET_NAME}_obj>)
|
||||
|
||||
set_ie_threading_interface_for(${TARGET_NAME}_s)
|
||||
diff --git a/inference-engine/src/vpu/common/CMakeLists.txt b/inference-engine/src/vpu/common/CMakeLists.txt
|
||||
index 65215299..03ba4a4c 100644
|
||||
--- a/inference-engine/src/vpu/common/CMakeLists.txt
|
||||
+++ b/inference-engine/src/vpu/common/CMakeLists.txt
|
||||
@@ -53,7 +53,7 @@ add_common_target("vpu_common_lib" FALSE)
|
||||
|
||||
# Unit tests support for graph transformer
|
||||
if(WIN32)
|
||||
- add_common_target("vpu_common_lib_test_static" TRUE)
|
||||
+ #add_common_target("vpu_common_lib_test_static" TRUE)
|
||||
else()
|
||||
add_library("vpu_common_lib_test_static" ALIAS "vpu_common_lib")
|
||||
endif()
|
||||
diff --git a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
|
||||
index 982d3c7f..15fcf3e8 100644
|
||||
--- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
|
||||
+++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
|
||||
@@ -64,7 +64,7 @@ add_graph_transformer_target("vpu_graph_transformer" FALSE)
|
||||
|
||||
# Unit tests support for graph transformer
|
||||
if(WIN32)
|
||||
- add_graph_transformer_target("vpu_graph_transformer_test_static" TRUE)
|
||||
+ #add_graph_transformer_target("vpu_graph_transformer_test_static" TRUE)
|
||||
else()
|
||||
add_library("vpu_graph_transformer_test_static" ALIAS "vpu_graph_transformer")
|
||||
endif()
|
||||
diff --git a/inference-engine/thirdparty/CMakeLists.txt b/inference-engine/thirdparty/CMakeLists.txt
|
||||
index ebf32c71..ad8cb435 100644
|
||||
--- a/inference-engine/thirdparty/CMakeLists.txt
|
||||
+++ b/inference-engine/thirdparty/CMakeLists.txt
|
||||
@@ -36,7 +36,7 @@ function(build_with_lto)
|
||||
endif()
|
||||
|
||||
add_subdirectory(pugixml)
|
||||
- add_subdirectory(stb_lib)
|
||||
+ #add_subdirectory(stb_lib)
|
||||
add_subdirectory(ade)
|
||||
add_subdirectory(fluid/modules/gapi)
|
||||
|
||||
diff --git a/inference-engine/thirdparty/pugixml/CMakeLists.txt b/inference-engine/thirdparty/pugixml/CMakeLists.txt
|
||||
index 8bcb2801..f7e031c0 100644
|
||||
--- a/inference-engine/thirdparty/pugixml/CMakeLists.txt
|
||||
+++ b/inference-engine/thirdparty/pugixml/CMakeLists.txt
|
||||
@@ -41,7 +41,7 @@ if(BUILD_SHARED_LIBS)
|
||||
else()
|
||||
add_library(pugixml STATIC ${SOURCES})
|
||||
if (MSVC)
|
||||
- add_library(pugixml_mt STATIC ${SOURCES})
|
||||
+ #add_library(pugixml_mt STATIC ${SOURCES})
|
||||
#if (WIN32)
|
||||
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
@ -0,0 +1,13 @@ |
||||
diff --git a/cmake/developer_package.cmake b/cmake/developer_package.cmake
|
||||
index bed73503..5124795a 100644
|
||||
--- a/cmake/developer_package.cmake
|
||||
+++ b/cmake/developer_package.cmake
|
||||
@@ -137,7 +137,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
-set(OUTPUT_ROOT ${OpenVINO_MAIN_SOURCE_DIR})
|
||||
+set(OUTPUT_ROOT "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# Enable postfixes for Debug/Release builds
|
||||
set(IE_DEBUG_POSTFIX_WIN "d")
|
@ -0,0 +1,14 @@ |
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index edf8233f..cf197376 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -18,6 +18,9 @@ endif()
|
||||
|
||||
project(OpenVINO)
|
||||
|
||||
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /FS")
|
||||
+set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
|
||||
+
|
||||
set(OpenVINO_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(IE_MAIN_SOURCE_DIR ${OpenVINO_MAIN_SOURCE_DIR}/inference-engine)
|
||||
set(CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
@ -0,0 +1,13 @@ |
||||
diff --git a/inference-engine/src/CMakeLists.txt b/inference-engine/src/CMakeLists.txt
|
||||
index 7e9f590..a460c17 100644
|
||||
--- a/inference-engine/src/CMakeLists.txt
|
||||
+++ b/inference-engine/src/CMakeLists.txt
|
||||
@@ -24,7 +24,7 @@ endif()
|
||||
|
||||
add_subdirectory(hetero_plugin)
|
||||
|
||||
-add_subdirectory(multi_device)
|
||||
+#add_subdirectory(multi_device)
|
||||
|
||||
add_subdirectory(transformations)
|
||||
|
@ -0,0 +1,4 @@ |
||||
applyPatch('20200413-dldt-disable-unused-targets.patch') |
||||
applyPatch('20200413-dldt-fix-binaries-location.patch') |
||||
applyPatch('20200413-dldt-pdb.patch') |
||||
applyPatch('20200604-dldt-disable-multidevice.patch') |
@ -0,0 +1,57 @@ |
||||
sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin') |
||||
copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph') |
||||
#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll') |
||||
|
||||
build_config = 'Release' if not self.config.build_debug else 'Debug' |
||||
build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config |
||||
|
||||
def copy_bin(name): |
||||
global build_bin_dir, sysroot_bin_dir |
||||
copytree(build_bin_dir / name, sysroot_bin_dir / name) |
||||
|
||||
dll_suffix = 'd' if self.config.build_debug else '' |
||||
def copy_dll(name): |
||||
global copy_bin, dll_suffix |
||||
copy_bin(name + dll_suffix + '.dll') |
||||
copy_bin(name + dll_suffix + '.pdb') |
||||
|
||||
copy_bin('cldnn_global_custom_kernels') |
||||
copy_bin('cache.json') |
||||
copy_dll('clDNNPlugin') |
||||
copy_dll('HeteroPlugin') |
||||
copy_dll('inference_engine') |
||||
copy_dll('inference_engine_legacy') |
||||
copy_dll('inference_engine_nn_builder') |
||||
copy_dll('inference_engine_transformations') # runtime |
||||
copy_dll('inference_engine_lp_transformations') # runtime |
||||
copy_dll('MKLDNNPlugin') # runtime |
||||
copy_dll('myriadPlugin') # runtime |
||||
#copy_dll('MultiDevicePlugin') # runtime, not used |
||||
copy_dll('ngraph') |
||||
copy_bin('plugins.xml') |
||||
copytree(self.build_dir / 'bin' / 'intel64' / 'pcie-ma248x.elf', sysroot_bin_dir / 'pcie-ma248x.elf') |
||||
copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2x8x.mvcmd', sysroot_bin_dir / 'usb-ma2x8x.mvcmd') |
||||
copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2450.mvcmd', sysroot_bin_dir / 'usb-ma2450.mvcmd') |
||||
|
||||
copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb' / 'bin', sysroot_bin_dir) |
||||
copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb', self.sysrootdir / 'tbb') |
||||
|
||||
sysroot_ie_dir = prepare_dir(self.sysrootdir / 'deployment_tools' / 'inference_engine') |
||||
sysroot_ie_lib_dir = prepare_dir(sysroot_ie_dir / 'lib' / 'intel64') |
||||
|
||||
copytree(self.srcdir / 'inference-engine' / 'include', sysroot_ie_dir / 'include') |
||||
if not self.config.build_debug: |
||||
copytree(self.build_dir / 'install' / 'lib' / 'ngraph.lib', sysroot_ie_lib_dir / 'ngraph.lib') |
||||
copytree(build_bin_dir / 'inference_engine.lib', sysroot_ie_lib_dir / 'inference_engine.lib') |
||||
copytree(build_bin_dir / 'inference_engine_nn_builder.lib', sysroot_ie_lib_dir / 'inference_engine_nn_builder.lib') |
||||
copytree(build_bin_dir / 'inference_engine_legacy.lib', sysroot_ie_lib_dir / 'inference_engine_legacy.lib') |
||||
else: |
||||
copytree(self.build_dir / 'install' / 'lib' / 'ngraphd.lib', sysroot_ie_lib_dir / 'ngraphd.lib') |
||||
copytree(build_bin_dir / 'inference_engined.lib', sysroot_ie_lib_dir / 'inference_engined.lib') |
||||
copytree(build_bin_dir / 'inference_engine_nn_builderd.lib', sysroot_ie_lib_dir / 'inference_engine_nn_builderd.lib') |
||||
copytree(build_bin_dir / 'inference_engine_legacyd.lib', sysroot_ie_lib_dir / 'inference_engine_legacyd.lib') |
||||
|
||||
sysroot_license_dir = prepare_dir(self.sysrootdir / 'etc' / 'licenses') |
||||
copytree(self.srcdir / 'LICENSE', sysroot_license_dir / 'dldt-LICENSE') |
||||
copytree(self.srcdir / 'ngraph/LICENSE', sysroot_license_dir / 'ngraph-LICENSE') |
||||
copytree(self.sysrootdir / 'tbb/LICENSE', sysroot_license_dir / 'tbb-LICENSE') |
@ -0,0 +1,104 @@ |
||||
//
|
||||
// this sample demonstrates parsing (segmenting) human body parts from an image using opencv's dnn,
|
||||
// based on https://github.com/Engineering-Course/LIP_JPPNet
|
||||
//
|
||||
// get the pretrained model from: https://www.dropbox.com/s/qag9vzambhhkvxr/lip_jppnet_384.pb?dl=0
|
||||
//
|
||||
|
||||
#include <opencv2/dnn.hpp> |
||||
#include <opencv2/highgui.hpp> |
||||
#include <opencv2/imgproc.hpp> |
||||
using namespace cv; |
||||
|
||||
|
||||
static Mat parse_human(const Mat &image, const std::string &model, int backend=dnn::DNN_BACKEND_DEFAULT, int target=dnn::DNN_TARGET_CPU) { |
||||
// this network expects an image and a flipped copy as input
|
||||
Mat flipped; |
||||
flip(image, flipped, 1); |
||||
std::vector<Mat> batch; |
||||
batch.push_back(image); |
||||
batch.push_back(flipped); |
||||
Mat blob = dnn::blobFromImages(batch, 1.0, Size(), Scalar(104.00698793, 116.66876762, 122.67891434)); |
||||
|
||||
dnn::Net net = dnn::readNet(model); |
||||
net.setPreferableBackend(backend); |
||||
net.setPreferableTarget(target); |
||||
net.setInput(blob); |
||||
Mat out = net.forward(); |
||||
// expected output: [2, 20, 384, 384], (2 lists(orig, flipped) of 20 body part heatmaps 384x384)
|
||||
|
||||
// LIP classes:
|
||||
// 0 Background, 1 Hat, 2 Hair, 3 Glove, 4 Sunglasses, 5 UpperClothes, 6 Dress, 7 Coat, 8 Socks, 9 Pants
|
||||
// 10 Jumpsuits, 11 Scarf, 12 Skirt, 13 Face, 14 LeftArm, 15 RightArm, 16 LeftLeg, 17 RightLeg, 18 LeftShoe. 19 RightShoe
|
||||
Vec3b colors[] = { |
||||
Vec3b(0, 0, 0), Vec3b(128, 0, 0), Vec3b(255, 0, 0), Vec3b(0, 85, 0), Vec3b(170, 0, 51), Vec3b(255, 85, 0), |
||||
Vec3b(0, 0, 85), Vec3b(0, 119, 221), Vec3b(85, 85, 0), Vec3b(0, 85, 85), Vec3b(85, 51, 0), Vec3b(52, 86, 128), |
||||
Vec3b(0, 128, 0), Vec3b(0, 0, 255), Vec3b(51, 170, 221), Vec3b(0, 255, 255), Vec3b(85, 255, 170), |
||||
Vec3b(170, 255, 85), Vec3b(255, 255, 0), Vec3b(255, 170, 0) |
||||
}; |
||||
|
||||
Mat segm(image.size(), CV_8UC3, Scalar(0,0,0)); |
||||
Mat maxval(image.size(), CV_32F, Scalar(0)); |
||||
|
||||
// iterate over body part heatmaps (LIP classes)
|
||||
for (int i=0; i<out.size[1]; i++) { |
||||
// resize heatmaps to original image size
|
||||
// "head" is the original image result, "tail" the flipped copy
|
||||
Mat head, h(out.size[2], out.size[3], CV_32F, out.ptr<float>(0,i)); |
||||
resize(h, head, image.size()); |
||||
|
||||
// we have to swap the last 3 pairs in the "tail" list
|
||||
static int tail_order[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,15,14,17,16,19,18}; |
||||
Mat tail, t(out.size[2], out.size[3], CV_32F, out.ptr<float>(1,tail_order[i])); |
||||
resize(t, tail, image.size()); |
||||
flip(tail, tail, 1); |
||||
|
||||
// mix original and flipped result
|
||||
Mat avg = (head + tail) * 0.5; |
||||
|
||||
// write color if prob value > maxval
|
||||
Mat cmask; |
||||
compare(avg, maxval, cmask, CMP_GT); |
||||
segm.setTo(colors[i], cmask); |
||||
|
||||
// keep largest values for next iteration
|
||||
max(avg, maxval, maxval); |
||||
} |
||||
cvtColor(segm, segm, COLOR_RGB2BGR); |
||||
return segm; |
||||
} |
||||
|
||||
int main(int argc, char**argv) |
||||
{ |
||||
CommandLineParser parser(argc,argv, |
||||
"{help h | | show help screen / args}" |
||||
"{image i | | person image to process }" |
||||
"{model m |lip_jppnet_384.pb| network model}" |
||||
"{backend b | 0 | Choose one of computation backends: " |
||||
"0: automatically (by default), " |
||||
"1: Halide language (http://halide-lang.org/), " |
||||
"2: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), " |
||||
"3: OpenCV implementation }" |
||||
"{target t | 0 | Choose one of target computation devices: " |
||||
"0: CPU target (by default), " |
||||
"1: OpenCL, " |
||||
"2: OpenCL fp16 (half-float precision), " |
||||
"3: VPU }" |
||||
); |
||||
if (argc == 1 || parser.has("help")) |
||||
{ |
||||
parser.printMessage(); |
||||
return 0; |
||||
} |
||||
std::string model = parser.get<std::string>("model"); |
||||
std::string image = parser.get<std::string>("image"); |
||||
int backend = parser.get<int>("backend"); |
||||
int target = parser.get<int>("target"); |
||||
|
||||
Mat input = imread(image); |
||||
Mat segm = parse_human(input, model, backend, target); |
||||
|
||||
imshow("human parsing", segm); |
||||
waitKey(); |
||||
return 0; |
||||
} |
Loading…
Reference in new issue