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
52326388
Commit
52326388
authored
Dec 04, 2010
by
Gary Bradski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revamped
parent
85c27e5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
grabcut.cpp
samples/cpp/grabcut.cpp
+33
-15
No files found.
samples/cpp/grabcut.cpp
View file @
52326388
...
...
@@ -6,6 +6,27 @@
using
namespace
std
;
using
namespace
cv
;
void
help
()
{
cout
<<
"
\n
This program demonstrates GrabCut segmentation -- select an object in a region
\n
"
"and then grabcut will attempt to segment it out.
\n
"
"Call:
\n
"
"./grabcut <image_name>
\n
"
"
\n
Select a rectangular area around the object you want to segment
\n
"
<<
"
\n
Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
r - restore the original image
\n
"
"
\t
n - next iteration
\n
"
"
\n
"
"
\t
left mouse button - set rectangle
\n
"
"
\n
"
"
\t
CTRL+left mouse button - set GC_BGD pixels
\n
"
"
\t
SHIFT+left mouse button - set CG_FGD pixels
\n
"
"
\n
"
"
\t
CTRL+right mouse button - set GC_PR_BGD pixels
\n
"
"
\t
SHIFT+right mouse button - set CG_PR_FGD pixels
\n
"
<<
endl
;
}
const
Scalar
RED
=
Scalar
(
0
,
0
,
255
);
const
Scalar
PINK
=
Scalar
(
230
,
130
,
255
);
const
Scalar
BLUE
=
Scalar
(
255
,
0
,
0
);
...
...
@@ -254,28 +275,25 @@ void on_mouse( int event, int x, int y, int flags, void* param )
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
1
)
if
(
argc
!=
2
)
{
help
();
return
1
;
}
string
filename
=
argv
[
1
];
if
(
filename
.
empty
()
)
{
cout
<<
"
\n
Durn, couldn't read in "
<<
argv
[
1
]
<<
endl
;
return
1
;
}
Mat
image
=
imread
(
filename
,
1
);
if
(
image
.
empty
()
)
return
1
;
{
cout
<<
"
\n
Durn, couldn't read image filename "
<<
filename
<<
endl
;
return
1
;
}
cout
<<
"First, select the rectangular area
\n
"
<<
"Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
r - restore the original image
\n
"
"
\t
n - next iteration
\n
"
"
\n
"
"
\t
left mouse button - set rectangle
\n
"
"
\n
"
"
\t
CTRL+left mouse button - set GC_BGD pixels
\n
"
"
\t
SHIFT+left mouse button - set CG_FGD pixels
\n
"
"
\n
"
"
\t
CTRL+right mouse button - set GC_PR_BGD pixels
\n
"
"
\t
SHIFT+right mouse button - set CG_PR_FGD pixels
\n
"
;
help
();
const
string
winName
=
"image"
;
cvNamedWindow
(
winName
.
c_str
(),
CV_WINDOW_AUTOSIZE
);
...
...
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