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
511e79ae
Commit
511e79ae
authored
Feb 11, 2014
by
Roman Donchenko
Committed by
OpenCV Buildbot
Feb 11, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2311 from SvenWe:master
parents
1cef6f9f
f7041bac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
grabcut.py
samples/python2/grabcut.py
+5
-5
No files found.
samples/python2/grabcut.py
View file @
511e79ae
...
...
@@ -5,7 +5,7 @@ Interactive Image Segmentation using GrabCut algorithm.
This sample shows interactive image segmentation using grabcut algorithm.
USAGE
:
USAGE:
python grabcut.py <filename>
README FIRST:
...
...
@@ -63,14 +63,14 @@ def onmouse(event,x,y,flags,param):
if
rectangle
==
True
:
img
=
img2
.
copy
()
cv2
.
rectangle
(
img
,(
ix
,
iy
),(
x
,
y
),
BLUE
,
2
)
rect
=
(
ix
,
iy
,
abs
(
ix
-
x
),
abs
(
iy
-
y
))
rect
=
(
min
(
ix
,
x
),
min
(
iy
,
y
)
,
abs
(
ix
-
x
),
abs
(
iy
-
y
))
rect_or_mask
=
0
elif
event
==
cv2
.
EVENT_RBUTTONUP
:
rectangle
=
False
rect_over
=
True
cv2
.
rectangle
(
img
,(
ix
,
iy
),(
x
,
y
),
BLUE
,
2
)
rect
=
(
ix
,
iy
,
abs
(
ix
-
x
),
abs
(
iy
-
y
))
rect
=
(
min
(
ix
,
x
),
min
(
iy
,
y
)
,
abs
(
ix
-
x
),
abs
(
iy
-
y
))
rect_or_mask
=
0
print
" Now press the key 'n' a few times until no further change
\n
"
...
...
@@ -103,7 +103,7 @@ if len(sys.argv) == 2:
filename
=
sys
.
argv
[
1
]
# for drawing purposes
else
:
print
"No input image given, so loading default image, lena.jpg
\n
"
print
"Correct Usage
: python grabcut.py <filename>
\n
"
print
"Correct Usage: python grabcut.py <filename>
\n
"
filename
=
'../cpp/lena.jpg'
img
=
cv2
.
imread
(
filename
)
...
...
@@ -117,7 +117,7 @@ cv2.namedWindow('input')
cv2
.
setMouseCallback
(
'input'
,
onmouse
)
cv2
.
moveWindow
(
'input'
,
img
.
shape
[
1
]
+
10
,
90
)
print
" Instructions
:
\n
"
print
" Instructions:
\n
"
print
" Draw a rectangle around the object using right mouse button
\n
"
while
(
1
):
...
...
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