Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ea1f885b
Commit
ea1f885b
authored
Aug 18, 2016
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7055 from gylns:master
parents
66e94467
ac2d79fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
24 deletions
+44
-24
mser.cpp
modules/features2d/src/mser.cpp
+41
-20
test_mser.cpp
modules/features2d/test/test_mser.cpp
+1
-1
test_mser.py
modules/python/test/test_mser.py
+2
-3
No files found.
modules/features2d/src/mser.cpp
View file @
ea1f885b
...
...
@@ -211,7 +211,7 @@ public:
return
;
}
}
if
(
parent_
&&
parent_
->
var
>=
0.
f
&&
var
>=
parent_
->
var
)
if
(
var
>
0.
f
&&
parent_
&&
parent_
->
var
>=
0.
f
&&
var
>=
parent_
->
var
)
return
;
int
xmin
=
INT_MAX
,
ymin
=
INT_MAX
,
xmax
=
INT_MIN
,
ymax
=
INT_MIN
,
j
=
0
;
wp
.
msers
->
push_back
(
vector
<
Point
>
());
...
...
@@ -270,12 +270,20 @@ public:
if
(
!
history
||
(
history
->
size
!=
size
&&
size
>
0
&&
(
gray_level
!=
history
->
val
||
force
)))
{
CompHistory
*
h
=
hptr
++
;
h
->
parent_
=
0
;
h
->
child_
=
history
;
h
->
next_
=
0
;
if
(
history
)
history
->
parent_
=
h
;
CompHistory
*
h
;
if
(
history
&&
gray_level
==
history
->
val
)
h
=
history
;
else
{
h
=
hptr
++
;
h
->
parent_
=
0
;
h
->
child_
=
history
;
h
->
next_
=
0
;
if
(
history
)
history
->
parent_
=
h
;
}
h
->
val
=
gray_level
;
h
->
size
=
size
;
h
->
head
=
head
;
...
...
@@ -283,7 +291,7 @@ public:
history
=
h
;
h
->
var
=
FLT_MAX
;
h
->
checked
=
true
;
if
(
h
->
size
>=
wp
.
p
.
minArea
)
if
(
h
->
size
>=
wp
.
p
.
minArea
)
{
h
->
var
=
-
1.
f
;
h
->
checked
=
false
;
...
...
@@ -291,7 +299,7 @@ public:
}
}
gray_level
=
new_gray_level
;
if
(
update
&&
history
)
if
(
update
&&
history
&&
gray_level
!=
history
->
val
)
history
->
updateTree
(
wp
,
0
,
0
,
final
);
}
...
...
@@ -299,14 +307,13 @@ public:
void
merge
(
ConnectedComp
*
comp1
,
ConnectedComp
*
comp2
,
CompHistory
*&
hptr
,
WParams
&
wp
)
{
comp1
->
growHistory
(
hptr
,
wp
,
-
1
,
false
);
comp2
->
growHistory
(
hptr
,
wp
,
-
1
,
false
);
if
(
comp1
->
size
<
comp2
->
size
)
std
::
swap
(
comp1
,
comp2
);
if
(
comp2
->
size
==
0
)
{
// only grow comp1's history
comp1
->
growHistory
(
hptr
,
wp
,
-
1
,
false
);
gray_level
=
comp1
->
gray_level
;
head
=
comp1
->
head
;
tail
=
comp1
->
tail
;
...
...
@@ -315,21 +322,35 @@ public:
return
;
}
CompHistory
*
h1
=
comp1
->
history
;
CompHistory
*
h2
=
comp2
->
history
;
comp1
->
growHistory
(
hptr
,
wp
,
-
1
,
false
);
comp2
->
growHistory
(
hptr
,
wp
,
-
1
,
false
);
if
(
comp1
->
gray_level
<
comp2
->
gray_level
)
std
::
swap
(
comp1
,
comp2
);
gray_level
=
std
::
max
(
comp1
->
gray_level
,
comp2
->
gray_level
)
;
gray_level
=
comp1
->
gray_level
;
history
=
comp1
->
history
;
wp
.
pix0
[
comp1
->
tail
].
setNext
(
comp2
->
head
);
head
=
comp1
->
head
;
tail
=
comp2
->
tail
;
size
=
comp1
->
size
+
comp2
->
size
;
bool
keep_2nd
=
h2
->
size
>
wp
.
p
.
minArea
;
growHistory
(
hptr
,
wp
,
-
1
,
false
,
keep_2nd
);
if
(
keep_2nd
)
CompHistory
*
h1
=
history
->
child_
;
CompHistory
*
h2
=
comp2
->
history
;
if
(
h2
->
size
>
wp
.
p
.
minArea
)
{
h1
->
next_
=
h2
;
// the child_'s size should be the large one
if
(
h1
&&
h1
->
size
>
h2
->
size
)
{
h2
->
next_
=
h1
->
next_
;
h1
->
next_
=
h2
;
}
else
{
history
->
child_
=
h2
;
h2
->
next_
=
h1
;
}
h2
->
parent_
=
history
;
}
}
...
...
@@ -390,7 +411,7 @@ public:
int
step
=
cols
;
for
(
i
=
1
;
i
<
rows
-
1
;
i
++
)
{
Pixel
*
pptr
=
&
pixbuf
[
i
*
step
+
1
];
Pixel
*
pptr
=
&
pixbuf
[
i
*
step
];
for
(
j
=
1
;
j
<
cols
-
1
;
j
++
)
{
pptr
[
j
].
val
=
0
;
...
...
modules/features2d/test/test_mser.cpp
View file @
ea1f885b
...
...
@@ -132,7 +132,7 @@ TEST(Features2d_MSER, cases)
GaussianBlur
(
src
,
src
,
Size
(
5
,
5
),
1.5
,
1.5
);
int
minRegs
=
use_big_image
?
7
:
2
;
int
maxRegs
=
use_big_image
?
1000
:
15
;
int
maxRegs
=
use_big_image
?
1000
:
20
;
if
(
binarize
&&
(
thresh
==
0
||
thresh
==
255
)
)
minRegs
=
maxRegs
=
0
;
...
...
modules/python/test/test_mser.py
View file @
ea1f885b
...
...
@@ -59,11 +59,11 @@ class mser_test(NewOpenCVTests):
if
blur
:
src
=
cv2
.
GaussianBlur
(
src
,
(
5
,
5
),
1.5
,
1.5
)
minRegs
=
7
if
use_big_image
else
2
maxRegs
=
1000
if
use_big_image
else
15
maxRegs
=
1000
if
use_big_image
else
20
if
binarize
and
(
thresh
==
0
or
thresh
==
255
):
minRegs
=
maxRegs
=
0
msers
,
boxes
=
mserExtractor
.
detectRegions
(
src
)
nmsers
=
len
(
msers
)
self
.
assertEqual
(
nmsers
,
len
(
boxes
))
self
.
assertLessEqual
(
minRegs
,
nmsers
)
self
.
assertGreaterEqual
(
maxRegs
,
nmsers
)
\ No newline at end of file
self
.
assertGreaterEqual
(
maxRegs
,
nmsers
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment