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
4046d9f8
Commit
4046d9f8
authored
Jan 14, 2018
by
Suleyman TURKMEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update samples
parent
70ff4af4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
32 deletions
+28
-32
resnet_ssd_face.cpp
samples/dnn/resnet_ssd_face.cpp
+3
-5
ssd_mobilenet_object_detection.cpp
samples/dnn/ssd_mobilenet_object_detection.cpp
+17
-15
ssd_object_detection.cpp
samples/dnn/ssd_object_detection.cpp
+4
-6
yolo_object_detection.cpp
samples/dnn/yolo_object_detection.cpp
+4
-6
No files found.
samples/dnn/resnet_ssd_face.cpp
View file @
4046d9f8
#include <opencv2/dnn.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
dnn
;
#include <iostream>
#include <cstdlib>
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
::
dnn
;
const
size_t
inWidth
=
300
;
const
size_t
inWidth
=
300
;
const
size_t
inHeight
=
300
;
const
size_t
inHeight
=
300
;
...
@@ -152,7 +150,7 @@ int main(int argc, char** argv)
...
@@ -152,7 +150,7 @@ int main(int argc, char** argv)
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
rectangle
(
frame
,
Rect
(
Point
(
xLeftBottom
,
yLeftBottom
-
labelSize
.
height
),
rectangle
(
frame
,
Rect
(
Point
(
xLeftBottom
,
yLeftBottom
-
labelSize
.
height
),
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
Scalar
(
255
,
255
,
255
),
CV_
FILLED
);
Scalar
(
255
,
255
,
255
),
FILLED
);
putText
(
frame
,
label
,
Point
(
xLeftBottom
,
yLeftBottom
),
putText
(
frame
,
label
,
Point
(
xLeftBottom
,
yLeftBottom
),
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
}
}
...
...
samples/dnn/ssd_mobilenet_object_detection.cpp
View file @
4046d9f8
...
@@ -2,14 +2,11 @@
...
@@ -2,14 +2,11 @@
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
dnn
;
#include <fstream>
#include <iostream>
#include <cstdlib>
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
::
dnn
;
const
size_t
inWidth
=
300
;
const
size_t
inWidth
=
300
;
const
size_t
inHeight
=
300
;
const
size_t
inHeight
=
300
;
...
@@ -22,11 +19,13 @@ const char* classNames[] = {"background",
...
@@ -22,11 +19,13 @@ const char* classNames[] = {"background",
"motorbike"
,
"person"
,
"pottedplant"
,
"motorbike"
,
"person"
,
"pottedplant"
,
"sheep"
,
"sofa"
,
"train"
,
"tvmonitor"
};
"sheep"
,
"sofa"
,
"train"
,
"tvmonitor"
};
const
char
*
param
s
const
String
key
s
=
"{ help | false | print usage }"
=
"{ help | false | print usage }"
"{ proto | MobileNetSSD_deploy.prototxt | model configuration }"
"{ proto | MobileNetSSD_deploy.prototxt | model configuration }"
"{ model | MobileNetSSD_deploy.caffemodel | model weights }"
"{ model | MobileNetSSD_deploy.caffemodel | model weights }"
"{ camera_device | 0 | camera device number }"
"{ camera_device | 0 | camera device number }"
"{ camera_width | 640 | camera device width }"
"{ camera_height | 480 | camera device height }"
"{ video | | video or image for detection}"
"{ video | | video or image for detection}"
"{ out | | path to output video file}"
"{ out | | path to output video file}"
"{ min_confidence | 0.2 | min confidence }"
"{ min_confidence | 0.2 | min confidence }"
...
@@ -35,7 +34,7 @@ const char* params
...
@@ -35,7 +34,7 @@ const char* params
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
CommandLineParser
parser
(
argc
,
argv
,
param
s
);
CommandLineParser
parser
(
argc
,
argv
,
key
s
);
parser
.
about
(
"This sample uses MobileNet Single-Shot Detector "
parser
.
about
(
"This sample uses MobileNet Single-Shot Detector "
"(https://arxiv.org/abs/1704.04861) "
"(https://arxiv.org/abs/1704.04861) "
"to detect objects on camera/video/image.
\n
"
"to detect objects on camera/video/image.
\n
"
...
@@ -43,14 +42,14 @@ int main(int argc, char** argv)
...
@@ -43,14 +42,14 @@ int main(int argc, char** argv)
"https://github.com/chuanqi305/MobileNet-SSD
\n
"
"https://github.com/chuanqi305/MobileNet-SSD
\n
"
"Default network is 300x300 and 20-classes VOC.
\n
"
);
"Default network is 300x300 and 20-classes VOC.
\n
"
);
if
(
parser
.
get
<
bool
>
(
"help"
)
||
argc
==
1
)
if
(
parser
.
get
<
bool
>
(
"help"
))
{
{
parser
.
printMessage
();
parser
.
printMessage
();
return
0
;
return
0
;
}
}
String
modelConfiguration
=
parser
.
get
<
s
tring
>
(
"proto"
);
String
modelConfiguration
=
parser
.
get
<
S
tring
>
(
"proto"
);
String
modelBinary
=
parser
.
get
<
s
tring
>
(
"model"
);
String
modelBinary
=
parser
.
get
<
S
tring
>
(
"model"
);
CV_Assert
(
!
modelConfiguration
.
empty
()
&&
!
modelBinary
.
empty
());
CV_Assert
(
!
modelConfiguration
.
empty
()
&&
!
modelBinary
.
empty
());
//! [Initialize network]
//! [Initialize network]
...
@@ -82,6 +81,9 @@ int main(int argc, char** argv)
...
@@ -82,6 +81,9 @@ int main(int argc, char** argv)
cout
<<
"Couldn't find camera: "
<<
cameraDevice
<<
endl
;
cout
<<
"Couldn't find camera: "
<<
cameraDevice
<<
endl
;
return
-
1
;
return
-
1
;
}
}
cap
.
set
(
CAP_PROP_FRAME_WIDTH
,
parser
.
get
<
int
>
(
"camera_width"
));
cap
.
set
(
CAP_PROP_FRAME_HEIGHT
,
parser
.
get
<
int
>
(
"camera_height"
));
}
}
else
else
{
{
...
@@ -94,11 +96,11 @@ int main(int argc, char** argv)
...
@@ -94,11 +96,11 @@ int main(int argc, char** argv)
}
}
//Acquire input size
//Acquire input size
Size
inVideoSize
((
int
)
cap
.
get
(
C
V_C
AP_PROP_FRAME_WIDTH
),
Size
inVideoSize
((
int
)
cap
.
get
(
CAP_PROP_FRAME_WIDTH
),
(
int
)
cap
.
get
(
C
V_C
AP_PROP_FRAME_HEIGHT
));
(
int
)
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
));
double
fps
=
cap
.
get
(
C
V_C
AP_PROP_FPS
);
double
fps
=
cap
.
get
(
CAP_PROP_FPS
);
int
fourcc
=
static_cast
<
int
>
(
cap
.
get
(
C
V_C
AP_PROP_FOURCC
));
int
fourcc
=
static_cast
<
int
>
(
cap
.
get
(
CAP_PROP_FOURCC
));
VideoWriter
outputVideo
;
VideoWriter
outputVideo
;
outputVideo
.
open
(
parser
.
get
<
String
>
(
"out"
)
,
outputVideo
.
open
(
parser
.
get
<
String
>
(
"out"
)
,
(
fourcc
!=
0
?
fourcc
:
VideoWriter
::
fourcc
(
'M'
,
'J'
,
'P'
,
'G'
)),
(
fourcc
!=
0
?
fourcc
:
VideoWriter
::
fourcc
(
'M'
,
'J'
,
'P'
,
'G'
)),
...
@@ -168,7 +170,7 @@ int main(int argc, char** argv)
...
@@ -168,7 +170,7 @@ int main(int argc, char** argv)
top
=
max
(
top
,
labelSize
.
height
);
top
=
max
(
top
,
labelSize
.
height
);
rectangle
(
frame
,
Point
(
left
,
top
-
labelSize
.
height
),
rectangle
(
frame
,
Point
(
left
,
top
-
labelSize
.
height
),
Point
(
left
+
labelSize
.
width
,
top
+
baseLine
),
Point
(
left
+
labelSize
.
width
,
top
+
baseLine
),
Scalar
(
255
,
255
,
255
),
CV_
FILLED
);
Scalar
(
255
,
255
,
255
),
FILLED
);
putText
(
frame
,
label
,
Point
(
left
,
top
),
putText
(
frame
,
label
,
Point
(
left
,
top
),
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
}
}
...
...
samples/dnn/ssd_object_detection.cpp
View file @
4046d9f8
...
@@ -2,13 +2,11 @@
...
@@ -2,13 +2,11 @@
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/highgui.hpp>
using
namespace
cv
;
using
namespace
cv
::
dnn
;
#include <fstream>
#include <iostream>
#include <iostream>
#include <cstdlib>
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
::
dnn
;
const
char
*
classNames
[]
=
{
"background"
,
const
char
*
classNames
[]
=
{
"background"
,
"aeroplane"
,
"bicycle"
,
"bird"
,
"boat"
,
"aeroplane"
,
"bicycle"
,
"bird"
,
"boat"
,
...
@@ -144,7 +142,7 @@ int main(int argc, char** argv)
...
@@ -144,7 +142,7 @@ int main(int argc, char** argv)
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
rectangle
(
frame
,
Rect
(
Point
(
xLeftBottom
,
yLeftBottom
-
labelSize
.
height
),
rectangle
(
frame
,
Rect
(
Point
(
xLeftBottom
,
yLeftBottom
-
labelSize
.
height
),
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
Scalar
(
255
,
255
,
255
),
CV_
FILLED
);
Scalar
(
255
,
255
,
255
),
FILLED
);
putText
(
frame
,
label
,
Point
(
xLeftBottom
,
yLeftBottom
),
putText
(
frame
,
label
,
Point
(
xLeftBottom
,
yLeftBottom
),
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
}
}
...
...
samples/dnn/yolo_object_detection.cpp
View file @
4046d9f8
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
#include <opencv2/highgui.hpp>
#include <opencv2/highgui.hpp>
#include <fstream>
#include <fstream>
#include <iostream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
using
namespace
std
;
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
;
...
@@ -26,7 +24,7 @@ static const char* params =
...
@@ -26,7 +24,7 @@ static const char* params =
"{ model | | model weights }"
"{ model | | model weights }"
"{ camera_device | 0 | camera device number}"
"{ camera_device | 0 | camera device number}"
"{ source | | video or image for detection}"
"{ source | | video or image for detection}"
"{
save | | file name output
}"
"{
out | | path to output video file
}"
"{ fps | 3 | frame per second }"
"{ fps | 3 | frame per second }"
"{ style | box | box or line style draw }"
"{ style | box | box or line style draw }"
"{ min_confidence | 0.24 | min confidence }"
"{ min_confidence | 0.24 | min confidence }"
...
@@ -84,9 +82,9 @@ int main(int argc, char** argv)
...
@@ -84,9 +82,9 @@ int main(int argc, char** argv)
}
}
}
}
if
(
!
parser
.
get
<
String
>
(
"
save
"
).
empty
())
if
(
!
parser
.
get
<
String
>
(
"
out
"
).
empty
())
{
{
writer
.
open
(
parser
.
get
<
String
>
(
"
save
"
),
codec
,
fps
,
Size
((
int
)
cap
.
get
(
CAP_PROP_FRAME_WIDTH
),(
int
)
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
)),
1
);
writer
.
open
(
parser
.
get
<
String
>
(
"
out
"
),
codec
,
fps
,
Size
((
int
)
cap
.
get
(
CAP_PROP_FRAME_WIDTH
),(
int
)
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
)),
1
);
}
}
vector
<
String
>
classNamesVec
;
vector
<
String
>
classNamesVec
;
...
@@ -169,7 +167,7 @@ int main(int argc, char** argv)
...
@@ -169,7 +167,7 @@ int main(int argc, char** argv)
int
baseLine
=
0
;
int
baseLine
=
0
;
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
Size
labelSize
=
getTextSize
(
label
,
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
rectangle
(
frame
,
Rect
(
p1
,
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
rectangle
(
frame
,
Rect
(
p1
,
Size
(
labelSize
.
width
,
labelSize
.
height
+
baseLine
)),
object_roi_color
,
CV_
FILLED
);
object_roi_color
,
FILLED
);
putText
(
frame
,
label
,
p1
+
Point
(
0
,
labelSize
.
height
),
putText
(
frame
,
label
,
p1
+
Point
(
0
,
labelSize
.
height
),
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
0
));
FONT_HERSHEY_SIMPLEX
,
0.5
,
Scalar
(
0
,
0
,
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