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
d3aa808b
Commit
d3aa808b
authored
Nov 25, 2010
by
Ethan Rublee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renaming cvstarter and breaking it appart
parent
334ac49d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
106 deletions
+0
-106
cvstarter.cpp
samples/cpp/cvstarter.cpp
+0
-106
No files found.
samples/cpp/cvstarter.cpp
deleted
100644 → 0
View file @
334ac49d
/*
* cvstarter.cpp
*
* Created on: Nov 23, 2010
* Author: Ethan Rublee
*
* A starter sample for using opencv, load up a list or get a video stream
* easy as CV_PI right?
*/
#include <opencv2/opencv.hpp>
#include <vector>
using
namespace
cv
;
using
namespace
std
;
//hide the local functions in an anon namespace
namespace
{
void
help
(
char
**
av
)
{
cout
<<
"usage:"
<<
av
[
0
]
<<
" image_list.yaml
\n
"
<<
"
\t
This is a starter sample, to get you up and going in a copy pasta fashion
\n
"
<<
"
\t
Try running imagelist_creator to generate a list of images
\n
"
<<
"
\t
Or try running this with an integer arg like:
\n\n
"
<<
av
[
0
]
<<
" 0
\n
"
<<
"
\t
This will open up the video device."
<<
endl
;
}
bool
readStringList
(
const
string
&
filename
,
vector
<
string
>&
l
)
{
l
.
resize
(
0
);
FileStorage
fs
(
filename
,
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
return
false
;
FileNode
n
=
fs
.
getFirstTopLevelNode
();
if
(
n
.
type
()
!=
FileNode
::
SEQ
)
return
false
;
FileNodeIterator
it
=
n
.
begin
(),
it_end
=
n
.
end
();
for
(;
it
!=
it_end
;
++
it
)
l
.
push_back
((
string
)
*
it
);
return
true
;
}
int
videoProcess
(
VideoCapture
&
capture
)
{
namedWindow
(
"video"
,
CV_WINDOW_KEEPRATIO
);
//resizable window;
Mat
frame
;
for
(;;)
{
capture
>>
frame
;
if
(
frame
.
empty
())
continue
;
imshow
(
"video"
,
frame
);
char
key
=
waitKey
(
5
);
//delay N millis, usually long enough to display and capture input
switch
(
key
)
{
case
'q'
:
case
'Q'
:
case
27
:
//escape key
return
0
;
default
:
break
;
}
}
return
0
;
}
int
imageListProcess
(
vector
<
string
>
images
)
{
namedWindow
(
"image"
,
CV_WINDOW_KEEPRATIO
);
//resizable window;
for
(
size_t
i
=
0
;
i
<
images
.
size
();
i
++
)
{
Mat
image
=
imread
(
images
[
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
// do grayscale processing?
imshow
(
"image"
,
image
);
cout
<<
"Press a key to see the next image in the list."
<<
endl
;
waitKey
();
// wait indefinitely
}
return
0
;
}
}
int
main
(
int
ac
,
char
**
av
)
{
if
(
ac
!=
2
)
{
help
(
av
);
return
1
;
}
std
::
string
arg
=
av
[
1
];
vector
<
string
>
imagelist
;
if
(
!
readStringList
(
arg
,
imagelist
))
{
int
ad
=
atoi
(
arg
.
c_str
());
VideoCapture
capture
(
ad
);
return
videoProcess
(
capture
);
}
else
{
return
imageListProcess
(
imagelist
);
}
return
0
;
}
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