mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Backported several changes from master branch:
- #3771 - inline round on ARM - #5633 - documentation for MSER - #5666 - run.py fixes
This commit is contained in:
parent
2897da037e
commit
7cb78451d1
@ -305,6 +305,30 @@ enum {
|
||||
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
||||
#define CV_SIGN(a) CV_CMP((a),0)
|
||||
|
||||
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__)
|
||||
# define CV_VFP 1
|
||||
#else
|
||||
# define CV_VFP 0
|
||||
#endif
|
||||
|
||||
|
||||
#if CV_VFP
|
||||
// 1. general scheme
|
||||
#define ARM_ROUND(_value, _asm_string) \
|
||||
int res; \
|
||||
float temp; \
|
||||
asm(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
|
||||
return res;
|
||||
// 2. version for double
|
||||
#ifdef __clang__
|
||||
#define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %[value] \n vmov %[res], %[temp]")
|
||||
#else
|
||||
#define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %P[value] \n vmov %[res], %[temp]")
|
||||
#endif
|
||||
// 3. version for float
|
||||
#define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
|
||||
#endif // CV_VFP
|
||||
|
||||
CV_INLINE int cvRound( double value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && defined __SSE2__ && !defined __APPLE__)
|
||||
@ -323,6 +347,8 @@ CV_INLINE int cvRound( double value )
|
||||
#elif defined CV_ICC || defined __GNUC__
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND(value);
|
||||
# elif CV_VFP
|
||||
ARM_ROUND_DBL(value)
|
||||
# else
|
||||
return (int)lrint(value);
|
||||
# endif
|
||||
|
@ -52,13 +52,46 @@ Maximally stable extremal region extractor. ::
|
||||
void operator()( const Mat& image, vector<vector<Point> >& msers, const Mat& mask ) const;
|
||||
};
|
||||
|
||||
The class encapsulates all the parameters of the MSER extraction algorithm (see
|
||||
http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions). Also see http://code.opencv.org/projects/opencv/wiki/MSER for useful comments and parameters description.
|
||||
The class encapsulates all the parameters of the MSER extraction algorithm (see [wiki]_ article).
|
||||
|
||||
.. note::
|
||||
|
||||
* (Python) A complete example showing the use of the MSER detector can be found at opencv_source_code/samples/python2/mser.py
|
||||
* there are two different implementation of MSER: one for grey image, one for color image the grey image algorithm is taken from: [nister2008linear]_ ; the paper claims to be faster than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop.
|
||||
|
||||
* the color image algorithm is taken from: [forssen2007maximally]_ ; it should be much slower than grey image method ( 3~4 times ); the chi_table.h file is taken directly from paper's source code which is distributed under GPL.
|
||||
|
||||
* (Python) A complete example showing the use of the MSER detector can be found at opencv_source_code/samples/python2/mser.py
|
||||
|
||||
.. [wiki] http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions
|
||||
.. [nister2008linear] David Nistér and Henrik Stewénius. Linear time maximally stable extremal regions. In Computer Vision–ECCV 2008, pages 183–196. Springer, 2008.
|
||||
.. [forssen2007maximally] Per-Erik Forssén. Maximally stable colour regions for recognition and matching. In Computer Vision and Pattern Recognition, 2007. CVPR'07. IEEE Conference on, pages 1–8. IEEE, 2007.
|
||||
|
||||
MSER::MSER
|
||||
----------
|
||||
The MSER constructor
|
||||
|
||||
.. ocv:function:: MSER::MSER(int _delta=5, int _min_area=60, int _max_area=14400, double _max_variation=0.25, double _min_diversity=.2, int _max_evolution=200, double _area_threshold=1.01, double _min_margin=0.003, int _edge_blur_size=5)
|
||||
|
||||
:param _delta: Compares (sizei - sizei-delta)/sizei-delta
|
||||
:param _min_area: Prune the area which smaller than minArea
|
||||
:param _max_area: Prune the area which bigger than maxArea
|
||||
:param _max_variation: Prune the area have simliar size to its children
|
||||
:param _min_diversity: For color image, trace back to cut off mser with diversity less than min_diversity
|
||||
:param _max_evolution: For color image, the evolution steps
|
||||
:param _area_threshold: For color image, the area threshold to cause re-initialize
|
||||
:param _min_margin: For color image, ignore too small margin
|
||||
:param _edge_blur_size: For color image, the aperture size for edge blur
|
||||
|
||||
MSER::operator()
|
||||
----------------
|
||||
|
||||
Detect MSER regions
|
||||
|
||||
.. ocv:function:: void MSER::operator()(const Mat& image, vector<vector<Point> >& msers, const Mat& mask=Mat() ) const
|
||||
|
||||
:param image: Input image (8UC1, 8UC3 or 8UC4)
|
||||
:param msers: Resulting list of point sets
|
||||
:param mask: The operation mask
|
||||
|
||||
ORB
|
||||
---
|
||||
|
@ -31,7 +31,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--list", action="store_true", default=False, help="List available tests (executables)")
|
||||
parser.add_argument("--list_short", action="store_true", default=False, help="List available tests (aliases)")
|
||||
parser.add_argument("--list_short_main", action="store_true", default=False, help="List available tests (main repository, aliases)")
|
||||
parser.add_argument("--configuration", metavar="CFG", default="", help="Visual Studio: force Debug or Release configuration")
|
||||
parser.add_argument("--configuration", metavar="CFG", default=None, help="Force Debug or Release configuration (for Visual Studio and Java tests build)")
|
||||
parser.add_argument("-n", "--dry_run", action="store_true", help="Do not run the tests")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", default=False, help="Print more debug information")
|
||||
|
||||
@ -95,12 +95,12 @@ if __name__ == "__main__":
|
||||
try:
|
||||
if not os.path.isdir(path):
|
||||
raise Err("Not a directory (should contain CMakeCache.txt ot test executables)")
|
||||
cache = CMakeCache()
|
||||
cache = CMakeCache(args.configuration)
|
||||
fname = os.path.join(path, "CMakeCache.txt")
|
||||
|
||||
if os.path.isfile(fname):
|
||||
log.debug("Reading cmake cache file: %s", fname)
|
||||
cache.read(path, fname, args.configuration)
|
||||
cache.read(path, fname)
|
||||
else:
|
||||
log.debug("Assuming folder contains tests: %s", path)
|
||||
cache.setDummy(path)
|
||||
|
@ -48,22 +48,27 @@ class TestSuite(object):
|
||||
return sorted(self.getAliases(fname), key = len)[0]
|
||||
|
||||
def getAliases(self, fname):
|
||||
def getCuts(fname, prefix):
|
||||
# filename w/o extension (opencv_test_core)
|
||||
noext = re.sub(r"\.(exe|apk)$", '', fname)
|
||||
# filename w/o prefix (core.exe)
|
||||
nopref = fname
|
||||
if fname.startswith(prefix):
|
||||
nopref = fname[len(prefix):]
|
||||
# filename w/o prefix and extension (core)
|
||||
noprefext = noext
|
||||
if noext.startswith(prefix):
|
||||
noprefext = noext[len(prefix):]
|
||||
return noext, nopref, noprefext
|
||||
# input is full path ('/home/.../bin/opencv_test_core') or 'java'
|
||||
res = [fname]
|
||||
fname = os.path.basename(fname)
|
||||
res.append(fname) # filename (opencv_test_core.exe)
|
||||
noext = re.sub(r"\.(exe|apk)$", '', fname)
|
||||
res.append(noext) # filename w/o extension (opencv_test_core)
|
||||
nopref = None
|
||||
if fname.startswith(self.nameprefix):
|
||||
nopref = fname[len(self.nameprefix):]
|
||||
res.append(nopref) # filename w/o prefix (core)
|
||||
if noext.startswith(self.nameprefix):
|
||||
res.append(noext[len(self.nameprefix):])
|
||||
if self.options.configuration == "Debug":
|
||||
res.append(re.sub(r"d$", '', noext)) # MSVC debug config, remove 'd' suffix
|
||||
if nopref:
|
||||
res.append(re.sub(r"d$", '', nopref)) # MSVC debug config, remove 'd' suffix
|
||||
for s in getCuts(fname, self.nameprefix):
|
||||
res.append(s)
|
||||
if self.cache.build_type == "Debug" and "Visual Studio" in self.cache.cmake_generator:
|
||||
res.append(re.sub(r"d$", '', s)) # MSVC debug config, remove 'd' suffix
|
||||
log.debug("Aliases: %s", set(res))
|
||||
return set(res)
|
||||
|
||||
def getTest(self, name):
|
||||
@ -101,10 +106,7 @@ class TestSuite(object):
|
||||
args = args[:]
|
||||
exe = os.path.abspath(path)
|
||||
if path == "java":
|
||||
cfg = self.cache.build_type
|
||||
if self.options.configuration:
|
||||
cfg = self.options.configuration
|
||||
cmd = [self.cache.ant_executable, "-Dopencv.build.type=%s" % cfg, "buildAndTest"]
|
||||
cmd = [self.cache.ant_executable, "-Dopencv.build.type=%s" % self.cache.build_type, "buildAndTest"]
|
||||
ret = execute(cmd, cwd = self.cache.java_test_binary_dir + "/.build")
|
||||
return None, ret
|
||||
else:
|
||||
|
@ -152,7 +152,7 @@ parse_patterns = (
|
||||
{'name': "opencv_home", 'default': None, 'pattern': re.compile(r"^OpenCV_SOURCE_DIR:STATIC=(.+)$")},
|
||||
{'name': "opencv_build", 'default': None, 'pattern': re.compile(r"^OpenCV_BINARY_DIR:STATIC=(.+)$")},
|
||||
{'name': "tests_dir", 'default': None, 'pattern': re.compile(r"^EXECUTABLE_OUTPUT_PATH:PATH=(.+)$")},
|
||||
{'name': "build_type", 'default': "Release", 'pattern': re.compile(r"^CMAKE_BUILD_TYPE:STRING=(.*)$")},
|
||||
{'name': "build_type", 'default': "Release", 'pattern': re.compile(r"^CMAKE_BUILD_TYPE:\w+=(.*)$")},
|
||||
{'name': "git_executable", 'default': None, 'pattern': re.compile(r"^GIT_EXECUTABLE:FILEPATH=(.*)$")},
|
||||
{'name': "cxx_flags", 'default': "", 'pattern': re.compile(r"^CMAKE_CXX_FLAGS:STRING=(.*)$")},
|
||||
{'name': "cxx_flags_debug", 'default': "", 'pattern': re.compile(r"^CMAKE_CXX_FLAGS_DEBUG:STRING=(.*)$")},
|
||||
@ -174,17 +174,19 @@ parse_patterns = (
|
||||
)
|
||||
|
||||
class CMakeCache:
|
||||
def __init__(self):
|
||||
def __init__(self, cfg = None):
|
||||
self.setDefaultAttrs()
|
||||
self.cmake_home_vcver = None
|
||||
self.opencv_home_vcver = None
|
||||
self.featuresSIMD = None
|
||||
self.main_modules = []
|
||||
if cfg:
|
||||
self.build_type = cfg
|
||||
|
||||
def setDummy(self, path):
|
||||
self.tests_dir = os.path.normpath(path)
|
||||
|
||||
def read(self, path, fname, cfg):
|
||||
def read(self, path, fname):
|
||||
rx = re.compile(r'^opencv_(\w+)_SOURCE_DIR:STATIC=(.*)$')
|
||||
module_paths = {} # name -> path
|
||||
with open(fname, "rt") as cachefile:
|
||||
@ -213,10 +215,7 @@ class CMakeCache:
|
||||
|
||||
# fix VS test binary path (add Debug or Release)
|
||||
if "Visual Studio" in self.cmake_generator:
|
||||
if cfg:
|
||||
self.tests_dir = os.path.join(self.tests_dir, self.options.configuration)
|
||||
else:
|
||||
self.tests_dir = os.path.join(self.tests_dir, self.build_type)
|
||||
self.tests_dir = os.path.join(self.tests_dir, self.build_type)
|
||||
|
||||
self.cmake_home_vcver = readGitVersion(self.git_executable, self.cmake_home)
|
||||
if self.opencv_home == self.cmake_home:
|
||||
|
Loading…
Reference in New Issue
Block a user