Commit 690fb054 authored by Alexander Alekhin's avatar Alexander Alekhin Committed by Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents ae4c72a1 ee0c9854
...@@ -146,6 +146,14 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { ...@@ -146,6 +146,14 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
return __atomic_load_n(ptr, __ATOMIC_RELAXED); return __atomic_load_n(ptr, __ATOMIC_RELAXED);
} }
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
__atomic_compare_exchange_n(ptr, &old_value, new_value, false,
__ATOMIC_RELEASE, __ATOMIC_ACQUIRE);
return old_value;
}
#endif // defined(__LP64__) #endif // defined(__LP64__)
} // namespace internal } // namespace internal
......
...@@ -14,6 +14,7 @@ if(DOXYGEN_FOUND) ...@@ -14,6 +14,7 @@ if(DOXYGEN_FOUND)
add_custom_target(doxygen) add_custom_target(doxygen)
# not documented modules list # not documented modules list
set(blacklist "${DOXYGEN_BLACKLIST}")
list(APPEND blacklist "ts" "java_bindings_generator" "java" "python_bindings_generator" "python2" "python3" "js" "world") list(APPEND blacklist "ts" "java_bindings_generator" "java" "python_bindings_generator" "python2" "python3" "js" "world")
unset(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT) unset(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
unset(CMAKE_DOXYGEN_TUTORIAL_JS_ROOT) unset(CMAKE_DOXYGEN_TUTORIAL_JS_ROOT)
......
...@@ -56,7 +56,7 @@ Theory ...@@ -56,7 +56,7 @@ Theory
entire pyramid. entire pyramid.
- The procedure above was useful to downsample an image. What if we want to make it bigger?: - The procedure above was useful to downsample an image. What if we want to make it bigger?:
columns filled with zeros (\f$0 \f$) columns filled with zeros (\f$0 \f$)
- First, upsize the image to twice the original in each dimension, wit the new even rows and - First, upsize the image to twice the original in each dimension, with the new even rows and
- Perform a convolution with the same kernel shown above (multiplied by 4) to approximate the - Perform a convolution with the same kernel shown above (multiplied by 4) to approximate the
values of the "missing pixels" values of the "missing pixels"
- These two procedures (downsampling and upsampling as explained above) are implemented by the - These two procedures (downsampling and upsampling as explained above) are implemented by the
......
...@@ -5,11 +5,17 @@ ...@@ -5,11 +5,17 @@
#ifndef OPENCV_CONFIGURATION_PRIVATE_HPP #ifndef OPENCV_CONFIGURATION_PRIVATE_HPP
#define OPENCV_CONFIGURATION_PRIVATE_HPP #define OPENCV_CONFIGURATION_PRIVATE_HPP
#include "opencv2/core/cvstd.hpp"
#include <vector>
#include <string>
namespace cv { namespace utils { namespace cv { namespace utils {
typedef std::vector<std::string> Paths;
CV_EXPORTS bool getConfigurationParameterBool(const char* name, bool defaultValue); CV_EXPORTS bool getConfigurationParameterBool(const char* name, bool defaultValue);
CV_EXPORTS size_t getConfigurationParameterSizeT(const char* name, size_t defaultValue); CV_EXPORTS size_t getConfigurationParameterSizeT(const char* name, size_t defaultValue);
CV_EXPORTS cv::String getConfigurationParameterString(const char* name, const char* defaultValue); CV_EXPORTS cv::String getConfigurationParameterString(const char* name, const char* defaultValue);
CV_EXPORTS Paths getConfigurationParameterPaths(const char* name, const Paths &defaultValue = Paths());
}} // namespace }} // namespace
......
...@@ -238,6 +238,20 @@ static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = utils::getConfigura ...@@ -238,6 +238,20 @@ static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = utils::getConfigura
#endif #endif
); );
static const String getBuildExtraOptions()
{
static String param_buildExtraOptions;
static bool initialized = false;
if (!initialized)
{
param_buildExtraOptions = utils::getConfigurationParameterString("OPENCV_OPENCL_BUILD_EXTRA_OPTIONS", "");
initialized = true;
if (!param_buildExtraOptions.empty())
CV_LOG_WARNING(NULL, "OpenCL: using extra build options: '" << param_buildExtraOptions << "'");
}
return param_buildExtraOptions;
}
#endif // HAVE_OPENCL #endif // HAVE_OPENCL
struct UMat2D struct UMat2D
...@@ -3517,6 +3531,9 @@ struct Program::Impl ...@@ -3517,6 +3531,9 @@ struct Program::Impl
buildflags = joinBuildOptions(buildflags, " -D AMD_DEVICE"); buildflags = joinBuildOptions(buildflags, " -D AMD_DEVICE");
else if (device.isIntel()) else if (device.isIntel())
buildflags = joinBuildOptions(buildflags, " -D INTEL_DEVICE"); buildflags = joinBuildOptions(buildflags, " -D INTEL_DEVICE");
const String param_buildExtraOptions = getBuildExtraOptions();
if (!param_buildExtraOptions.empty())
buildflags = joinBuildOptions(buildflags, param_buildExtraOptions);
} }
compile(ctx, src_, errmsg); compile(ctx, src_, errmsg);
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include <iostream> #include <iostream>
#include <ostream>
#include <opencv2/core/utils/configuration.private.hpp> #include <opencv2/core/utils/configuration.private.hpp>
#include <opencv2/core/utils/trace.private.hpp> #include <opencv2/core/utils/trace.private.hpp>
...@@ -1594,18 +1595,26 @@ static TLSData<ThreadID>& getThreadIDTLS() ...@@ -1594,18 +1595,26 @@ static TLSData<ThreadID>& getThreadIDTLS()
} // namespace } // namespace
int utils::getThreadID() { return getThreadIDTLS().get()->id; } int utils::getThreadID() { return getThreadIDTLS().get()->id; }
bool utils::getConfigurationParameterBool(const char* name, bool defaultValue)
class ParseError
{ {
#ifdef NO_GETENV std::string bad_value;
const char* envValue = NULL; public:
#else ParseError(const std::string bad_value_) :bad_value(bad_value_) {}
const char* envValue = getenv(name); std::string toString(const std::string &param) const
#endif
if (envValue == NULL)
{ {
return defaultValue; std::ostringstream out;
out << "Invalid value for parameter " << param << ": " << bad_value;
return out.str();
} }
cv::String value = envValue; };
template <typename T>
T parseOption(const std::string &);
template<>
inline bool parseOption(const std::string & value)
{
if (value == "1" || value == "True" || value == "true" || value == "TRUE") if (value == "1" || value == "True" || value == "true" || value == "TRUE")
{ {
return true; return true;
...@@ -1614,22 +1623,12 @@ bool utils::getConfigurationParameterBool(const char* name, bool defaultValue) ...@@ -1614,22 +1623,12 @@ bool utils::getConfigurationParameterBool(const char* name, bool defaultValue)
{ {
return false; return false;
} }
CV_Error(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str())); throw ParseError(value);
} }
template<>
size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultValue) inline size_t parseOption(const std::string &value)
{ {
#ifdef NO_GETENV
const char* envValue = NULL;
#else
const char* envValue = getenv(name);
#endif
if (envValue == NULL)
{
return defaultValue;
}
cv::String value = envValue;
size_t pos = 0; size_t pos = 0;
for (; pos < value.size(); pos++) for (; pos < value.size(); pos++)
{ {
...@@ -1645,17 +1644,80 @@ size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultVal ...@@ -1645,17 +1644,80 @@ size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultVal
return v * 1024 * 1024; return v * 1024 * 1024;
else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb") else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
return v * 1024; return v * 1024;
CV_Error(cv::Error::StsBadArg, cv::format("Invalid value for %s parameter: %s", name, value.c_str())); throw ParseError(value);
} }
cv::String utils::getConfigurationParameterString(const char* name, const char* defaultValue) template<>
inline cv::String parseOption(const std::string &value)
{
return value;
}
template<>
inline utils::Paths parseOption(const std::string &value)
{
utils::Paths result;
#ifdef _WIN32
const char sep = ';';
#else
const char sep = ':';
#endif
size_t start_pos = 0;
while (start_pos != std::string::npos)
{
const size_t pos = value.find(sep, start_pos);
const std::string one_piece(value, start_pos, pos == std::string::npos ? pos : pos - start_pos);
if (!one_piece.empty())
result.push_back(one_piece);
start_pos = pos == std::string::npos ? pos : pos + 1;
}
return result;
}
static inline const char * envRead(const char * name)
{ {
#ifdef NO_GETENV #ifdef NO_GETENV
const char* envValue = NULL; CV_UNUSED(name);
return NULL;
#else #else
const char* envValue = getenv(name); return getenv(name);
#endif #endif
return envValue ? cv::String(envValue) : (defaultValue ? cv::String(defaultValue) : cv::String()); }
template<typename T>
inline T read(const std::string & k, const T & defaultValue)
{
try
{
const char * res = envRead(k.c_str());
if (res)
return parseOption<T>(std::string(res));
}
catch (const ParseError &err)
{
CV_Error(cv::Error::StsBadArg, err.toString(k));
}
return defaultValue;
}
bool utils::getConfigurationParameterBool(const char* name, bool defaultValue)
{
return read<bool>(name, defaultValue);
}
size_t utils::getConfigurationParameterSizeT(const char* name, size_t defaultValue)
{
return read<size_t>(name, defaultValue);
}
cv::String utils::getConfigurationParameterString(const char* name, const char* defaultValue)
{
return read<cv::String>(name, defaultValue ? cv::String(defaultValue) : cv::String());
}
utils::Paths utils::getConfigurationParameterPaths(const char* name, const utils::Paths &defaultValue)
{
return read<utils::Paths>(name, defaultValue);
} }
......
...@@ -280,15 +280,6 @@ convolve_simd( ...@@ -280,15 +280,6 @@ convolve_simd(
in_addr += INPUT_PITCH; in_addr += INPUT_PITCH;
Dtype weight_buf[WEIGHT_PREF];
int w_idx=0;
for (int i = 0; i < WEIGHT_PREF; i++)
{
weight_buf[i] = weights[weight_addr];
weight_addr += SIMD_SIZE;
}
#define BLOCK_IN(n, c) intel_sub_group_shuffle(in_buf[n], (c)) #define BLOCK_IN(n, c) intel_sub_group_shuffle(in_buf[n], (c))
int kr = 0; // kr = Kernel Row int kr = 0; // kr = Kernel Row
...@@ -297,20 +288,18 @@ convolve_simd( ...@@ -297,20 +288,18 @@ convolve_simd(
int kc = 0; // kc = Kernel Column int kc = 0; // kc = Kernel Column
LOOP(KERNEL_WIDTH, kc, LOOP(KERNEL_WIDTH, kc,
{ {
Dtype weight_value = weights[weight_addr];
weight_addr += SIMD_SIZE;
for (int br=0; br < OUT_BLOCK_HEIGHT; br++) for (int br=0; br < OUT_BLOCK_HEIGHT; br++)
{ {
for(int bc=0; bc < OUT_BLOCK_WIDTH; bc++) for(int bc=0; bc < OUT_BLOCK_WIDTH; bc++)
{ {
Dtype input = BLOCK_IN((br * STRIDE_Y + kr * DILATION_Y), bc * STRIDE_X + kc * DILATION_X); Dtype input = BLOCK_IN((br * STRIDE_Y + kr * DILATION_Y), bc * STRIDE_X + kc * DILATION_X);
out[br * OUT_BLOCK_WIDTH + bc] = mad(weight_buf[w_idx % WEIGHT_PREF], input, out[br * OUT_BLOCK_WIDTH + bc]); out[br * OUT_BLOCK_WIDTH + bc] = mad(weight_value, input, out[br * OUT_BLOCK_WIDTH + bc]);
} }
} }
weight_buf[w_idx % WEIGHT_PREF] = weights[weight_addr];
weight_addr += SIMD_SIZE;
++w_idx;
}); });
}); });
weight_addr -= WEIGHT_PREF * SIMD_SIZE;
} }
fm = fm % ALIGNED_NUM_FILTERS; fm = fm % ALIGNED_NUM_FILTERS;
......
set(the_description "2D Features Framework") set(the_description "2D Features Framework")
ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python) ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python js)
...@@ -137,7 +137,11 @@ public: ...@@ -137,7 +137,11 @@ public:
/** @brief Abstract base class for 2D image feature detectors and descriptor extractors /** @brief Abstract base class for 2D image feature detectors and descriptor extractors
*/ */
#ifdef __EMSCRIPTEN__
class CV_EXPORTS_W Feature2D : public Algorithm
#else
class CV_EXPORTS_W Feature2D : public virtual Algorithm class CV_EXPORTS_W Feature2D : public virtual Algorithm
#endif
{ {
public: public:
virtual ~Feature2D(); virtual ~Feature2D();
......
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
#ifdef HAVE_OPENCV_FLANN
#include "opencv2/flann/miniflann.hpp" #include "opencv2/flann/miniflann.hpp"
#endif
#include <limits> #include <limits>
#include "opencl_kernels_features2d.hpp" #include "opencl_kernels_features2d.hpp"
......
...@@ -63,7 +63,7 @@ namespace cv ...@@ -63,7 +63,7 @@ namespace cv
//! Imread flags //! Imread flags
enum ImreadModes { enum ImreadModes {
IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped). IMREAD_UNCHANGED = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image. IMREAD_GRAYSCALE = 0, //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image. IMREAD_COLOR = 1, //!< If set, always convert image to the 3 channel BGR color image.
IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit. IMREAD_ANYDEPTH = 2, //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format. IMREAD_ANYCOLOR = 4, //!< If set, the image is read in any possible color format.
...@@ -155,6 +155,8 @@ Currently, the following file formats are supported: ...@@ -155,6 +155,8 @@ Currently, the following file formats are supported:
- The function determines the type of an image by the content, not by the file extension. - The function determines the type of an image by the content, not by the file extension.
- In the case of color images, the decoded images will have the channels stored in **B G R** order. - In the case of color images, the decoded images will have the channels stored in **B G R** order.
- When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
Results may differ to the output of cvtColor()
- On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg, - On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs, libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
......
...@@ -14,7 +14,7 @@ public class FpsMeter { ...@@ -14,7 +14,7 @@ public class FpsMeter {
private static final int STEP = 20; private static final int STEP = 20;
private static final DecimalFormat FPS_FORMAT = new DecimalFormat("0.00"); private static final DecimalFormat FPS_FORMAT = new DecimalFormat("0.00");
private int mFramesCouner; private int mFramesCounter;
private double mFrequency; private double mFrequency;
private long mprevFrameTime; private long mprevFrameTime;
private String mStrfps; private String mStrfps;
...@@ -24,7 +24,7 @@ public class FpsMeter { ...@@ -24,7 +24,7 @@ public class FpsMeter {
int mHeight = 0; int mHeight = 0;
public void init() { public void init() {
mFramesCouner = 0; mFramesCounter = 0;
mFrequency = Core.getTickFrequency(); mFrequency = Core.getTickFrequency();
mprevFrameTime = Core.getTickCount(); mprevFrameTime = Core.getTickCount();
mStrfps = ""; mStrfps = "";
...@@ -39,8 +39,8 @@ public class FpsMeter { ...@@ -39,8 +39,8 @@ public class FpsMeter {
init(); init();
mIsInitialized = true; mIsInitialized = true;
} else { } else {
mFramesCouner++; mFramesCounter++;
if (mFramesCouner % STEP == 0) { if (mFramesCounter % STEP == 0) {
long time = Core.getTickCount(); long time = Core.getTickCount();
double fps = STEP * mFrequency / (time - mprevFrameTime); double fps = STEP * mFrequency / (time - mprevFrameTime);
mprevFrameTime = time; mprevFrameTime = time;
......
...@@ -125,7 +125,22 @@ video = {'': ['CamShift', 'calcOpticalFlowFarneback', 'calcOpticalFlowPyrLK', 'c ...@@ -125,7 +125,22 @@ video = {'': ['CamShift', 'calcOpticalFlowFarneback', 'calcOpticalFlowPyrLK', 'c
'BackgroundSubtractor': ['apply', 'getBackgroundImage']} 'BackgroundSubtractor': ['apply', 'getBackgroundImage']}
dnn = {'dnn_Net': ['setInput', 'forward'], dnn = {'dnn_Net': ['setInput', 'forward'],
'': ['readNetFromCaffe', 'readNetFromTensorflow', 'readNetFromTorch', 'readNetFromDarknet', 'blobFromImage']} '': ['readNetFromCaffe', 'readNetFromTensorflow', 'readNetFromTorch', 'readNetFromDarknet',
'readNetFromONNX', 'readNet', 'blobFromImage']}
features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptorSize', 'descriptorType', 'defaultNorm', 'empty', 'getDefaultName'],
'BRISK': ['create', 'getDefaultName'],
'ORB': ['create', 'setMaxFeatures', 'setScaleFactor', 'setNLevels', 'setEdgeThreshold', 'setFirstLevel', 'setWTA_K', 'setScoreType', 'setPatchSize', 'getFastThreshold', 'getDefaultName'],
'MSER': ['create', 'detectRegions', 'setDelta', 'getDelta', 'setMinArea', 'getMinArea', 'setMaxArea', 'getMaxArea', 'setPass2Only', 'getPass2Only', 'getDefaultName'],
'FastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
'AgastFeatureDetector': ['create', 'setThreshold', 'getThreshold', 'setNonmaxSuppression', 'getNonmaxSuppression', 'setType', 'getType', 'getDefaultName'],
'GFTTDetector': ['create', 'setMaxFeatures', 'getMaxFeatures', 'setQualityLevel', 'getQualityLevel', 'setMinDistance', 'getMinDistance', 'setBlockSize', 'getBlockSize', 'setHarrisDetector', 'getHarrisDetector', 'setK', 'getK', 'getDefaultName'],
# 'SimpleBlobDetector': ['create'],
'KAZE': ['create', 'setExtended', 'getExtended', 'setUpright', 'getUpright', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'],
'BFMatcher': ['isMaskSupported', 'create'],
'': ['FAST', 'AGAST', 'drawKeypoints', 'drawMatches']}
def makeWhiteList(module_list): def makeWhiteList(module_list):
wl = {} wl = {}
...@@ -137,7 +152,7 @@ def makeWhiteList(module_list): ...@@ -137,7 +152,7 @@ def makeWhiteList(module_list):
wl[k] = m[k] wl[k] = m[k]
return wl return wl
white_list = makeWhiteList([core, imgproc, objdetect, video, dnn]) white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d])
# Features to be exported # Features to be exported
export_enums = False export_enums = False
...@@ -218,7 +233,8 @@ def handle_ptr(tp): ...@@ -218,7 +233,8 @@ def handle_ptr(tp):
def handle_vector(tp): def handle_vector(tp):
if tp.startswith('vector_'): if tp.startswith('vector_'):
tp = 'std::vector<' + "::".join(tp.split('_')[1:]) + '>' tp = handle_vector(tp[tp.find('_') + 1:])
tp = 'std::vector<' + "::".join(tp.split('_')) + '>'
return tp return tp
...@@ -861,13 +877,12 @@ class JSWrapperGenerator(object): ...@@ -861,13 +877,12 @@ class JSWrapperGenerator(object):
[class_info.cname, property.name]))) [class_info.cname, property.name])))
dv = '' dv = ''
base = Template("""base<$base$isPoly>""") base = Template("""base<$base>""")
assert len(class_info.bases) <= 1 , "multiple inheritance not supported" assert len(class_info.bases) <= 1 , "multiple inheritance not supported"
if len(class_info.bases) == 1: if len(class_info.bases) == 1:
dv = "," + base.substitute(base=', '.join(class_info.bases), dv = "," + base.substitute(base=', '.join(class_info.bases))
isPoly = " ,true" if class_info.name=="Feature2D" else "")
self.bindings.append(class_template.substitute(cpp_name=class_info.cname, self.bindings.append(class_template.substitute(cpp_name=class_info.cname,
js_name=name, js_name=name,
......
...@@ -136,6 +136,8 @@ void HOGDescriptor::setSVMDetector(InputArray _svmDetector) ...@@ -136,6 +136,8 @@ void HOGDescriptor::setSVMDetector(InputArray _svmDetector)
bool HOGDescriptor::read(FileNode& obj) bool HOGDescriptor::read(FileNode& obj)
{ {
CV_Assert(!obj["winSize"].empty());
if( !obj.isMap() ) if( !obj.isMap() )
return false; return false;
FileNodeIterator it = obj["winSize"].begin(); FileNodeIterator it = obj["winSize"].begin();
......
...@@ -66,7 +66,7 @@ if __name__ == "__main__": ...@@ -66,7 +66,7 @@ if __name__ == "__main__":
tbl.newColumn(m, metrix_table[m][0], align = "center") tbl.newColumn(m, metrix_table[m][0], align = "center")
needNewRow = True needNewRow = True
for case in sorted(tests): for case in sorted(tests, key=lambda x: str(x)):
if needNewRow: if needNewRow:
tbl.newRow() tbl.newRow()
if not options.showall: if not options.showall:
......
#!/usr/bin/env python #!/usr/bin/env python
import os import os
import re import re
import sys
from run_utils import Err, log, execute, getPlatformVersion, isColorEnabled, TempEnvDir from run_utils import Err, log, execute, getPlatformVersion, isColorEnabled, TempEnvDir
from run_long import LONG_TESTS_DEBUG_VALGRIND, longTestFilter from run_long import LONG_TESTS_DEBUG_VALGRIND, longTestFilter
...@@ -116,6 +117,8 @@ class TestSuite(object): ...@@ -116,6 +117,8 @@ class TestSuite(object):
return None, ret return None, ret
elif module in ['python2', 'python3']: elif module in ['python2', 'python3']:
executable = os.getenv('OPENCV_PYTHON_BINARY', None) executable = os.getenv('OPENCV_PYTHON_BINARY', None)
if executable is None or module == 'python{}'.format(sys.version_info[0]):
executable = sys.executable
if executable is None: if executable is None:
executable = path executable = path
if not self.tryCommand([executable, '--version'], workingDir): if not self.tryCommand([executable, '--version'], workingDir):
......
...@@ -177,7 +177,7 @@ if __name__ == "__main__": ...@@ -177,7 +177,7 @@ if __name__ == "__main__":
prevGroupName = None prevGroupName = None
needNewRow = True needNewRow = True
lastRow = None lastRow = None
for name in sorted(test_cases.iterkeys(), key=alphanum_keyselector): for name in sorted(test_cases.keys(), key=alphanum_keyselector):
cases = test_cases[name] cases = test_cases[name]
if needNewRow: if needNewRow:
lastRow = tbl.newRow() lastRow = tbl.newRow()
......
...@@ -98,7 +98,7 @@ class table(object): ...@@ -98,7 +98,7 @@ class table(object):
def layoutTable(self): def layoutTable(self):
columns = self.columns.values() columns = self.columns.values()
columns.sort(key=lambda c: c.index) columns = sorted(columns, key=lambda c: c.index)
colspanned = [] colspanned = []
rowspanned = [] rowspanned = []
...@@ -206,7 +206,7 @@ class table(object): ...@@ -206,7 +206,7 @@ class table(object):
cell.width = len(max(cell.text, key = lambda line: len(line))) cell.width = len(max(cell.text, key = lambda line: len(line)))
def reformatTextValue(self, value): def reformatTextValue(self, value):
if sys.version_info > (3,): # PY3 fix if sys.version_info >= (2,7):
unicode = str unicode = str
if isinstance(value, str): if isinstance(value, str):
vstr = value vstr = value
...@@ -340,7 +340,7 @@ class table(object): ...@@ -340,7 +340,7 @@ class table(object):
if align == "right": if align == "right":
pattern = "%" + str(width) + "s" pattern = "%" + str(width) + "s"
elif align == "center": elif align == "center":
pattern = "%" + str((width - len(line)) / 2 + len(line)) + "s" + " " * (width - len(line) - (width - len(line)) / 2) pattern = "%" + str((width - len(line)) // 2 + len(line)) + "s" + " " * (width - len(line) - (width - len(line)) // 2)
else: else:
pattern = "%-" + str(width) + "s" pattern = "%-" + str(width) + "s"
...@@ -354,7 +354,7 @@ class table(object): ...@@ -354,7 +354,7 @@ class table(object):
if valign == "bottom": if valign == "bottom":
return height - space return height - space
if valign == "middle": if valign == "middle":
return (height - space + 1) / 2 return (height - space + 1) // 2
return 0 return 0
def htmlPrintTable(self, out, embeedcss = False): def htmlPrintTable(self, out, embeedcss = False):
......
...@@ -202,7 +202,7 @@ def parseLogFile(filename): ...@@ -202,7 +202,7 @@ def parseLogFile(filename):
if attr_name.startswith('cv_') if attr_name.startswith('cv_')
} }
tests = map(TestInfo, log.getElementsByTagName("testcase")) tests = list(map(TestInfo, log.getElementsByTagName("testcase")))
return TestRunInfo(properties, tests) return TestRunInfo(properties, tests)
......
...@@ -1541,7 +1541,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc, ...@@ -1541,7 +1541,7 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
identically 1. */ identically 1. */
frame_rate=(int)(fps+0.5); frame_rate=(int)(fps+0.5);
frame_rate_base=1; frame_rate_base=1;
while (fabs((double)frame_rate/frame_rate_base) - fps > 0.001){ while (fabs(((double)frame_rate/frame_rate_base) - fps) > 0.001){
frame_rate_base*=10; frame_rate_base*=10;
frame_rate=(int)(fps*frame_rate_base + 0.5); frame_rate=(int)(fps*frame_rate_base + 0.5);
} }
...@@ -2374,7 +2374,7 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC ...@@ -2374,7 +2374,7 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
int frame_rate = static_cast<int>(fps+0.5); int frame_rate = static_cast<int>(fps+0.5);
int frame_rate_base = 1; int frame_rate_base = 1;
while (fabs(static_cast<double>(frame_rate)/frame_rate_base) - fps > 0.001) while (fabs((static_cast<double>(frame_rate)/frame_rate_base) - fps) > 0.001)
{ {
frame_rate_base *= 10; frame_rate_base *= 10;
frame_rate = static_cast<int>(fps*frame_rate_base + 0.5); frame_rate = static_cast<int>(fps*frame_rate_base + 0.5);
......
...@@ -39,10 +39,11 @@ def execute(cmd, cwd = None): ...@@ -39,10 +39,11 @@ def execute(cmd, cwd = None):
def getXCodeMajor(): def getXCodeMajor():
ret = check_output(["xcodebuild", "-version"]) ret = check_output(["xcodebuild", "-version"])
m = re.match(r'XCode\s+(\d)\..*', ret, flags=re.IGNORECASE) m = re.match(r'Xcode\s+(\d+)\..*', ret, flags=re.IGNORECASE)
if m: if m:
return int(m.group(1)) return int(m.group(1))
return 0 else:
raise Exception("Failed to parse Xcode version")
class Builder: class Builder:
def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, targets): def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, targets):
......
...@@ -83,6 +83,7 @@ class Builder: ...@@ -83,6 +83,7 @@ class Builder:
"-DCV_TRACE=OFF", "-DCV_TRACE=OFF",
"-DBUILD_SHARED_LIBS=OFF", "-DBUILD_SHARED_LIBS=OFF",
"-DWITH_1394=OFF", "-DWITH_1394=OFF",
"-DWITH_ADE=OFF",
"-DWITH_VTK=OFF", "-DWITH_VTK=OFF",
"-DWITH_EIGEN=OFF", "-DWITH_EIGEN=OFF",
"-DWITH_FFMPEG=OFF", "-DWITH_FFMPEG=OFF",
...@@ -114,8 +115,9 @@ class Builder: ...@@ -114,8 +115,9 @@ class Builder:
"-DBUILD_opencv_apps=OFF", "-DBUILD_opencv_apps=OFF",
"-DBUILD_opencv_calib3d=ON", "-DBUILD_opencv_calib3d=ON",
"-DBUILD_opencv_dnn=ON", "-DBUILD_opencv_dnn=ON",
"-DBUILD_opencv_features2d=OFF", "-DBUILD_opencv_features2d=ON",
"-DBUILD_opencv_flann=OFF", "-DBUILD_opencv_flann=OFF",
"-DBUILD_opencv_gapi=OFF",
"-DBUILD_opencv_ml=OFF", "-DBUILD_opencv_ml=OFF",
"-DBUILD_opencv_photo=OFF", "-DBUILD_opencv_photo=OFF",
"-DBUILD_opencv_imgcodecs=OFF", "-DBUILD_opencv_imgcodecs=OFF",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment