Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
7494ceb3
Commit
7494ceb3
authored
Apr 10, 2017
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1093 from lhelontra:py_selective_search
parents
21f39397
83fef803
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
segmentation.hpp
modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
+1
-1
selectivesearchsegmentation_demo.py
modules/ximgproc/samples/selectivesearchsegmentation_demo.py
+60
-0
No files found.
modules/ximgproc/include/opencv2/ximgproc/segmentation.hpp
View file @
7494ceb3
...
...
@@ -236,7 +236,7 @@ namespace cv {
/** @brief Based on all images, graph segmentations and stragies, computes all possible rects and return them
@param rects The list of rects. The first ones are more relevents than the lasts ones.
*/
CV_WRAP
virtual
void
process
(
std
::
vector
<
Rect
>&
rects
)
=
0
;
CV_WRAP
virtual
void
process
(
CV_OUT
std
::
vector
<
Rect
>&
rects
)
=
0
;
};
/** @brief Create a new SelectiveSearchSegmentation class.
...
...
modules/ximgproc/samples/selectivesearchsegmentation_demo.py
0 → 100644
View file @
7494ceb3
#!/usr/bin/env python
'''
A program demonstrating the use and capabilities of a particular image segmentation algorithm described
in Jasper R. R. Uijlings, Koen E. A. van de Sande, Theo Gevers, Arnold W. M. Smeulders:
"Selective Search for Object Recognition"
International Journal of Computer Vision, Volume 104 (2), page 154-171, 2013
Usage:
./selectivesearchsegmentation_demo.py input_image (single|fast|quality)
Use "a" to display less rects, 'd' to display more rects, "q" to quit.
'''
import
cv2
import
sys
if
__name__
==
'__main__'
:
img
=
cv2
.
imread
(
sys
.
argv
[
1
])
cv2
.
setUseOptimized
(
True
)
cv2
.
setNumThreads
(
8
)
gs
=
cv2
.
ximgproc
.
segmentation
.
createSelectiveSearchSegmentation
()
gs
.
setBaseImage
(
img
)
if
(
sys
.
argv
[
2
][
0
]
==
's'
):
gs
.
switchToSingleStrategy
()
elif
(
sys
.
argv
[
2
][
0
]
==
'f'
):
gs
.
switchToSelectiveSearchFast
()
elif
(
sys
.
argv
[
2
][
0
]
==
'q'
):
gs
.
switchToSelectiveSearchQuality
()
else
:
print
(
__doc__
)
sys
.
exit
(
1
)
rects
=
gs
.
process
()
nb_rects
=
10
while
True
:
wimg
=
img
.
copy
()
for
i
in
range
(
len
(
rects
)):
if
(
i
<
nb_rects
):
x
,
y
,
w
,
h
=
rects
[
i
]
cv2
.
rectangle
(
wimg
,
(
x
,
y
),
(
x
+
w
,
y
+
h
),
(
0
,
255
,
0
),
1
,
cv2
.
LINE_AA
)
cv2
.
imshow
(
"Output"
,
wimg
);
c
=
cv2
.
waitKey
()
if
(
c
==
100
):
nb_rects
+=
10
elif
(
c
==
97
and
nb_rects
>
10
):
nb_rects
-=
10
elif
(
c
==
113
):
break
cv2
.
destroyAllWindows
()
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