mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Compare commits
33 Commits
4.3.0-openvino
...
3.4.10
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cc1e6fa56 | |||
| 6216bf9221 | |||
| 388a7ce86e | |||
| 5d95a500ad | |||
| 95341c2b1b | |||
| 54063c40de | |||
| 585593e9fc | |||
| f15e885baf | |||
| 9109cb1ec6 | |||
| dc9ee53ff5 | |||
| 1485968fc4 | |||
| 09134ac881 | |||
| 433c5199fd | |||
| 396f43d674 | |||
| e12b1c2209 | |||
| f6b2b49e4a | |||
| e1322cf503 | |||
| 67dfdee33f | |||
| 61c4cfd896 | |||
| be17f532e1 | |||
| 6d85fa3fd2 | |||
| 222a48577f | |||
| 353273579b | |||
| 7373ef0983 | |||
| 2740901378 | |||
| e661ad2a67 | |||
| 3a4b79173b | |||
| bdc29cccb6 | |||
| 7465125f67 | |||
| 340df65fb4 | |||
| 9a463b74dc | |||
| c920b45fb8 | |||
| 2a9a2fff66 |
+2
-2
@@ -971,11 +971,11 @@ endif()
|
||||
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
|
||||
if(ANDROID OR NOT UNIX)
|
||||
install(FILES ${OPENCV_LICENSE_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
DESTINATION ./ COMPONENT libs)
|
||||
if(OPENCV_README_FILE)
|
||||
install(FILES ${OPENCV_README_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
DESTINATION ./ COMPONENT libs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -24,10 +24,33 @@ endif()
|
||||
|
||||
# =======================
|
||||
|
||||
macro(ocv_ie_find_extra_libraries find_prefix find_suffix)
|
||||
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${find_prefix}inference_engine*${find_suffix}")
|
||||
foreach(full_path IN LISTS libraries)
|
||||
get_filename_component(library "${full_path}" NAME_WE)
|
||||
string(REPLACE "${find_prefix}" "" library "${library}")
|
||||
if(library STREQUAL "inference_engine" OR library STREQUAL "inference_engined")
|
||||
# skip
|
||||
else()
|
||||
add_library(${library} UNKNOWN IMPORTED)
|
||||
set_target_properties(${library} PROPERTIES
|
||||
IMPORTED_LOCATION "${full_path}")
|
||||
list(APPEND custom_libraries ${library})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
|
||||
if(NOT _inc OR NOT (_lib OR _lib_rel OR _lib_dbg))
|
||||
return()
|
||||
endif()
|
||||
if(NOT _lib)
|
||||
if(_lib_rel)
|
||||
set(_lib "${_lib_rel}")
|
||||
else()
|
||||
set(_lib "${_lib_dbg}")
|
||||
endif()
|
||||
endif()
|
||||
add_library(inference_engine UNKNOWN IMPORTED)
|
||||
set_target_properties(inference_engine PROPERTIES
|
||||
IMPORTED_LOCATION "${_lib}"
|
||||
@@ -37,24 +60,31 @@ function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
|
||||
)
|
||||
|
||||
set(custom_libraries "")
|
||||
file(GLOB libraries "${INF_ENGINE_LIB_DIRS}/${CMAKE_SHARED_LIBRARY_PREFIX}inference_engine_*${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
foreach(full_path IN LISTS libraries)
|
||||
get_filename_component(library "${full_path}" NAME_WE)
|
||||
string(REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}" "" library "${library}")
|
||||
add_library(${library} UNKNOWN IMPORTED)
|
||||
set_target_properties(${library} PROPERTIES
|
||||
IMPORTED_LOCATION "${full_path}")
|
||||
list(APPEND custom_libraries ${library})
|
||||
set(__prefixes "${CMAKE_FIND_LIBRARY_PREFIXES}")
|
||||
if(NOT __prefixes)
|
||||
set(__prefixes "_empty_")
|
||||
endif()
|
||||
foreach(find_prefix ${__prefixes})
|
||||
if(find_prefix STREQUAL "_empty_") # foreach doesn't iterate over empty elements
|
||||
set(find_prefix "")
|
||||
endif()
|
||||
foreach(find_suffix ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
ocv_ie_find_extra_libraries("${find_prefix}" "${find_suffix}")
|
||||
endforeach()
|
||||
if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
ocv_ie_find_extra_libraries("${find_prefix}" "")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT INF_ENGINE_RELEASE VERSION_GREATER "2018050000")
|
||||
find_library(INF_ENGINE_OMP_LIBRARY iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH)
|
||||
if(NOT INF_ENGINE_OMP_LIBRARY)
|
||||
message(WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors.")
|
||||
else()
|
||||
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
if(EXISTS "${INF_ENGINE_OMP_LIBRARY}")
|
||||
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${INF_ENGINE_OMP_LIBRARY}")
|
||||
endif()
|
||||
set(INF_ENGINE_VERSION "Unknown" CACHE STRING "")
|
||||
set(INF_ENGINE_TARGET "inference_engine;${custom_libraries}" PARENT_SCOPE)
|
||||
message(STATUS "Detected InferenceEngine: ${_msg}")
|
||||
@@ -71,6 +101,9 @@ endif()
|
||||
|
||||
if(NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS)
|
||||
find_path(ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
find_library(ie_custom_lib_dbg "inference_engined" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH) # Win32 and MacOSX
|
||||
endif()
|
||||
find_library(ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH)
|
||||
find_library(ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH)
|
||||
find_library(ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH)
|
||||
@@ -89,6 +122,9 @@ if(NOT INF_ENGINE_TARGET AND _loc)
|
||||
endif()
|
||||
set(INF_ENGINE_PLATFORM "${INF_ENGINE_PLATFORM_DEFAULT}" CACHE STRING "InferenceEngine platform (library dir)")
|
||||
find_path(ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
find_library(ie_custom_env_lib_dbg "inference_engined" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
|
||||
endif()
|
||||
find_library(ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
|
||||
find_library(ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH)
|
||||
find_library(ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH)
|
||||
|
||||
@@ -1083,6 +1083,17 @@ macro(ocv_check_dependencies)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
################################################################################
|
||||
# OpenCV tests
|
||||
################################################################################
|
||||
|
||||
if(DEFINED OPENCV_BUILD_TEST_MODULES_LIST)
|
||||
string(REPLACE "," ";" OPENCV_BUILD_TEST_MODULES_LIST "${OPENCV_BUILD_TEST_MODULES_LIST}") # support comma-separated list (,) too
|
||||
endif()
|
||||
if(DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST)
|
||||
string(REPLACE "," ";" OPENCV_BUILD_PERF_TEST_MODULES_LIST "${OPENCV_BUILD_PERF_TEST_MODULES_LIST}") # support comma-separated list (,) too
|
||||
endif()
|
||||
|
||||
# auxiliary macro to parse arguments of ocv_add_accuracy_tests and ocv_add_perf_tests commands
|
||||
macro(__ocv_parse_test_sources tests_type)
|
||||
set(OPENCV_${tests_type}_${the_module}_SOURCES "")
|
||||
@@ -1123,7 +1134,12 @@ function(ocv_add_perf_tests)
|
||||
endif()
|
||||
|
||||
set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf")
|
||||
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}")
|
||||
if(BUILD_PERF_TESTS AND EXISTS "${perf_path}"
|
||||
AND (NOT DEFINED OPENCV_BUILD_PERF_TEST_MODULES_LIST
|
||||
OR OPENCV_BUILD_PERF_TEST_MODULES_LIST STREQUAL "all"
|
||||
OR ";${OPENCV_BUILD_PERF_TEST_MODULES_LIST};" MATCHES ";${name};"
|
||||
)
|
||||
)
|
||||
__ocv_parse_test_sources(PERF ${ARGN})
|
||||
|
||||
# opencv_imgcodecs is required for imread/imwrite
|
||||
@@ -1199,7 +1215,12 @@ function(ocv_add_accuracy_tests)
|
||||
ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")")
|
||||
|
||||
set(test_path "${CMAKE_CURRENT_LIST_DIR}/test")
|
||||
if(BUILD_TESTS AND EXISTS "${test_path}")
|
||||
if(BUILD_TESTS AND EXISTS "${test_path}"
|
||||
AND (NOT DEFINED OPENCV_BUILD_TEST_MODULES_LIST
|
||||
OR OPENCV_BUILD_TEST_MODULES_LIST STREQUAL "all"
|
||||
OR ";${OPENCV_BUILD_TEST_MODULES_LIST};" MATCHES ";${name};"
|
||||
)
|
||||
)
|
||||
__ocv_parse_test_sources(TEST ${ARGN})
|
||||
|
||||
# opencv_imgcodecs is required for imread/imwrite
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 4
|
||||
#define CV_VERSION_REVISION 10
|
||||
#define CV_VERSION_STATUS "-pre"
|
||||
#define CV_VERSION_STATUS ""
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -146,6 +146,141 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
enum ROIType {
|
||||
ROI_FULL,
|
||||
ROI_2_RECT,
|
||||
ROI_2_TOP, // contiguous memory block
|
||||
ROI_2_LEFT,
|
||||
ROI_4,
|
||||
ROI_16,
|
||||
};
|
||||
static Rect getROI(enum ROIType t, const Size& sz)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case ROI_FULL: return Rect(0, 0, sz.width, sz.height);
|
||||
case ROI_2_RECT: return Rect(0, 0, sz.width * 71 / 100, sz.height * 71 / 100); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_TOP: return Rect(0, 0, sz.width, sz.height / 2); // 71 = sqrt(1/2) * 100
|
||||
case ROI_2_LEFT: return Rect(0, 0, sz.width / 2, sz.height); // 71 = sqrt(1/2) * 100
|
||||
case ROI_4: return Rect(0, 0, sz.width / 2, sz.height / 2);
|
||||
case ROI_16: return Rect(0, 0, sz.width / 4, sz.height / 4);
|
||||
}
|
||||
CV_Assert(false);
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam< tuple<cv::Size, MatType, ROIType> > OpenCLBuffer;
|
||||
|
||||
static inline void PrintTo(const tuple<cv::Size, MatType, enum ROIType>& v, std::ostream* os)
|
||||
{
|
||||
*os << "(" << get<0>(v) << ", " << typeToString(get<1>(v)) << ", ";
|
||||
enum ROIType roiType = get<2>(v);
|
||||
if (roiType == ROI_FULL)
|
||||
*os << "ROI_100_FULL";
|
||||
else if (roiType == ROI_2_RECT)
|
||||
*os << "ROI_050_RECT_HALF";
|
||||
else if (roiType == ROI_2_TOP)
|
||||
*os << "ROI_050_TOP_HALF";
|
||||
else if (roiType == ROI_2_LEFT)
|
||||
*os << "ROI_050_LEFT_HALF";
|
||||
else if (roiType == ROI_4)
|
||||
*os << "ROI_025_1/4";
|
||||
else
|
||||
*os << "ROI_012_1/16";
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_write)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_WRITE);
|
||||
m.setTo(Scalar(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_read)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
unsigned counter = 0;
|
||||
Mat m = src(roi).getMat(ACCESS_READ);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
counter += (unsigned)(ptr[x_bytes]);
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P_(OpenCLBuffer, cpu_update)
|
||||
{
|
||||
const Size srcSize = get<0>(GetParam());
|
||||
const int type = get<1>(GetParam());
|
||||
const Rect roi = getROI(get<2>(GetParam()), srcSize);
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
UMat src(srcSize, type, Scalar(1, 2, 3, 4));
|
||||
declare.in(src(roi), WARMUP_NONE);
|
||||
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
Mat m = src(roi).getMat(ACCESS_READ | ACCESS_WRITE);
|
||||
for (int y = 0; y < m.rows; y++)
|
||||
{
|
||||
uchar* ptr = m.ptr(y);
|
||||
size_t width_bytes = m.cols * m.elemSize();
|
||||
for (size_t x_bytes = 0; x_bytes < width_bytes; x_bytes++)
|
||||
ptr[x_bytes] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*FULL*/, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(szVGA, sz720p, sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1, CV_8UC2, CV_8UC3, CV_8UC4),
|
||||
testing::Values(ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ROI, OpenCLBuffer,
|
||||
testing::Combine(
|
||||
testing::Values(sz1080p, sz2160p),
|
||||
testing::Values(CV_8UC1),
|
||||
testing::Values(ROI_16, ROI_4, ROI_2_RECT, ROI_2_LEFT, ROI_2_TOP, ROI_FULL)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
} } // namespace opencv_test::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// */
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -1319,10 +1320,18 @@ void MatOp_AddEx::assign(const MatExpr& e, Mat& m, int _type) const
|
||||
cv::add(dst, e.s, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (e.a.channels() > 1)
|
||||
CV_LOG_ONCE_WARNING(NULL, "OpenCV/MatExpr: processing of multi-channel arrays might be changed in the future: "
|
||||
"https://github.com/opencv/opencv/issues/16739");
|
||||
cv::addWeighted(e.a, e.alpha, e.b, e.beta, e.s[0], dst);
|
||||
}
|
||||
}
|
||||
else if( e.s.isReal() && (dst.data != m.data || fabs(e.alpha) != 1))
|
||||
{
|
||||
if (e.a.channels() > 1)
|
||||
CV_LOG_ONCE_WARNING(NULL, "OpenCV/MatExpr: processing of multi-channel arrays might be changed in the future: "
|
||||
"https://github.com/opencv/opencv/issues/16739");
|
||||
e.a.convertTo(m, _type, e.alpha, e.s[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4607,6 +4607,17 @@ public:
|
||||
return u;
|
||||
}
|
||||
|
||||
static bool isOpenCLMapForced() // force clEnqueueMapBuffer / clEnqueueUnmapMemObject OpenCL API
|
||||
{
|
||||
static bool value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_BUFFER_FORCE_MAPPING", false);
|
||||
return value;
|
||||
}
|
||||
static bool isOpenCLCopyingForced() // force clEnqueueReadBuffer[Rect] / clEnqueueWriteBuffer[Rect] OpenCL API
|
||||
{
|
||||
static bool value = cv::utils::getConfigurationParameterBool("OPENCV_OPENCL_BUFFER_FORCE_COPYING", false);
|
||||
return value;
|
||||
}
|
||||
|
||||
void getBestFlags(const Context& ctx, int /*flags*/, UMatUsageFlags usageFlags, int& createFlags, int& flags0) const
|
||||
{
|
||||
const Device& dev = ctx.device(0);
|
||||
@@ -4614,7 +4625,15 @@ public:
|
||||
if ((usageFlags & USAGE_ALLOCATE_HOST_MEMORY) != 0)
|
||||
createFlags |= CL_MEM_ALLOC_HOST_PTR;
|
||||
|
||||
if( dev.hostUnifiedMemory() )
|
||||
if (!isOpenCLCopyingForced() &&
|
||||
(isOpenCLMapForced() ||
|
||||
(dev.hostUnifiedMemory()
|
||||
#ifndef __APPLE__
|
||||
|| dev.isIntel()
|
||||
#endif
|
||||
)
|
||||
)
|
||||
)
|
||||
flags0 = 0;
|
||||
else
|
||||
flags0 = UMatData::COPY_ON_MAP;
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#endif
|
||||
|
||||
#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ \
|
||||
|| defined __HAIKU__ || defined __EMSCRIPTEN__
|
||||
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -95,6 +95,9 @@
|
||||
*/
|
||||
|
||||
#if defined HAVE_TBB
|
||||
#ifndef TBB_SUPPRESS_DEPRECATED_MESSAGES // supress warning
|
||||
#define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
|
||||
#endif
|
||||
#include "tbb/tbb.h"
|
||||
#include "tbb/task.h"
|
||||
#include "tbb/tbb_stddef.h"
|
||||
|
||||
@@ -251,10 +251,10 @@ void icvClose( CvFileStorage* fs, cv::String* out )
|
||||
else if ( fs->fmt == CV_STORAGE_FORMAT_JSON )
|
||||
icvPuts( fs, "}\n" );
|
||||
}
|
||||
|
||||
icvCloseFile(fs);
|
||||
}
|
||||
|
||||
icvCloseFile(fs);
|
||||
|
||||
if( fs->outbuf && out )
|
||||
{
|
||||
*out = cv::String(fs->outbuf->begin(), fs->outbuf->end());
|
||||
|
||||
@@ -68,10 +68,9 @@ static bool is_param_exist( const std::vector<std::string> & params, const std::
|
||||
|
||||
//===========================================================================================
|
||||
|
||||
CV_IMPL CvFileStorage*
|
||||
cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const char* encoding )
|
||||
static
|
||||
void cvOpenFileStorage_(CvFileStorage*& fs, const char* query, CvMemStorage* dststorage, int flags, const char* encoding)
|
||||
{
|
||||
CvFileStorage* fs = 0;
|
||||
int default_block_size = 1 << 18;
|
||||
bool append = (flags & 3) == CV_STORAGE_APPEND;
|
||||
bool mem = (flags & CV_STORAGE_MEMORY) != 0;
|
||||
@@ -104,10 +103,6 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
|
||||
if( mem && append )
|
||||
CV_Error( CV_StsBadFlag, "CV_STORAGE_APPEND and CV_STORAGE_MEMORY are not currently compatible" );
|
||||
|
||||
fs = (CvFileStorage*)cvAlloc( sizeof(*fs) );
|
||||
CV_Assert(fs);
|
||||
memset( fs, 0, sizeof(*fs));
|
||||
|
||||
fs->memstorage = cvCreateMemStorage( default_block_size );
|
||||
fs->dststorage = dststorage ? dststorage : fs->memstorage;
|
||||
|
||||
@@ -373,9 +368,12 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
|
||||
const char* yaml_signature = "%YAML";
|
||||
const char* json_signature = "{";
|
||||
const char* xml_signature = "<?xml";
|
||||
char buf[16];
|
||||
icvGets( fs, buf, sizeof(buf)-2 );
|
||||
char* bufPtr = cv_skip_BOM(buf);
|
||||
char buf[16] = { 0 };
|
||||
char* bufPtr = icvGets( fs, buf, sizeof(buf)-2);
|
||||
if (!bufPtr)
|
||||
CV_Error(CV_BADARG_ERR, "Can't read from input stream or input stream is empty");
|
||||
bufPtr = cv_skip_BOM(bufPtr);
|
||||
CV_Assert(bufPtr);
|
||||
size_t bufOffset = bufPtr - buf;
|
||||
|
||||
if(strncmp( bufPtr, yaml_signature, strlen(yaml_signature) ) == 0)
|
||||
@@ -417,21 +415,12 @@ cvOpenFileStorage( const char* query, CvMemStorage* dststorage, int flags, const
|
||||
|
||||
//mode = cvGetErrMode();
|
||||
//cvSetErrMode( CV_ErrModeSilent );
|
||||
try
|
||||
switch (fs->fmt)
|
||||
{
|
||||
switch (fs->fmt)
|
||||
{
|
||||
case CV_STORAGE_FORMAT_XML : { icvXMLParse ( fs ); break; }
|
||||
case CV_STORAGE_FORMAT_YAML: { icvYMLParse ( fs ); break; }
|
||||
case CV_STORAGE_FORMAT_JSON: { icvJSONParse( fs ); break; }
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fs->is_opened = true;
|
||||
cvReleaseFileStorage( &fs );
|
||||
CV_RETHROW();
|
||||
case CV_STORAGE_FORMAT_XML : { icvXMLParse ( fs ); break; }
|
||||
case CV_STORAGE_FORMAT_YAML: { icvYMLParse ( fs ); break; }
|
||||
case CV_STORAGE_FORMAT_JSON: { icvJSONParse( fs ); break; }
|
||||
default: break;
|
||||
}
|
||||
//cvSetErrMode( mode );
|
||||
|
||||
@@ -457,9 +446,28 @@ _exit_:
|
||||
}
|
||||
}
|
||||
|
||||
return fs;
|
||||
return;
|
||||
}
|
||||
|
||||
CV_IMPL CvFileStorage*
|
||||
cvOpenFileStorage(const char* query, CvMemStorage* dststorage, int flags, const char* encoding)
|
||||
{
|
||||
CvFileStorage* fs = (CvFileStorage*)cvAlloc( sizeof(*fs) );
|
||||
CV_Assert(fs);
|
||||
memset( fs, 0, sizeof(*fs));
|
||||
|
||||
try
|
||||
{
|
||||
cvOpenFileStorage_(fs, query, dststorage, flags, encoding);
|
||||
return fs;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (fs)
|
||||
cvReleaseFileStorage(&fs);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/* closes file storage and deallocates buffers */
|
||||
CV_IMPL void
|
||||
|
||||
@@ -1703,4 +1703,65 @@ TEST(Core_InputOutput, FileStorage_YAML_parse_multiple_documents)
|
||||
ASSERT_EQ(0, std::remove(filename.c_str()));
|
||||
}
|
||||
|
||||
TEST(Core_InputOutput, FileStorage_empty_16823)
|
||||
{
|
||||
std::string fname = tempfile("test_fs_empty.yml");
|
||||
{
|
||||
// create empty file
|
||||
std::ofstream f(fname.c_str(), std::ios::out);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileStorage fs(fname, FileStorage::READ);
|
||||
ADD_FAILURE() << "Exception must be thrown for empty file.";
|
||||
}
|
||||
catch (const cv::Exception&)
|
||||
{
|
||||
// expected way
|
||||
// closed files can be checked manually through 'strace'
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
ADD_FAILURE() << "Unexpected exception: " << e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ADD_FAILURE() << "Unexpected unknown C++ exception";
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, remove(fname.c_str()));
|
||||
}
|
||||
|
||||
TEST(Core_InputOutput, FileStorage_open_empty_16823)
|
||||
{
|
||||
std::string fname = tempfile("test_fs_open_empty.yml");
|
||||
{
|
||||
// create empty file
|
||||
std::ofstream f(fname.c_str(), std::ios::out);
|
||||
}
|
||||
|
||||
FileStorage fs;
|
||||
try
|
||||
{
|
||||
fs.open(fname, FileStorage::READ);
|
||||
ADD_FAILURE() << "Exception must be thrown for empty file.";
|
||||
}
|
||||
catch (const cv::Exception&)
|
||||
{
|
||||
// expected way
|
||||
// closed files can be checked manually through 'strace'
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
ADD_FAILURE() << "Unexpected exception: " << e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ADD_FAILURE() << "Unexpected unknown C++ exception";
|
||||
}
|
||||
|
||||
EXPECT_EQ(0, remove(fname.c_str()));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -100,6 +100,7 @@ endif()
|
||||
ocv_module_include_directories(${include_dirs})
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
ocv_append_source_files_cxx_compiler_options(fw_srcs "-Wno-suggest-override") # GCC
|
||||
ocv_append_source_files_cxx_compiler_options(fw_srcs "-Wno-array-bounds") # GCC 9.3.0 (Ubuntu 20.04)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
ocv_append_source_files_cxx_compiler_options(fw_srcs "-Wno-inconsistent-missing-override") # Clang
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_common.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
static
|
||||
Mat generateTestImageBGR_()
|
||||
{
|
||||
Size sz(640, 480);
|
||||
Mat result(sz, CV_8UC3, Scalar::all(0));
|
||||
|
||||
const string fname = cvtest::findDataFile("../cv/shared/baboon.png");
|
||||
Mat image = imread(fname, IMREAD_COLOR);
|
||||
CV_Assert(!image.empty());
|
||||
CV_CheckEQ(image.size(), Size(512, 512), "");
|
||||
Rect roi((640-512) / 2, 0, 512, 480);
|
||||
image(Rect(0, 0, 512, 480)).copyTo(result(roi));
|
||||
result(Rect(0, 0, 5, 5)).setTo(Scalar(0, 0, 255)); // R
|
||||
result(Rect(5, 0, 5, 5)).setTo(Scalar(0, 255, 0)); // G
|
||||
result(Rect(10, 0, 5, 5)).setTo(Scalar(255, 0, 0)); // B
|
||||
result(Rect(0, 5, 5, 5)).setTo(Scalar(128, 128, 128)); // gray
|
||||
//imshow("test_image", result); waitKey();
|
||||
return result;
|
||||
}
|
||||
Mat generateTestImageBGR()
|
||||
{
|
||||
static Mat image = generateTestImageBGR_(); // initialize once
|
||||
CV_Assert(!image.empty());
|
||||
return image;
|
||||
}
|
||||
|
||||
static
|
||||
Mat generateTestImageGrayscale_()
|
||||
{
|
||||
Mat imageBGR = generateTestImageBGR();
|
||||
CV_Assert(!imageBGR.empty());
|
||||
|
||||
Mat result;
|
||||
cvtColor(imageBGR, result, COLOR_BGR2GRAY);
|
||||
return result;
|
||||
}
|
||||
Mat generateTestImageGrayscale()
|
||||
{
|
||||
static Mat image = generateTestImageGrayscale_(); // initialize once
|
||||
return image;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,15 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
|
||||
#ifndef OPENCV_TEST_IMGCODECS_COMMON_HPP
|
||||
#define OPENCV_TEST_IMGCODECS_COMMON_HPP
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
Mat generateTestImageBGR();
|
||||
Mat generateTestImageGrayscale();
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // OPENCV_TEST_IMGCODECS_COMMON_HPP
|
||||
@@ -2,6 +2,7 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_common.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@@ -145,45 +146,6 @@ TEST(Imgcodecs_Image, read_write_bmp)
|
||||
typedef string Ext;
|
||||
typedef testing::TestWithParam<Ext> Imgcodecs_Image;
|
||||
|
||||
TEST_P(Imgcodecs_Image, read_write)
|
||||
{
|
||||
const string ext = this->GetParam();
|
||||
const string full_name = cv::tempfile(ext.c_str());
|
||||
const string _name = TS::ptr()->get_data_path() + "../cv/shared/baboon.png";
|
||||
const double thresDbell = 32;
|
||||
|
||||
Mat image = imread(_name);
|
||||
image.convertTo(image, CV_8UC3);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
imwrite(full_name, image);
|
||||
Mat loaded = imread(full_name);
|
||||
ASSERT_FALSE(loaded.empty());
|
||||
|
||||
double psnr = cvtest::PSNR(loaded, image);
|
||||
EXPECT_GT(psnr, thresDbell);
|
||||
|
||||
vector<uchar> from_file;
|
||||
FILE *f = fopen(full_name.c_str(), "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long len = ftell(f);
|
||||
from_file.resize((size_t)len);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
from_file.resize(fread(&from_file[0], 1, from_file.size(), f));
|
||||
fclose(f);
|
||||
vector<uchar> buf;
|
||||
imencode("." + ext, image, buf);
|
||||
ASSERT_EQ(buf, from_file);
|
||||
|
||||
Mat buf_loaded = imdecode(Mat(buf), 1);
|
||||
ASSERT_FALSE(buf_loaded.empty());
|
||||
|
||||
psnr = cvtest::PSNR(buf_loaded, image);
|
||||
EXPECT_GT(psnr, thresDbell);
|
||||
|
||||
EXPECT_EQ(0, remove(full_name.c_str()));
|
||||
}
|
||||
|
||||
const string exts[] = {
|
||||
#ifdef HAVE_PNG
|
||||
"png",
|
||||
@@ -209,6 +171,90 @@ const string exts[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static
|
||||
void test_image_io(const Mat& image, const std::string& fname, const std::string& ext, int imreadFlag, double psnrThreshold)
|
||||
{
|
||||
vector<uchar> buf;
|
||||
ASSERT_NO_THROW(imencode("." + ext, image, buf));
|
||||
|
||||
ASSERT_NO_THROW(imwrite(fname, image));
|
||||
|
||||
FILE *f = fopen(fname.c_str(), "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
long len = ftell(f);
|
||||
cout << "File size: " << len << " bytes" << endl;
|
||||
EXPECT_GT(len, 1024) << "File is small. Test or implementation is broken";
|
||||
fseek(f, 0, SEEK_SET);
|
||||
vector<uchar> file_buf((size_t)len);
|
||||
EXPECT_EQ(len, (long)fread(&file_buf[0], 1, (size_t)len, f));
|
||||
fclose(f); f = NULL;
|
||||
|
||||
EXPECT_EQ(buf, file_buf) << "imwrite() / imencode() calls must provide the same output (bit-exact)";
|
||||
|
||||
Mat buf_loaded = imdecode(Mat(buf), imreadFlag);
|
||||
EXPECT_FALSE(buf_loaded.empty());
|
||||
|
||||
Mat loaded = imread(fname, imreadFlag);
|
||||
EXPECT_FALSE(loaded.empty());
|
||||
|
||||
EXPECT_EQ(0, cv::norm(loaded, buf_loaded, NORM_INF)) << "imread() and imdecode() calls must provide the same result (bit-exact)";
|
||||
|
||||
double psnr = cvtest::PSNR(loaded, image);
|
||||
EXPECT_GT(psnr, psnrThreshold);
|
||||
|
||||
// not necessary due bitexact check above
|
||||
//double buf_psnr = cvtest::PSNR(buf_loaded, image);
|
||||
//EXPECT_GT(buf_psnr, psnrThreshold);
|
||||
|
||||
#if 0 // debug
|
||||
if (psnr <= psnrThreshold /*|| buf_psnr <= thresDbell*/)
|
||||
{
|
||||
cout << "File: " << fname << endl;
|
||||
imshow("origin", image);
|
||||
imshow("imread", loaded);
|
||||
imshow("imdecode", buf_loaded);
|
||||
waitKey();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_P(Imgcodecs_Image, read_write_BGR)
|
||||
{
|
||||
const string ext = this->GetParam();
|
||||
const string fname = cv::tempfile(ext.c_str());
|
||||
|
||||
double psnrThreshold = 100;
|
||||
if (ext == "jpg")
|
||||
psnrThreshold = 32;
|
||||
|
||||
Mat image = generateTestImageBGR();
|
||||
EXPECT_NO_THROW(test_image_io(image, fname, ext, IMREAD_COLOR, psnrThreshold));
|
||||
|
||||
EXPECT_EQ(0, remove(fname.c_str()));
|
||||
}
|
||||
|
||||
TEST_P(Imgcodecs_Image, read_write_GRAYSCALE)
|
||||
{
|
||||
const string ext = this->GetParam();
|
||||
|
||||
if (false
|
||||
|| ext == "ppm" // grayscale is not implemented
|
||||
|| ext == "ras" // broken (black result)
|
||||
)
|
||||
throw SkipTestException("GRAYSCALE mode is not supported");
|
||||
|
||||
const string fname = cv::tempfile(ext.c_str());
|
||||
|
||||
double psnrThreshold = 100;
|
||||
if (ext == "jpg")
|
||||
psnrThreshold = 40;
|
||||
|
||||
Mat image = generateTestImageGrayscale();
|
||||
EXPECT_NO_THROW(test_image_io(image, fname, ext, IMREAD_GRAYSCALE, psnrThreshold));
|
||||
|
||||
EXPECT_EQ(0, remove(fname.c_str()));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(imgcodecs, Imgcodecs_Image, testing::ValuesIn(exts));
|
||||
|
||||
TEST(Imgcodecs_Image, regression_9376)
|
||||
|
||||
@@ -59,8 +59,8 @@ class resizeNNInvokerAVX4 CV_FINAL :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
resizeNNInvokerAVX4(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
|
||||
resizeNNInvokerAVX4(const Mat& _src, Mat &_dst, int *_x_ofs, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs),
|
||||
ify(_ify)
|
||||
{
|
||||
}
|
||||
@@ -129,9 +129,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat src;
|
||||
Mat dst;
|
||||
int* x_ofs, pix_size4;
|
||||
const Mat& src;
|
||||
Mat& dst;
|
||||
int* x_ofs;
|
||||
double ify;
|
||||
|
||||
resizeNNInvokerAVX4(const resizeNNInvokerAVX4&);
|
||||
@@ -142,8 +142,8 @@ class resizeNNInvokerAVX2 CV_FINAL :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
resizeNNInvokerAVX2(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
|
||||
resizeNNInvokerAVX2(const Mat& _src, Mat &_dst, int *_x_ofs, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs),
|
||||
ify(_ify)
|
||||
{
|
||||
}
|
||||
@@ -235,24 +235,24 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat src;
|
||||
Mat dst;
|
||||
int* x_ofs, pix_size4;
|
||||
const Mat& src;
|
||||
Mat& dst;
|
||||
int* x_ofs;
|
||||
double ify;
|
||||
|
||||
resizeNNInvokerAVX2(const resizeNNInvokerAVX2&);
|
||||
resizeNNInvokerAVX2& operator=(const resizeNNInvokerAVX2&);
|
||||
};
|
||||
|
||||
void resizeNN2_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
|
||||
void resizeNN2_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, double ify)
|
||||
{
|
||||
resizeNNInvokerAVX2 invoker(src, dst, x_ofs, pix_size4, ify);
|
||||
resizeNNInvokerAVX2 invoker(src, dst, x_ofs, ify);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
}
|
||||
|
||||
void resizeNN4_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
|
||||
void resizeNN4_AVX2(const Range& range, const Mat& src, Mat &dst, int *x_ofs, double ify)
|
||||
{
|
||||
resizeNNInvokerAVX4 invoker(src, dst, x_ofs, pix_size4, ify);
|
||||
resizeNNInvokerAVX4 invoker(src, dst, x_ofs, ify);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
}
|
||||
|
||||
|
||||
@@ -970,8 +970,8 @@ class resizeNNInvoker :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
resizeNNInvoker(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
|
||||
resizeNNInvoker(const Mat& _src, Mat &_dst, int *_x_ofs, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs),
|
||||
ify(_ify)
|
||||
{
|
||||
}
|
||||
@@ -1043,19 +1043,18 @@ public:
|
||||
default:
|
||||
for( x = 0; x < dsize.width; x++, D += pix_size )
|
||||
{
|
||||
const int* _tS = (const int*)(S + x_ofs[x]);
|
||||
int* _tD = (int*)D;
|
||||
for( int k = 0; k < pix_size4; k++ )
|
||||
_tD[k] = _tS[k];
|
||||
const uchar* _tS = S + x_ofs[x];
|
||||
for (int k = 0; k < pix_size; k++)
|
||||
D[k] = _tS[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat src;
|
||||
Mat dst;
|
||||
int* x_ofs, pix_size4;
|
||||
const Mat& src;
|
||||
Mat& dst;
|
||||
int* x_ofs;
|
||||
double ify;
|
||||
|
||||
resizeNNInvoker(const resizeNNInvoker&);
|
||||
@@ -1069,7 +1068,6 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
|
||||
AutoBuffer<int> _x_ofs(dsize.width);
|
||||
int* x_ofs = _x_ofs.data();
|
||||
int pix_size = (int)src.elemSize();
|
||||
int pix_size4 = (int)(pix_size / sizeof(int));
|
||||
double ifx = 1./fx, ify = 1./fy;
|
||||
int x;
|
||||
|
||||
@@ -1084,9 +1082,9 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
|
||||
if(CV_CPU_HAS_SUPPORT_AVX2 && ((pix_size == 2) || (pix_size == 4)))
|
||||
{
|
||||
if(pix_size == 2)
|
||||
opt_AVX2::resizeNN2_AVX2(range, src, dst, x_ofs, pix_size4, ify);
|
||||
opt_AVX2::resizeNN2_AVX2(range, src, dst, x_ofs, ify);
|
||||
else
|
||||
opt_AVX2::resizeNN4_AVX2(range, src, dst, x_ofs, pix_size4, ify);
|
||||
opt_AVX2::resizeNN4_AVX2(range, src, dst, x_ofs, ify);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -1094,14 +1092,14 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
|
||||
if(CV_CPU_HAS_SUPPORT_SSE4_1 && ((pix_size == 2) || (pix_size == 4)))
|
||||
{
|
||||
if(pix_size == 2)
|
||||
opt_SSE4_1::resizeNN2_SSE4_1(range, src, dst, x_ofs, pix_size4, ify);
|
||||
opt_SSE4_1::resizeNN2_SSE4_1(range, src, dst, x_ofs, ify);
|
||||
else
|
||||
opt_SSE4_1::resizeNN4_SSE4_1(range, src, dst, x_ofs, pix_size4, ify);
|
||||
opt_SSE4_1::resizeNN4_SSE4_1(range, src, dst, x_ofs, ify);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
resizeNNInvoker invoker(src, dst, x_ofs, pix_size4, ify);
|
||||
resizeNNInvoker invoker(src, dst, x_ofs, ify);
|
||||
parallel_for_(range, invoker, dst.total()/(double)(1<<16));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,16 @@ namespace cv
|
||||
namespace opt_AVX2
|
||||
{
|
||||
#if CV_TRY_AVX2
|
||||
void resizeNN2_AVX2(const Range&, const Mat&, Mat&, int*, int, double);
|
||||
void resizeNN4_AVX2(const Range&, const Mat&, Mat&, int*, int, double);
|
||||
void resizeNN2_AVX2(const Range&, const Mat&, Mat&, int*, double);
|
||||
void resizeNN4_AVX2(const Range&, const Mat&, Mat&, int*, double);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace opt_SSE4_1
|
||||
{
|
||||
#if CV_TRY_SSE4_1
|
||||
void resizeNN2_SSE4_1(const Range&, const Mat&, Mat&, int*, int, double);
|
||||
void resizeNN4_SSE4_1(const Range&, const Mat&, Mat&, int*, int, double);
|
||||
void resizeNN2_SSE4_1(const Range&, const Mat&, Mat&, int*, double);
|
||||
void resizeNN4_SSE4_1(const Range&, const Mat&, Mat&, int*, double);
|
||||
|
||||
int VResizeLanczos4Vec_32f16u_SSE41(const float** src, ushort* dst, const float* beta, int width);
|
||||
#endif
|
||||
|
||||
@@ -59,8 +59,8 @@ class resizeNNInvokerSSE2 :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
resizeNNInvokerSSE2(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
|
||||
resizeNNInvokerSSE2(const Mat& _src, Mat &_dst, int *_x_ofs, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs),
|
||||
ify(_ify)
|
||||
{
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat src;
|
||||
Mat dst;
|
||||
int* x_ofs, pix_size4;
|
||||
const Mat& src;
|
||||
Mat& dst;
|
||||
int* x_ofs;
|
||||
double ify;
|
||||
|
||||
resizeNNInvokerSSE2(const resizeNNInvokerSSE2&);
|
||||
@@ -123,8 +123,8 @@ class resizeNNInvokerSSE4 :
|
||||
public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
resizeNNInvokerSSE4(const Mat& _src, Mat &_dst, int *_x_ofs, int _pix_size4, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs), pix_size4(_pix_size4),
|
||||
resizeNNInvokerSSE4(const Mat& _src, Mat &_dst, int *_x_ofs, double _ify) :
|
||||
ParallelLoopBody(), src(_src), dst(_dst), x_ofs(_x_ofs),
|
||||
ify(_ify)
|
||||
{
|
||||
}
|
||||
@@ -165,24 +165,24 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat src;
|
||||
Mat dst;
|
||||
int* x_ofs, pix_size4;
|
||||
const Mat& src;
|
||||
Mat& dst;
|
||||
int* x_ofs;
|
||||
double ify;
|
||||
|
||||
resizeNNInvokerSSE4(const resizeNNInvokerSSE4&);
|
||||
resizeNNInvokerSSE4& operator=(const resizeNNInvokerSSE4&);
|
||||
};
|
||||
|
||||
void resizeNN2_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
|
||||
void resizeNN2_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, double ify)
|
||||
{
|
||||
resizeNNInvokerSSE2 invoker(src, dst, x_ofs, pix_size4, ify);
|
||||
resizeNNInvokerSSE2 invoker(src, dst, x_ofs, ify);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
}
|
||||
|
||||
void resizeNN4_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, int pix_size4, double ify)
|
||||
void resizeNN4_SSE4_1(const Range& range, const Mat& src, Mat &dst, int *x_ofs, double ify)
|
||||
{
|
||||
resizeNNInvokerSSE4 invoker(src, dst, x_ofs, pix_size4, ify);
|
||||
resizeNNInvokerSSE4 invoker(src, dst, x_ofs, ify);
|
||||
parallel_for_(range, invoker, dst.total() / (double)(1 << 16));
|
||||
}
|
||||
|
||||
|
||||
@@ -1721,7 +1721,7 @@ TEST(Resize, lanczos4_regression_16192)
|
||||
EXPECT_EQ(cvtest::norm(dst, expected, NORM_INF), 0) << dst(Rect(0,0,8,8));
|
||||
}
|
||||
|
||||
TEST(Resize, DISABLED_nearest_regression_15075) // reverted https://github.com/opencv/opencv/pull/16497
|
||||
TEST(Resize, nearest_regression_15075)
|
||||
{
|
||||
const int C = 5;
|
||||
const int i1 = 5, j1 = 5;
|
||||
|
||||
@@ -745,7 +745,9 @@ void DpSeamFinder::computeCosts(
|
||||
{
|
||||
for (int x = roi.x; x < roi.br().x+1; ++x)
|
||||
{
|
||||
if (labels_(y, x) == l && x > 0 && labels_(y, x-1) == l)
|
||||
if (x > 0 && x < labels_.cols &&
|
||||
labels_(y, x) == l && labels_(y, x-1) == l
|
||||
)
|
||||
{
|
||||
float costColor = (diff(image1, y + dy1, x + dx1 - 1, image2, y + dy2, x + dx2) +
|
||||
diff(image1, y + dy1, x + dx1, image2, y + dy2, x + dx2 - 1)) / 2;
|
||||
@@ -769,7 +771,9 @@ void DpSeamFinder::computeCosts(
|
||||
{
|
||||
for (int x = roi.x; x < roi.br().x; ++x)
|
||||
{
|
||||
if (labels_(y, x) == l && y > 0 && labels_(y-1, x) == l)
|
||||
if (y > 0 && y < labels_.rows &&
|
||||
labels_(y, x) == l && labels_(y-1, x) == l
|
||||
)
|
||||
{
|
||||
float costColor = (diff(image1, y + dy1 - 1, x + dx1, image2, y + dy2, x + dx2) +
|
||||
diff(image1, y + dy1, x + dx1, image2, y + dy2 - 1, x + dx2)) / 2;
|
||||
|
||||
@@ -294,8 +294,7 @@ if(WIN32 AND HAVE_FFMPEG_WRAPPER)
|
||||
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
|
||||
|
||||
if(INSTALL_CREATE_DISTRIB)
|
||||
install(FILES "${ffmpeg_dir}/opencv_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}.dll")
|
||||
install(FILES "${ffmpeg_dir}/opencv_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}_64.dll")
|
||||
install(FILES "${ffmpeg_dir}/opencv_ffmpeg${FFMPEG_SUFFIX}.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -579,7 +579,7 @@ public:
|
||||
virtual bool isOpened() const CV_OVERRIDE { return isOpen; }
|
||||
virtual int getCaptureDomain() CV_OVERRIDE { return CV_CAP_MSMF; }
|
||||
protected:
|
||||
bool configureOutput(MediaType newType, cv::uint32_t outFormat, bool convertToFormat);
|
||||
bool configureOutput(MediaType newType, cv::uint32_t outFormat);
|
||||
bool setTime(double time, bool rough);
|
||||
bool configureHW(bool enable);
|
||||
|
||||
@@ -766,7 +766,7 @@ bool CvCapture_MSMF::configureHW(bool enable)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CvCapture_MSMF::configureOutput(MediaType newType, cv::uint32_t outFormat, bool convertToFormat)
|
||||
bool CvCapture_MSMF::configureOutput(MediaType newType, cv::uint32_t outFormat)
|
||||
{
|
||||
FormatStorage formats;
|
||||
formats.read(videoFileSource.Get());
|
||||
@@ -774,7 +774,7 @@ bool CvCapture_MSMF::configureOutput(MediaType newType, cv::uint32_t outFormat,
|
||||
dwStreamIndex = bestMatch.first.stream;
|
||||
nativeFormat = bestMatch.second;
|
||||
MediaType newFormat = nativeFormat;
|
||||
if (convertToFormat)
|
||||
if (convertFormat)
|
||||
{
|
||||
switch (outFormat)
|
||||
{
|
||||
@@ -834,7 +834,7 @@ bool CvCapture_MSMF::open(int index)
|
||||
camid = index;
|
||||
readCallback = cb;
|
||||
duration = 0;
|
||||
if (configureOutput(MediaType::createDefault(), outputFormat, convertFormat))
|
||||
if (configureOutput(MediaType::createDefault(), outputFormat))
|
||||
{
|
||||
frameStep = captureFormat.getFrameStep();
|
||||
}
|
||||
@@ -855,7 +855,7 @@ bool CvCapture_MSMF::open(const cv::String& _filename)
|
||||
{
|
||||
isOpen = true;
|
||||
sampleTime = 0;
|
||||
if (configureOutput(MediaType(), outputFormat, convertFormat))
|
||||
if (configureOutput(MediaType(), outputFormat))
|
||||
{
|
||||
frameStep = captureFormat.getFrameStep();
|
||||
filename = _filename;
|
||||
@@ -1298,42 +1298,43 @@ bool CvCapture_MSMF::setProperty( int property_id, double value )
|
||||
return false;
|
||||
}
|
||||
case CV_CAP_PROP_FORMAT:
|
||||
return configureOutput(newFormat, (int)cvRound(value), convertFormat);
|
||||
return configureOutput(newFormat, (int)cvRound(value));
|
||||
case CV_CAP_PROP_CONVERT_RGB:
|
||||
return configureOutput(newFormat, outputFormat, value != 0);
|
||||
convertFormat = (value != 0);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
case CV_CAP_PROP_SAR_NUM:
|
||||
if (value > 0)
|
||||
{
|
||||
newFormat.aspectRatioNum = (UINT32)cvRound(value);
|
||||
return configureOutput(newFormat, outputFormat, convertFormat);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_SAR_DEN:
|
||||
if (value > 0)
|
||||
{
|
||||
newFormat.aspectRatioDenom = (UINT32)cvRound(value);
|
||||
return configureOutput(newFormat, outputFormat, convertFormat);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_FRAME_WIDTH:
|
||||
if (value >= 0)
|
||||
{
|
||||
newFormat.width = (UINT32)cvRound(value);
|
||||
return configureOutput(newFormat, outputFormat, convertFormat);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_FRAME_HEIGHT:
|
||||
if (value >= 0)
|
||||
{
|
||||
newFormat.height = (UINT32)cvRound(value);
|
||||
return configureOutput(newFormat, outputFormat, convertFormat);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_FPS:
|
||||
if (value >= 0)
|
||||
{
|
||||
newFormat.setFramerate(value);
|
||||
return configureOutput(newFormat, outputFormat, convertFormat);
|
||||
return configureOutput(newFormat, outputFormat);
|
||||
}
|
||||
break;
|
||||
case CV_CAP_PROP_FOURCC:
|
||||
@@ -1565,7 +1566,7 @@ bool CvVideoWriter_MSMF::open( const cv::String& filename, int fourcc,
|
||||
SUCCEEDED(mediaTypeOut->SetUINT32(MF_MT_AVG_BITRATE, bitRate)) &&
|
||||
SUCCEEDED(mediaTypeOut->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive)) &&
|
||||
SUCCEEDED(MFSetAttributeSize(mediaTypeOut.Get(), MF_MT_FRAME_SIZE, videoWidth, videoHeight)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeOut.Get(), MF_MT_FRAME_RATE, (UINT32)fps, 1)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeOut.Get(), MF_MT_FRAME_RATE, (UINT32)(fps * 1000), 1000)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeOut.Get(), MF_MT_PIXEL_ASPECT_RATIO, 1, 1)) &&
|
||||
// Set the input media type.
|
||||
SUCCEEDED(MFCreateMediaType(&mediaTypeIn)) &&
|
||||
@@ -1574,7 +1575,7 @@ bool CvVideoWriter_MSMF::open( const cv::String& filename, int fourcc,
|
||||
SUCCEEDED(mediaTypeIn->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive)) &&
|
||||
SUCCEEDED(mediaTypeIn->SetUINT32(MF_MT_DEFAULT_STRIDE, 4 * videoWidth)) && //Assume BGR32 input
|
||||
SUCCEEDED(MFSetAttributeSize(mediaTypeIn.Get(), MF_MT_FRAME_SIZE, videoWidth, videoHeight)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeIn.Get(), MF_MT_FRAME_RATE, (UINT32)fps, 1)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeIn.Get(), MF_MT_FRAME_RATE, (UINT32)(fps * 1000), 1000)) &&
|
||||
SUCCEEDED(MFSetAttributeRatio(mediaTypeIn.Get(), MF_MT_PIXEL_ASPECT_RATIO, 1, 1)) &&
|
||||
// Set sink writer parameters
|
||||
SUCCEEDED(MFCreateAttributes(&spAttr, 10)) &&
|
||||
@@ -1595,7 +1596,7 @@ bool CvVideoWriter_MSMF::open( const cv::String& filename, int fourcc,
|
||||
{
|
||||
initiated = true;
|
||||
rtStart = 0;
|
||||
MFFrameRateToAverageTimePerFrame((UINT32)fps, 1, &rtDuration);
|
||||
MFFrameRateToAverageTimePerFrame((UINT32)(fps * 1000), 1000, &rtDuration);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
*.patch text eol=crlf -whitespace
|
||||
@@ -0,0 +1,158 @@
|
||||
diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt
|
||||
index d5feedb..1b7aa7e 100644
|
||||
--- a/inference-engine/CMakeLists.txt
|
||||
+++ b/inference-engine/CMakeLists.txt
|
||||
@@ -59,11 +59,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
|
||||
@@ -134,7 +134,7 @@ install(DIRECTORY ${ie_python_api_SOURCE_DIR}/sample/
|
||||
add_custom_target(ie_dev_targets ALL DEPENDS inference_engine HeteroPlugin)
|
||||
|
||||
# Developer package
|
||||
-ie_developer_export_targets(format_reader)
|
||||
+#ie_developer_export_targets(format_reader)
|
||||
|
||||
if (ENABLE_NGRAPH)
|
||||
ie_developer_export_targets(${NGRAPH_LIBRARIES})
|
||||
diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
index 54e264c..c0b7495 100644
|
||||
--- a/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
+++ b/inference-engine/src/inference_engine/CMakeLists.txt
|
||||
@@ -228,7 +228,7 @@ target_include_directories(${TARGET_NAME}_nn_builder PRIVATE "${CMAKE_CURRENT_SO
|
||||
|
||||
# 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>
|
||||
${NN_BUILDER_LIBRARY_SRC})
|
||||
|
||||
diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
index cd727fd..2f09b44 100644
|
||||
--- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
+++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
|
||||
@@ -184,9 +184,9 @@ endif()
|
||||
add_library(mkldnn_plugin_layers_no_opt OBJECT ${CROSS_COMPILED_SOURCES})
|
||||
set_ie_threading_interface_for(mkldnn_plugin_layers_no_opt)
|
||||
|
||||
-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)
|
||||
+#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)
|
||||
|
||||
set(object_libraries mkldnn_plugin_layers_no_opt)
|
||||
set(mkldnn_plugin_object_libraries mkldnn_plugin_layers_no_opt_s)
|
||||
@@ -220,7 +220,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)
|
||||
@@ -259,7 +259,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)
|
||||
@@ -297,7 +297,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)
|
||||
@@ -317,7 +317,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE inference_engine ${INTEL_ITT_LIBS}
|
||||
|
||||
# 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>)
|
||||
|
||||
diff --git a/inference-engine/src/preprocessing/CMakeLists.txt b/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
index 41f14a9..0e1b4f6 100644
|
||||
--- a/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
+++ b/inference-engine/src/preprocessing/CMakeLists.txt
|
||||
@@ -81,7 +81,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 8995390..8413faf 100644
|
||||
--- a/inference-engine/src/vpu/common/CMakeLists.txt
|
||||
+++ b/inference-engine/src/vpu/common/CMakeLists.txt
|
||||
@@ -49,7 +49,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 e77296e..333f560 100644
|
||||
--- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
|
||||
+++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
|
||||
@@ -60,7 +60,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 ec22761..8bb3325 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 8bcb280..5a17fa3 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 e59edb2..e42ac19 100644
|
||||
--- a/cmake/developer_package.cmake
|
||||
+++ b/cmake/developer_package.cmake
|
||||
@@ -99,7 +99,7 @@ if(UNIX)
|
||||
SET(LIB_DL ${CMAKE_DL_LIBS})
|
||||
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,25 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 631465f..723153b 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -567,7 +567,7 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
-include(cmake/external_gtest.cmake)
|
||||
+#include(cmake/external_gtest.cmake)
|
||||
if(NGRAPH_JSON_ENABLE)
|
||||
include(cmake/external_json.cmake)
|
||||
endif()
|
||||
@@ -623,8 +623,8 @@ endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
-add_subdirectory(test)
|
||||
-add_subdirectory(doc/examples)
|
||||
+#add_subdirectory(test)
|
||||
+#add_subdirectory(doc/examples)
|
||||
|
||||
if (NGRAPH_DOC_BUILD_ENABLE)
|
||||
add_subdirectory(doc)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index e48cee5..5823e92 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -12,6 +12,9 @@ endif()
|
||||
|
||||
project(OpenVINO)
|
||||
|
||||
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
||||
+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(CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 7900b382..b5c53d09 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -24,6 +24,8 @@ include(features)
|
||||
# include developer package
|
||||
include(developer_package)
|
||||
|
||||
+disable_deprecated_warnings()
|
||||
+
|
||||
# These options are shared with 3rdparty plugins
|
||||
# by means of developer package
|
||||
include(check_features)
|
||||
@@ -0,0 +1,5 @@
|
||||
applyPatch('20200313-ngraph-disable-tests-examples.patch', 'ngraph')
|
||||
applyPatch('20200313-dldt-disable-unused-targets.patch')
|
||||
applyPatch('20200313-dldt-fix-binaries-location.patch')
|
||||
applyPatch('20200318-dldt-pdb.patch')
|
||||
applyPatch('20200319-dldt-fix-msvs2019-v16.5.0.patch')
|
||||
@@ -0,0 +1,51 @@
|
||||
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_nn_builder')
|
||||
copy_dll('MKLDNNPlugin')
|
||||
copy_dll('myriadPlugin')
|
||||
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')
|
||||
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')
|
||||
|
||||
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,504 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os, sys
|
||||
import argparse
|
||||
import glob
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import logging as log
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
sys.exit("FATAL: Python 2.x is not supported")
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
class Fail(Exception):
|
||||
def __init__(self, text=None):
|
||||
self.t = text
|
||||
def __str__(self):
|
||||
return "ERROR" if self.t is None else self.t
|
||||
|
||||
def execute(cmd, cwd=None, shell=False):
|
||||
try:
|
||||
log.debug("Executing: %s" % cmd)
|
||||
log.info('Executing: ' + ' '.join(cmd))
|
||||
if cwd:
|
||||
log.info(" in: %s" % cwd)
|
||||
retcode = subprocess.call(cmd, shell=shell, cwd=str(cwd) if cwd else None)
|
||||
if retcode < 0:
|
||||
raise Fail("Child was terminated by signal: %s" % -retcode)
|
||||
elif retcode > 0:
|
||||
raise Fail("Child returned: %s" % retcode)
|
||||
except OSError as e:
|
||||
raise Fail("Execution failed: %d / %s" % (e.errno, e.strerror))
|
||||
|
||||
def check_executable(cmd):
|
||||
try:
|
||||
log.debug("Executing: %s" % cmd)
|
||||
result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
if not isinstance(result, str):
|
||||
result = result.decode("utf-8")
|
||||
log.debug("Result: %s" % (result + '\n').split('\n')[0])
|
||||
return True
|
||||
except OSError as e:
|
||||
log.debug('Failed: %s' % e)
|
||||
return False
|
||||
|
||||
|
||||
def rm_one(d):
|
||||
d = str(d) # Python 3.5 may not handle Path
|
||||
d = os.path.abspath(d)
|
||||
if os.path.exists(d):
|
||||
if os.path.isdir(d):
|
||||
log.info("Removing dir: %s", d)
|
||||
shutil.rmtree(d)
|
||||
elif os.path.isfile(d):
|
||||
log.info("Removing file: %s", d)
|
||||
os.remove(d)
|
||||
|
||||
|
||||
def prepare_dir(d, clean=False):
|
||||
d = str(d) # Python 3.5 may not handle Path
|
||||
d = os.path.abspath(d)
|
||||
log.info("Preparing directory: '%s' (clean: %r)", d, clean)
|
||||
if os.path.exists(d):
|
||||
if not os.path.isdir(d):
|
||||
raise Fail("Not a directory: %s" % d)
|
||||
if clean:
|
||||
for item in os.listdir(d):
|
||||
rm_one(os.path.join(d, item))
|
||||
else:
|
||||
os.makedirs(d)
|
||||
return Path(d)
|
||||
|
||||
|
||||
def check_dir(d):
|
||||
d = str(d) # Python 3.5 may not handle Path
|
||||
d = os.path.abspath(d)
|
||||
log.info("Check directory: '%s'", d)
|
||||
if os.path.exists(d):
|
||||
if not os.path.isdir(d):
|
||||
raise Fail("Not a directory: %s" % d)
|
||||
else:
|
||||
raise Fail("The directory is missing: %s" % d)
|
||||
return Path(d)
|
||||
|
||||
|
||||
# shutil.copytree fails if dst exists
|
||||
def copytree(src, dst, exclude=None):
|
||||
log.debug('copytree(%s, %s)', src, dst)
|
||||
src = str(src) # Python 3.5 may not handle Path
|
||||
dst = str(dst) # Python 3.5 may not handle Path
|
||||
if os.path.isfile(src):
|
||||
shutil.copy2(src, dst)
|
||||
return
|
||||
def copy_recurse(subdir):
|
||||
if exclude and subdir in exclude:
|
||||
log.debug(' skip: %s', subdir)
|
||||
return
|
||||
s = os.path.join(src, subdir)
|
||||
d = os.path.join(dst, subdir)
|
||||
if os.path.exists(d) or exclude:
|
||||
if os.path.isfile(s):
|
||||
shutil.copy2(s, d)
|
||||
elif os.path.isdir(s):
|
||||
if not os.path.isdir(d):
|
||||
os.makedirs(d)
|
||||
for item in os.listdir(s):
|
||||
copy_recurse(os.path.join(subdir, item))
|
||||
else:
|
||||
assert False, s + " => " + d
|
||||
else:
|
||||
if os.path.isfile(s):
|
||||
shutil.copy2(s, d)
|
||||
elif os.path.isdir(s):
|
||||
shutil.copytree(s, d)
|
||||
else:
|
||||
assert False, s + " => " + d
|
||||
copy_recurse('')
|
||||
|
||||
|
||||
def git_checkout(dst, url, branch, revision, clone_extra_args, noFetch=False):
|
||||
assert isinstance(dst, Path)
|
||||
log.info("Git checkout: '%s' (%s @ %s)", dst, url, revision)
|
||||
if noFetch:
|
||||
pass
|
||||
elif not os.path.exists(str(dst / '.git')):
|
||||
execute(cmd=['git', 'clone'] +
|
||||
(['-b', branch] if branch else []) +
|
||||
clone_extra_args + [url, '.'], cwd=dst)
|
||||
else:
|
||||
execute(cmd=['git', 'fetch', 'origin'] + ([branch] if branch else []), cwd=dst)
|
||||
execute(cmd=['git', 'reset', '--hard'], cwd=dst)
|
||||
execute(cmd=['git', 'checkout', '-B', 'winpack_dldt', revision], cwd=dst)
|
||||
execute(cmd=['git', 'clean', '-f', '-d'], cwd=dst)
|
||||
execute(cmd=['git', 'submodule', 'init'], cwd=dst)
|
||||
execute(cmd=['git', 'submodule', 'update', '--force', '--depth=1000'], cwd=dst)
|
||||
log.info("Git checkout: DONE")
|
||||
execute(cmd=['git', 'status'], cwd=dst)
|
||||
execute(cmd=['git', 'log', '--max-count=1', 'HEAD'], cwd=dst)
|
||||
|
||||
|
||||
def git_apply_patch(src_dir, patch_file):
|
||||
src_dir = str(src_dir) # Python 3.5 may not handle Path
|
||||
patch_file = str(patch_file) # Python 3.5 may not handle Path
|
||||
assert os.path.exists(patch_file), patch_file
|
||||
execute(cmd=['git', 'apply', '--3way', '-v', '--ignore-space-change', str(patch_file)], cwd=src_dir)
|
||||
|
||||
|
||||
#===================================================================================================
|
||||
|
||||
class BuilderDLDT:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
cpath = self.config.dldt_config
|
||||
log.info('DLDT build configration: %s', cpath)
|
||||
if not os.path.exists(cpath):
|
||||
cpath = os.path.join(SCRIPT_DIR, cpath)
|
||||
if not os.path.exists(cpath):
|
||||
raise Fail('Config "%s" is missing' % cpath)
|
||||
self.cpath = Path(cpath)
|
||||
|
||||
clean_src_dir = self.config.clean_dldt
|
||||
if self.config.dldt_src_dir:
|
||||
assert os.path.exists(self.config.dldt_src_dir), self.config.dldt_src_dir
|
||||
dldt_dir_name = 'dldt-custom'
|
||||
self.srcdir = self.config.dldt_src_dir
|
||||
clean_src_dir = False
|
||||
else:
|
||||
assert not self.config.dldt_src_dir
|
||||
self.init_patchset()
|
||||
dldt_dir_name = 'dldt-' + self.config.dldt_src_commit + \
|
||||
('/patch-' + self.patch_hashsum if self.patch_hashsum else '')
|
||||
if self.config.build_debug:
|
||||
dldt_dir_name += '-debug'
|
||||
self.srcdir = None # updated below
|
||||
log.info('DLDT directory: %s', dldt_dir_name)
|
||||
self.outdir = prepare_dir(os.path.join(self.config.build_cache_dir, dldt_dir_name))
|
||||
if self.srcdir is None:
|
||||
self.srcdir = prepare_dir(self.outdir / 'sources', clean=clean_src_dir)
|
||||
self.build_dir = prepare_dir(self.outdir / 'build', clean=self.config.clean_dldt)
|
||||
self.sysrootdir = prepare_dir(self.outdir / 'sysroot', clean=self.config.clean_dldt)
|
||||
|
||||
def init_patchset(self):
|
||||
cpath = self.cpath
|
||||
self.patch_file = str(cpath / 'patch.config.py') # Python 3.5 may not handle Path
|
||||
with open(self.patch_file, 'r') as f:
|
||||
self.patch_file_contents = f.read()
|
||||
|
||||
patch_hashsum = None
|
||||
try:
|
||||
import hashlib
|
||||
patch_hashsum = hashlib.md5(self.patch_file_contents.encode('utf-8')).hexdigest()
|
||||
except:
|
||||
log.warn("Can't compute hashsum of patches: %s", self.patch_file)
|
||||
self.patch_hashsum = patch_hashsum
|
||||
|
||||
|
||||
def prepare_sources(self):
|
||||
if self.config.dldt_src_dir:
|
||||
log.info('Using DLDT custom repository: %s', self.srcdir)
|
||||
return
|
||||
|
||||
def do_clone(srcdir, noFetch):
|
||||
git_checkout(srcdir, self.config.dldt_src_url, self.config.dldt_src_branch, self.config.dldt_src_commit,
|
||||
['-n', '--depth=100', '--recurse-submodules'] +
|
||||
(self.config.dldt_src_git_clone_extra or []),
|
||||
noFetch=noFetch
|
||||
)
|
||||
|
||||
if not os.path.exists(str(self.srcdir / '.git')):
|
||||
log.info('DLDT git checkout through "reference" copy.')
|
||||
reference_dir = self.config.dldt_reference_dir
|
||||
if reference_dir is None:
|
||||
reference_dir = prepare_dir(os.path.join(self.config.build_cache_dir, 'dldt-git-reference-repository'))
|
||||
do_clone(reference_dir, False)
|
||||
log.info('DLDT reference git checkout completed. Copying...')
|
||||
else:
|
||||
log.info('Using DLDT reference repository. Copying...')
|
||||
copytree(reference_dir, self.srcdir)
|
||||
do_clone(self.srcdir, True)
|
||||
else:
|
||||
do_clone(self.srcdir, False)
|
||||
|
||||
log.info('DLDT git checkout completed. Patching...')
|
||||
|
||||
def applyPatch(patch_file, subdir = None):
|
||||
if subdir:
|
||||
log.info('Patching "%s": %s' % (subdir, patch_file))
|
||||
else:
|
||||
log.info('Patching: %s' % (patch_file))
|
||||
git_apply_patch(self.srcdir / subdir if subdir else self.srcdir, self.cpath / patch_file)
|
||||
|
||||
exec(compile(self.patch_file_contents, self.patch_file, 'exec'))
|
||||
|
||||
log.info('DLDT patches applied')
|
||||
|
||||
|
||||
def build(self):
|
||||
self.cmake_path = 'cmake'
|
||||
build_config = 'Release' if not self.config.build_debug else 'Debug'
|
||||
|
||||
cmd = [self.cmake_path, '-G', 'Visual Studio 16 2019', '-A', 'x64']
|
||||
|
||||
cmake_vars = dict(
|
||||
CMAKE_BUILD_TYPE=build_config,
|
||||
ENABLE_SAMPLES='OFF',
|
||||
ENABLE_TESTS='OFF',
|
||||
BUILD_TESTS='OFF',
|
||||
ENABLE_OPENCV='OFF',
|
||||
ENABLE_GNA='OFF',
|
||||
NGRAPH_UNIT_TEST_ENABLE='OFF',
|
||||
CMAKE_INSTALL_PREFIX=str(self.build_dir / 'install'),
|
||||
)
|
||||
|
||||
cmd += [ '-D%s=%s' % (k, v) for (k, v) in cmake_vars.items() if v is not None]
|
||||
if self.config.cmake_option_dldt:
|
||||
cmd += self.config.cmake_option_dldt
|
||||
|
||||
cmd.append(str(self.srcdir))
|
||||
execute(cmd, cwd=self.build_dir)
|
||||
|
||||
# build
|
||||
cmd = [self.cmake_path, '--build', '.', '--config', build_config, # '--target', 'install',
|
||||
'--', '/v:n', '/m:2', '/consoleloggerparameters:NoSummary'
|
||||
]
|
||||
execute(cmd, cwd=self.build_dir)
|
||||
|
||||
# install ngraph only
|
||||
cmd = [self.cmake_path, '-DBUILD_TYPE=' + build_config, '-P', 'cmake_install.cmake']
|
||||
execute(cmd, cwd=self.build_dir / 'ngraph')
|
||||
|
||||
log.info('DLDT build completed')
|
||||
|
||||
|
||||
def make_sysroot(self):
|
||||
cfg_file = str(self.cpath / 'sysroot.config.py') # Python 3.5 may not handle Path
|
||||
with open(cfg_file, 'r') as f:
|
||||
cfg = f.read()
|
||||
exec(compile(cfg, cfg_file, 'exec'))
|
||||
|
||||
log.info('DLDT sysroot preparation completed')
|
||||
|
||||
|
||||
#===================================================================================================
|
||||
|
||||
class Builder:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
build_dir_name = 'opencv_build' if not self.config.build_debug else 'opencv_build_debug'
|
||||
self.build_dir = prepare_dir(Path(self.config.output_dir) / build_dir_name, clean=self.config.clean_opencv)
|
||||
self.package_dir = prepare_dir(Path(self.config.output_dir) / 'package/opencv', clean=True)
|
||||
self.install_dir = prepare_dir(self.package_dir / 'build')
|
||||
self.src_dir = check_dir(self.config.opencv_dir)
|
||||
|
||||
|
||||
def build(self, builderDLDT):
|
||||
self.cmake_path = 'cmake'
|
||||
build_config = 'Release' if not self.config.build_debug else 'Debug'
|
||||
|
||||
cmd = [self.cmake_path, '-G', 'Visual Studio 16 2019', '-A', 'x64']
|
||||
|
||||
cmake_vars = dict(
|
||||
CMAKE_BUILD_TYPE=build_config,
|
||||
INSTALL_CREATE_DISTRIB='ON',
|
||||
BUILD_opencv_world='OFF',
|
||||
BUILD_TESTS='OFF',
|
||||
BUILD_PERF_TESTS='OFF',
|
||||
ENABLE_CXX11='ON',
|
||||
WITH_INF_ENGINE='ON',
|
||||
INF_ENGINE_RELEASE=str(self.config.dldt_release),
|
||||
WITH_TBB='ON',
|
||||
CPU_BASELINE='AVX2',
|
||||
CMAKE_INSTALL_PREFIX=str(self.install_dir),
|
||||
INSTALL_PDB='ON',
|
||||
INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL='OFF',
|
||||
|
||||
OPENCV_SKIP_CMAKE_ROOT_CONFIG='ON',
|
||||
OPENCV_BIN_INSTALL_PATH='bin',
|
||||
OPENCV_INCLUDE_INSTALL_PATH='include',
|
||||
OPENCV_LIB_INSTALL_PATH='lib',
|
||||
OPENCV_CONFIG_INSTALL_PATH='cmake',
|
||||
OPENCV_3P_LIB_INSTALL_PATH='3rdparty',
|
||||
OPENCV_SAMPLES_SRC_INSTALL_PATH='samples',
|
||||
OPENCV_DOC_INSTALL_PATH='doc',
|
||||
OPENCV_OTHER_INSTALL_PATH='etc',
|
||||
OPENCV_LICENSES_INSTALL_PATH='etc/licenses',
|
||||
|
||||
OPENCV_INSTALL_DATA_DIR_RELATIVE='../../src/opencv',
|
||||
|
||||
BUILD_opencv_python2='OFF',
|
||||
BUILD_opencv_python3='ON',
|
||||
PYTHON3_LIMITED_API='ON',
|
||||
OPENCV_PYTHON_INSTALL_PATH='python',
|
||||
)
|
||||
|
||||
cmake_vars['INF_ENGINE_LIB_DIRS:PATH'] = str(builderDLDT.sysrootdir / 'deployment_tools/inference_engine/lib/intel64')
|
||||
cmake_vars['INF_ENGINE_INCLUDE_DIRS:PATH'] = str(builderDLDT.sysrootdir / 'deployment_tools/inference_engine/include')
|
||||
cmake_vars['ngraph_DIR:PATH'] = str(builderDLDT.sysrootdir / 'ngraph/cmake')
|
||||
cmake_vars['TBB_DIR:PATH'] = str(builderDLDT.sysrootdir / 'tbb/cmake')
|
||||
|
||||
if self.config.build_debug:
|
||||
cmake_vars['CMAKE_BUILD_TYPE'] = 'Debug'
|
||||
cmake_vars['BUILD_opencv_python3'] ='OFF' # python3x_d.lib is missing
|
||||
cmake_vars['OPENCV_INSTALL_APPS_LIST'] = 'all'
|
||||
|
||||
if self.config.build_tests:
|
||||
cmake_vars['BUILD_TESTS'] = 'ON'
|
||||
cmake_vars['BUILD_PERF_TESTS'] = 'ON'
|
||||
cmake_vars['BUILD_opencv_ts'] = 'ON'
|
||||
cmake_vars['INSTALL_TESTS']='ON'
|
||||
|
||||
if self.config.build_tests_dnn:
|
||||
cmake_vars['BUILD_TESTS'] = 'ON'
|
||||
cmake_vars['BUILD_PERF_TESTS'] = 'ON'
|
||||
cmake_vars['BUILD_opencv_ts'] = 'ON'
|
||||
cmake_vars['OPENCV_BUILD_TEST_MODULES_LIST'] = 'dnn'
|
||||
cmake_vars['OPENCV_BUILD_PERF_TEST_MODULES_LIST'] = 'dnn'
|
||||
cmake_vars['INSTALL_TESTS']='ON'
|
||||
|
||||
cmd += [ "-D%s=%s" % (k, v) for (k, v) in cmake_vars.items() if v is not None]
|
||||
if self.config.cmake_option:
|
||||
cmd += self.config.cmake_option
|
||||
|
||||
cmd.append(str(self.src_dir))
|
||||
|
||||
log.info('Configuring OpenCV...')
|
||||
|
||||
execute(cmd, cwd=self.build_dir)
|
||||
|
||||
log.info('Building OpenCV...')
|
||||
|
||||
# build
|
||||
cmd = [self.cmake_path, '--build', '.', '--config', build_config, '--target', 'install',
|
||||
'--', '/v:n', '/m:2', '/consoleloggerparameters:NoSummary'
|
||||
]
|
||||
execute(cmd, cwd=self.build_dir)
|
||||
|
||||
log.info('OpenCV build/install completed')
|
||||
|
||||
|
||||
def copy_sysroot(self, builderDLDT):
|
||||
log.info('Copy sysroot files')
|
||||
|
||||
copytree(builderDLDT.sysrootdir / 'bin', self.install_dir / 'bin')
|
||||
copytree(builderDLDT.sysrootdir / 'etc', self.install_dir / 'etc')
|
||||
|
||||
log.info('Copy sysroot files - DONE')
|
||||
|
||||
|
||||
def package_sources(self):
|
||||
package_opencv = prepare_dir(self.package_dir / 'src/opencv', clean=True)
|
||||
package_opencv = str(package_opencv) # Python 3.5 may not handle Path
|
||||
execute(cmd=['git', 'clone', '-s', str(self.src_dir), '.'], cwd=str(package_opencv))
|
||||
for item in os.listdir(package_opencv):
|
||||
if str(item).startswith('.git'):
|
||||
rm_one(os.path.join(package_opencv, item))
|
||||
|
||||
with open(str(self.package_dir / 'README.md'), 'w') as f:
|
||||
f.write('See licensing/copying statements in "build/etc/licenses"\n')
|
||||
f.write('Wiki page: https://github.com/opencv/opencv/wiki/Intel%27s-Deep-Learning-Inference-Engine-backend\n')
|
||||
|
||||
log.info('Package OpenCV sources - DONE')
|
||||
|
||||
|
||||
#===================================================================================================
|
||||
|
||||
def main():
|
||||
|
||||
dldt_src_url = 'https://github.com/opencv/dldt.git'
|
||||
dldt_src_commit = '2020.1'
|
||||
dldt_release = '2020010000'
|
||||
|
||||
build_cache_dir_default = os.environ.get('BUILD_CACHE_DIR', '.build_cache')
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Build OpenCV Windows package with Inference Engine (DLDT)',
|
||||
)
|
||||
parser.add_argument('output_dir', nargs='?', default='.', help='Output directory')
|
||||
parser.add_argument('opencv_dir', nargs='?', default=os.path.join(SCRIPT_DIR, '../..'), help='Path to OpenCV source dir')
|
||||
parser.add_argument('--build_cache_dir', default=build_cache_dir_default, help='Build cache directory (sources and binaries cache of build dependencies, default = "%s")' % build_cache_dir_default)
|
||||
|
||||
parser.add_argument('--cmake_option', action='append', help='Append OpenCV CMake option')
|
||||
parser.add_argument('--cmake_option_dldt', action='append', help='Append CMake option for DLDT project')
|
||||
|
||||
parser.add_argument('--clean_dldt', action='store_true', help='Clear DLDT build and sysroot directories')
|
||||
parser.add_argument('--clean_opencv', action='store_true', help='Clear OpenCV build directory')
|
||||
|
||||
parser.add_argument('--build_debug', action='store_true', help='Build debug binaries')
|
||||
parser.add_argument('--build_tests', action='store_true', help='Build OpenCV tests')
|
||||
parser.add_argument('--build_tests_dnn', action='store_true', help='Build OpenCV DNN accuracy and performance tests only')
|
||||
|
||||
parser.add_argument('--dldt_src_url', default=dldt_src_url, help='DLDT source URL (tag / commit, default: %s)' % dldt_src_url)
|
||||
parser.add_argument('--dldt_src_branch', help='DLDT checkout branch')
|
||||
parser.add_argument('--dldt_src_commit', default=dldt_src_commit, help='DLDT source commit / tag (default: %s)' % dldt_src_commit)
|
||||
parser.add_argument('--dldt_src_git_clone_extra', action='append', help='DLDT git clone extra args')
|
||||
parser.add_argument('--dldt_release', default=dldt_release, help='DLDT release code for INF_ENGINE_RELEASE (default: %s)' % dldt_release)
|
||||
|
||||
parser.add_argument('--dldt_reference_dir', help='DLDT reference git repository (optional)')
|
||||
parser.add_argument('--dldt_src_dir', help='DLDT custom source repository (skip git checkout and patching, use for TESTING only)')
|
||||
|
||||
parser.add_argument('--dldt_config', help='Specify DLDT build configuration (defaults to DLDT commit)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
log.basicConfig(
|
||||
format='%(asctime)s %(levelname)-8s %(message)s',
|
||||
level=os.environ.get('LOGLEVEL', 'INFO'),
|
||||
datefmt='%Y-%m-%d %H:%M:%S'
|
||||
)
|
||||
log.debug('Args: %s', args)
|
||||
|
||||
if not check_executable(['git', '--version']):
|
||||
sys.exit("FATAL: 'git' is not available")
|
||||
if not check_executable(['cmake', '--version']):
|
||||
sys.exit("FATAL: 'cmake' is not available")
|
||||
|
||||
if os.path.realpath(args.output_dir) == os.path.realpath(SCRIPT_DIR):
|
||||
raise Fail("Specify output_dir (building from script directory is not supported)")
|
||||
if os.path.realpath(args.output_dir) == os.path.realpath(args.opencv_dir):
|
||||
raise Fail("Specify output_dir (building from OpenCV source directory is not supported)")
|
||||
|
||||
# Relative paths become invalid in sub-directories
|
||||
if args.opencv_dir is not None and not os.path.isabs(args.opencv_dir):
|
||||
args.opencv_dir = os.path.abspath(args.opencv_dir)
|
||||
|
||||
if not args.dldt_config:
|
||||
args.dldt_config = args.dldt_src_commit
|
||||
|
||||
_opencv_dir = check_dir(args.opencv_dir)
|
||||
_outdir = prepare_dir(args.output_dir)
|
||||
_cachedir = prepare_dir(args.build_cache_dir)
|
||||
|
||||
ocv_hooks_dir = os.environ.get('OPENCV_CMAKE_HOOKS_DIR', None)
|
||||
hooks_dir = os.path.join(SCRIPT_DIR, 'cmake-opencv-checks')
|
||||
os.environ['OPENCV_CMAKE_HOOKS_DIR'] = hooks_dir if ocv_hooks_dir is None else (hooks_dir + ';' + ocv_hooks_dir)
|
||||
|
||||
builder_dldt = BuilderDLDT(args)
|
||||
|
||||
builder_dldt.prepare_sources()
|
||||
builder_dldt.build()
|
||||
builder_dldt.make_sysroot()
|
||||
|
||||
builder_opencv = Builder(args)
|
||||
builder_opencv.build(builder_dldt)
|
||||
builder_opencv.copy_sysroot(builder_dldt)
|
||||
builder_opencv.package_sources()
|
||||
|
||||
log.info("=====")
|
||||
log.info("===== Build finished")
|
||||
log.info("=====")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
log.info('FATAL: Error occured. To investigate problem try to change logging level using LOGLEVEL=DEBUG environment variable.')
|
||||
raise
|
||||
@@ -0,0 +1,17 @@
|
||||
message(STATUS "Winpack-DLDT: Validating OpenCV build configuration...")
|
||||
|
||||
if(NOT INF_ENGINE_TARGET)
|
||||
message(SEND_ERROR "Inference engine must be detected")
|
||||
set(HAS_ERROR 1)
|
||||
endif()
|
||||
if(NOT HAVE_NGRAPH)
|
||||
message(SEND_ERROR "Inference engine nGraph must be detected")
|
||||
set(HAS_ERROR 1)
|
||||
endif()
|
||||
|
||||
if(HAS_ERROR)
|
||||
ocv_cmake_dump_vars("^IE_|INF_|INFERENCE|ngraph")
|
||||
message(FATAL_ERROR "Winpack-DLDT: Validating OpenCV build configuration... FAILED")
|
||||
endif()
|
||||
|
||||
message(STATUS "Winpack-DLDT: Validating OpenCV build configuration... DONE")
|
||||
@@ -0,0 +1,13 @@
|
||||
import sys
|
||||
print(sys.version_info)
|
||||
try:
|
||||
import cv2 as cv
|
||||
print(cv.__version__)
|
||||
print(cv.dnn.getAvailableTargets(cv.dnn.DNN_BACKEND_INFERENCE_ENGINE))
|
||||
except:
|
||||
print(sys.path)
|
||||
import os
|
||||
print(os.environ.get('PATH', ''))
|
||||
raise
|
||||
|
||||
print('OK')
|
||||
@@ -4,16 +4,24 @@
|
||||
:: - > _winpack_build_sample.cmd cpp\opencv_version.cpp
|
||||
:: Requires:
|
||||
:: - CMake
|
||||
:: - MSVS 2015/2017
|
||||
:: - MSVS 2015/2017/2019
|
||||
:: (tools are searched on default paths or environment should be pre-configured)
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set SCRIPTDIR=%~dp0
|
||||
if NOT exist "%SCRIPTDIR%\..\..\build" (
|
||||
SET SCRIPT_DIR=%~dp0
|
||||
SET "OPENCV_SETUPVARS_SCRIPT=setup_vars_opencv3.cmd"
|
||||
SET "PACKAGE_BUILD_DIR=%SCRIPT_DIR%\..\..\build"
|
||||
IF NOT EXIST "%PACKAGE_BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
|
||||
:: Winpack DLDT
|
||||
SET "PACKAGE_BUILD_DIR=%SCRIPT_DIR%\..\..\..\build"
|
||||
)
|
||||
IF NOT EXIST "%PACKAGE_BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
|
||||
set "MSG=OpenCV Winpack installation is required"
|
||||
goto die
|
||||
)
|
||||
:: normalize path
|
||||
for %%i in ("%PACKAGE_BUILD_DIR%") do SET "PACKAGE_BUILD_DIR=%%~fi"
|
||||
|
||||
if [%1]==[] (
|
||||
set "MSG=Sample path is required"
|
||||
@@ -35,8 +43,8 @@ set "SRC_NAME=%~n1"
|
||||
echo SRC_NAME=%SRC_NAME%
|
||||
echo ================================================================================
|
||||
|
||||
:: Path to FFMPEG binary files
|
||||
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\bin\"
|
||||
:: Path to root 'bin' dir
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\bin;%PATH%"
|
||||
|
||||
:: Detect compiler
|
||||
cl /? >NUL 2>NUL <NUL
|
||||
@@ -102,12 +110,21 @@ if NOT DEFINED VisualStudioVersion (
|
||||
if "%VisualStudioVersion%" == "14.0" (
|
||||
set "CMAKE_GENERATOR=-G^"Visual Studio 14 Win64^""
|
||||
set "BUILD_DIR_SUFFIX=.vc14"
|
||||
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc14\bin\"
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
|
||||
)
|
||||
) else (
|
||||
if "%VisualStudioVersion%" == "15.0" (
|
||||
set "CMAKE_GENERATOR=-G^"Visual Studio 15 Win64^""
|
||||
set "BUILD_DIR_SUFFIX=.vc15"
|
||||
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc15\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc15\bin;%PATH%"
|
||||
) else (
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if "%VisualStudioVersion%" == "16.0" (
|
||||
echo.==========================================
|
||||
@@ -115,7 +132,17 @@ if "%VisualStudioVersion%" == "14.0" (
|
||||
echo.==========================================
|
||||
set "CMAKE_GENERATOR=-G^"Visual Studio 16 2019^" -A x64"
|
||||
set "BUILD_DIR_SUFFIX=.vc16"
|
||||
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc16\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc16\bin;%PATH%"
|
||||
) else (
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc15\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc15\bin;%PATH%"
|
||||
) else (
|
||||
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
|
||||
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
|
||||
)
|
||||
)
|
||||
)
|
||||
) else (
|
||||
set "MSG=Unsupported MSVS version. VisualStudioVersion=%VisualStudioVersion%"
|
||||
goto die
|
||||
@@ -128,10 +155,10 @@ call :set_title Create build directory
|
||||
if NOT exist "%BUILD_DIR%" ( call :execute md "%BUILD_DIR%" )
|
||||
PUSHD "%BUILD_DIR%"
|
||||
if NOT exist "%BUILD_DIR%/sample" ( call :execute md "%BUILD_DIR%/sample" )
|
||||
call :execute copy /Y "%SCRIPTDIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt"
|
||||
call :execute copy /Y "%SCRIPT_DIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt"
|
||||
|
||||
call :set_title Configuring via CMake
|
||||
call :execute cmake %CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%" "-DOpenCV_DIR=%SCRIPTDIR%\..\..\build"
|
||||
call :execute cmake %CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%"
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
set "MSG=CMake configuration step failed: %BUILD_DIR%"
|
||||
goto die
|
||||
|
||||
@@ -2,11 +2,19 @@
|
||||
SETLOCAL
|
||||
|
||||
SET SCRIPT_DIR=%~dp0
|
||||
IF NOT EXIST "%SCRIPT_DIR%\..\..\build\setup_vars_opencv3.cmd" (
|
||||
SET "OPENCV_SETUPVARS_SCRIPT=setup_vars_opencv3.cmd"
|
||||
SET "BUILD_DIR=%SCRIPT_DIR%\..\..\build"
|
||||
IF NOT EXIST "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
|
||||
:: Winpack DLDT
|
||||
SET "BUILD_DIR=%SCRIPT_DIR%\..\..\..\build"
|
||||
)
|
||||
IF NOT EXIST "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
|
||||
ECHO ERROR: OpenCV Winpack installation is required
|
||||
pause
|
||||
exit
|
||||
)
|
||||
:: normalize path
|
||||
for %%i in ("%PACKAGE_BUILD_DIR%") do SET "PACKAGE_BUILD_DIR=%%~fi"
|
||||
|
||||
:: Detect Python binary
|
||||
python -V 2>nul
|
||||
@@ -80,7 +88,11 @@ echo SRC_FILENAME=%SRC_FILENAME%
|
||||
call :dirname "%SRC_FILENAME%" SRC_DIR
|
||||
call :dirname "%PYTHON%" PYTHON_DIR
|
||||
PUSHD %SRC_DIR%
|
||||
CALL "%SCRIPT_DIR%\..\..\build\setup_vars_opencv3.cmd"
|
||||
|
||||
CALL "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%"
|
||||
:: repair SCRIPT_DIR
|
||||
SET "SCRIPT_DIR=%~dp0"
|
||||
|
||||
ECHO Run: %*
|
||||
%PYTHON% %*
|
||||
SET result=%errorlevel%
|
||||
@@ -94,17 +106,23 @@ IF %result% NEQ 0 (
|
||||
cmd /k echo Current directory: %CD%
|
||||
)
|
||||
)
|
||||
|
||||
POPD
|
||||
EXIT /B %result%
|
||||
|
||||
:rundemo
|
||||
PUSHD "%SCRIPT_DIR%\python"
|
||||
CALL "%SCRIPT_DIR%\..\..\build\setup_vars_opencv3.cmd"
|
||||
|
||||
CALL "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%"
|
||||
:: repair SCRIPT_DIR
|
||||
SET "SCRIPT_DIR=%~dp0"
|
||||
|
||||
%PYTHON% demo.py
|
||||
SET result=%errorlevel%
|
||||
IF %result% NEQ 0 (
|
||||
IF NOT DEFINED OPENCV_BATCH_MODE ( pause )
|
||||
)
|
||||
|
||||
POPD
|
||||
EXIT /B %result%
|
||||
|
||||
|
||||
+17
-5
@@ -114,12 +114,24 @@ class App:
|
||||
def on_demo_select(self, evt):
|
||||
name = self.demos_lb.get( self.demos_lb.curselection()[0] )
|
||||
fn = self.samples[name]
|
||||
loc = {}
|
||||
|
||||
descr = ""
|
||||
try:
|
||||
execfile(fn, loc) # Python 2
|
||||
except NameError:
|
||||
exec(open(fn).read(), loc) # Python 3
|
||||
descr = loc.get('__doc__', 'no-description')
|
||||
if sys.version_info[0] > 2:
|
||||
# Python 3.x
|
||||
module_globals = {}
|
||||
module_locals = {}
|
||||
with open(fn, 'r') as f:
|
||||
module_code = f.read()
|
||||
exec(compile(module_code, fn, 'exec'), module_globals, module_locals)
|
||||
descr = module_locals.get('__doc__', 'no-description')
|
||||
else:
|
||||
# Python 2
|
||||
module_globals = {}
|
||||
execfile(fn, module_globals) # noqa: F821
|
||||
descr = module_globals.get('__doc__', 'no-description')
|
||||
except Exception as e:
|
||||
descr = str(e)
|
||||
|
||||
self.linker.reset()
|
||||
self.text.config(state='normal')
|
||||
|
||||
Reference in New Issue
Block a user