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
6e13ffe1
Commit
6e13ffe1
authored
Mar 27, 2018
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11159 from alalek:samples_avoid_legacy_api
parents
00fff3a8
7f9253ea
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
26 additions
and
101 deletions
+26
-101
core_c.h
modules/core/include/opencv2/core/core_c.h
+1
-10
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+4
-0
imgproc_c.h
modules/imgproc/include/opencv2/imgproc/imgproc_c.h
+0
-1
CMakeLists.txt
samples/CMakeLists.txt
+2
-0
autofocus.cpp
samples/cpp/autofocus.cpp
+2
-2
facedetect.cpp
samples/cpp/facedetect.cpp
+2
-2
filestorage_base64.cpp
samples/cpp/filestorage_base64.cpp
+0
-71
fitellipse.cpp
samples/cpp/fitellipse.cpp
+1
-1
mask_tmpl.cpp
samples/cpp/mask_tmpl.cpp
+1
-1
smiledetect.cpp
samples/cpp/smiledetect.cpp
+3
-3
train_HOG.cpp
samples/cpp/train_HOG.cpp
+1
-1
train_svmsgd.cpp
samples/cpp/train_svmsgd.cpp
+2
-2
MatchTemplate_Demo.cpp
.../tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
+1
-1
Morphology_3.cpp
...orial_code/ImgProc/morph_lines_detection/Morphology_3.cpp
+3
-3
houghlines.cpp
samples/cpp/tutorial_code/ImgTrans/houghlines.cpp
+1
-1
videowriter_basic.cpp
samples/cpp/videowriter_basic.cpp
+1
-1
MainPage.xaml.cpp
samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp
+1
-1
No files found.
modules/core/include/opencv2/core/core_c.h
View file @
6e13ffe1
...
...
@@ -1978,11 +1978,7 @@ The function opens file storage for reading or writing data. In the latter case,
created or an existing file is rewritten. The type of the read or written file is determined by the
filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON.
At the same time, it also supports adding parameters like "example.xml?base64". The three ways
are the same:
@snippet samples/cpp/filestorage_base64.cpp suffix_in_file_name
@snippet samples/cpp/filestorage_base64.cpp flag_write_base64
@snippet samples/cpp/filestorage_base64.cpp flag_write_and_flag_base64
At the same time, it also supports adding parameters like "example.xml?base64".
The function returns a pointer to the CvFileStorage structure.
If the file cannot be opened then the function returns NULL.
...
...
@@ -2206,11 +2202,6 @@ in plain text.
This function can only be used to write a sequence with a type "binary".
Consider the following two examples where their output is the same:
@snippet samples/cpp/filestorage_base64.cpp without_base64_flag
and
@snippet samples/cpp/filestorage_base64.cpp with_write_base64_flag
@param fs File storage
@param src Pointer to the written array
@param len Number of the array elements to write
...
...
modules/imgproc/include/opencv2/imgproc.hpp
View file @
6e13ffe1
...
...
@@ -4339,6 +4339,10 @@ CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray user
//! @addtogroup imgproc_draw
//! @{
/** OpenCV color channel order is BGR[A] */
#define CV_RGB(r, g, b) cv::Scalar((b), (g), (r), 0)
/** @brief Draws a line segment connecting two points.
The function line draws the line segment between pt1 and pt2 points in the image. The line is
...
...
modules/imgproc/include/opencv2/imgproc/imgproc_c.h
View file @
6e13ffe1
...
...
@@ -982,7 +982,6 @@ CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param,
* If a drawn figure is partially or completely outside of the image, it is clipped.*
\****************************************************************************************/
#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 )
#define CV_FILLED -1
#define CV_AA 16
...
...
samples/CMakeLists.txt
View file @
6e13ffe1
...
...
@@ -125,6 +125,8 @@ if(MSVC)
endif
()
endif
()
add_definitions
(
-DDISABLE_OPENCV_24_COMPATIBILITY=1
)
# Avoid C-like legacy API
add_subdirectory
(
cpp
)
if
(
WIN32
)
add_subdirectory
(
directx
)
...
...
samples/cpp/autofocus.cpp
View file @
6e13ffe1
...
...
@@ -133,7 +133,7 @@ static double rateFrame(Mat & frame)
unsigned
long
int
sum
=
0
;
unsigned
long
int
size
=
frame
.
cols
*
frame
.
rows
;
Mat
edges
;
cvtColor
(
frame
,
edges
,
C
V
_BGR2GRAY
);
cvtColor
(
frame
,
edges
,
C
OLOR
_BGR2GRAY
);
GaussianBlur
(
edges
,
edges
,
Size
(
7
,
7
),
1.5
,
1.5
);
Canny
(
edges
,
edges
,
0
,
30
,
3
);
...
...
@@ -324,7 +324,7 @@ int main(int argc, char ** argv)
if
(
!
GlobalArgs
.
output
.
empty
())
{
Size
S
=
Size
((
int
)
cap
.
get
(
CAP_PROP_FRAME_WIDTH
),
(
int
)
cap
.
get
(
CAP_PROP_FRAME_HEIGHT
));
int
fourCC
=
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
);
int
fourCC
=
VideoWriter
::
fourcc
(
'M'
,
'J'
,
'P'
,
'G'
);
videoWriter
.
open
(
GlobalArgs
.
output
,
fourCC
,
GlobalArgs
.
fps
,
S
,
true
);
if
(
!
videoWriter
.
isOpened
())
{
...
...
samples/cpp/facedetect.cpp
View file @
6e13ffe1
...
...
@@ -218,8 +218,8 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
circle
(
img
,
center
,
radius
,
color
,
3
,
8
,
0
);
}
else
rectangle
(
img
,
cv
Point
(
cvRound
(
r
.
x
*
scale
),
cvRound
(
r
.
y
*
scale
)),
cv
Point
(
cvRound
((
r
.
x
+
r
.
width
-
1
)
*
scale
),
cvRound
((
r
.
y
+
r
.
height
-
1
)
*
scale
)),
rectangle
(
img
,
Point
(
cvRound
(
r
.
x
*
scale
),
cvRound
(
r
.
y
*
scale
)),
Point
(
cvRound
((
r
.
x
+
r
.
width
-
1
)
*
scale
),
cvRound
((
r
.
y
+
r
.
height
-
1
)
*
scale
)),
color
,
3
,
8
,
0
);
if
(
nestedCascade
.
empty
()
)
continue
;
...
...
samples/cpp/filestorage_base64.cpp
deleted
100644 → 0
View file @
00fff3a8
#include "opencv2/core.hpp"
#include <iostream>
#include <string>
static
CvFileStorage
*
three_same_ways_of_write_base64
()
{
CvFileStorage
*
fs
=
0
;
cv
::
RNG
rng
;
switch
(
rng
.
uniform
(
0
,
2
)
)
{
case
0
:
//! [suffix_in_file_name]
fs
=
cvOpenFileStorage
(
"example.yml?base64"
,
0
,
CV_STORAGE_WRITE
);
//! [suffix_in_file_name]
break
;
case
1
:
//! [flag_write_base64]
fs
=
cvOpenFileStorage
(
"example.yml"
,
0
,
CV_STORAGE_WRITE_BASE64
);
//! [flag_write_base64]
break
;
case
2
:
//! [flag_write_and_flag_base64]
fs
=
cvOpenFileStorage
(
"example.yml"
,
0
,
CV_STORAGE_WRITE
|
CV_STORAGE_BASE64
);
//! [flag_write_and_flag_base64]
break
;
default:
break
;
}
return
fs
;
}
static
void
two_ways_to_write_rawdata_in_base64
()
{
std
::
vector
<
int
>
rawdata
(
10
,
0x00010203
);
{
// [1]
//! [without_base64_flag]
CvFileStorage
*
fs
=
cvOpenFileStorage
(
"example.xml"
,
0
,
CV_STORAGE_WRITE
);
// both CV_NODE_SEQ and "binary" are necessary.
cvStartWriteStruct
(
fs
,
"rawdata"
,
CV_NODE_SEQ
|
CV_NODE_FLOW
,
"binary"
);
cvWriteRawDataBase64
(
fs
,
rawdata
.
data
(),
static_cast
<
int
>
(
rawdata
.
size
()),
"i"
);
cvEndWriteStruct
(
fs
);
cvReleaseFileStorage
(
&
fs
);
//! [without_base64_flag]
}
{
// [2]
//! [with_write_base64_flag]
CvFileStorage
*
fs
=
cvOpenFileStorage
(
"example.xml"
,
0
,
CV_STORAGE_WRITE_BASE64
);
// parameter, typename "binary" could be omitted.
cvStartWriteStruct
(
fs
,
"rawdata"
,
CV_NODE_SEQ
|
CV_NODE_FLOW
);
cvWriteRawData
(
fs
,
rawdata
.
data
(),
static_cast
<
int
>
(
rawdata
.
size
()),
"i"
);
cvEndWriteStruct
(
fs
);
cvReleaseFileStorage
(
&
fs
);
//! [with_write_base64_flag]
}
}
int
main
(
int
/* argc */
,
char
**
/* argv */
)
{
{
// base64 mode
CvFileStorage
*
fs
=
three_same_ways_of_write_base64
();
cvReleaseFileStorage
(
&
fs
);
}
{
// output rawdata by `cvWriteRawdata*`
two_ways_to_write_rawdata_in_base64
();
}
return
0
;
}
samples/cpp/fitellipse.cpp
View file @
6e13ffe1
...
...
@@ -207,7 +207,7 @@ int main( int argc, char** argv )
}
imshow
(
"source"
,
image
);
namedWindow
(
"result"
,
CV_
WINDOW_NORMAL
);
namedWindow
(
"result"
,
WINDOW_NORMAL
);
// Create toolbars. HighGUI use.
createTrackbar
(
"threshold"
,
"result"
,
&
sliderPos
,
255
,
processImage
);
...
...
samples/cpp/mask_tmpl.cpp
View file @
6e13ffe1
...
...
@@ -50,7 +50,7 @@ int main( int argc, const char** argv )
Rect
rect
;
minMaxLoc
(
res
,
&
minVal
,
&
maxVal
,
&
minLoc
,
&
maxLoc
);
if
(
method
==
CV_TM_SQDIFF
||
method
==
CV_
TM_SQDIFF_NORMED
)
if
(
method
==
TM_SQDIFF
||
method
==
TM_SQDIFF_NORMED
)
rect
=
Rect
(
minLoc
,
tmpl
.
size
());
else
rect
=
Rect
(
maxLoc
,
tmpl
.
size
());
...
...
samples/cpp/smiledetect.cpp
View file @
6e13ffe1
...
...
@@ -177,8 +177,8 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
circle
(
img
,
center
,
radius
,
color
,
3
,
8
,
0
);
}
else
rectangle
(
img
,
cv
Point
(
cvRound
(
r
.
x
*
scale
),
cvRound
(
r
.
y
*
scale
)),
cv
Point
(
cvRound
((
r
.
x
+
r
.
width
-
1
)
*
scale
),
cvRound
((
r
.
y
+
r
.
height
-
1
)
*
scale
)),
rectangle
(
img
,
Point
(
cvRound
(
r
.
x
*
scale
),
cvRound
(
r
.
y
*
scale
)),
Point
(
cvRound
((
r
.
x
+
r
.
width
-
1
)
*
scale
),
cvRound
((
r
.
y
+
r
.
height
-
1
)
*
scale
)),
color
,
3
,
8
,
0
);
const
int
half_height
=
cvRound
((
float
)
r
.
height
/
2
);
...
...
@@ -206,7 +206,7 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
float
intensityZeroOne
=
((
float
)
smile_neighbors
-
min_neighbors
)
/
(
max_neighbors
-
min_neighbors
+
1
);
int
rect_height
=
cvRound
((
float
)
img
.
rows
*
intensityZeroOne
);
Scalar
col
=
Scalar
((
float
)
255
*
intensityZeroOne
,
0
,
0
);
rectangle
(
img
,
cvPoint
(
0
,
img
.
rows
),
cv
Point
(
img
.
cols
/
10
,
img
.
rows
-
rect_height
),
col
,
-
1
);
rectangle
(
img
,
Point
(
0
,
img
.
rows
),
Point
(
img
.
cols
/
10
,
img
.
rows
-
rect_height
),
col
,
-
1
);
}
imshow
(
"result"
,
img
);
...
...
samples/cpp/train_HOG.cpp
View file @
6e13ffe1
...
...
@@ -312,7 +312,7 @@ int main( int argc, char** argv )
/* Default values to train SVM */
svm
->
setCoef0
(
0.0
);
svm
->
setDegree
(
3
);
svm
->
setTermCriteria
(
TermCriteria
(
CV_TERMCRIT_ITER
+
CV_TERMCRIT_
EPS
,
1000
,
1e-3
)
);
svm
->
setTermCriteria
(
TermCriteria
(
TermCriteria
::
MAX_ITER
+
TermCriteria
::
EPS
,
1000
,
1e-3
)
);
svm
->
setGamma
(
0
);
svm
->
setKernel
(
SVM
::
LINEAR
);
svm
->
setNu
(
0.5
);
...
...
samples/cpp/train_svmsgd.cpp
View file @
6e13ffe1
...
...
@@ -189,11 +189,11 @@ static void onMouse( int event, int x, int y, int, void* pData)
switch
(
event
)
{
case
CV_
EVENT_LBUTTONUP
:
case
EVENT_LBUTTONUP
:
addPointRetrainAndRedraw
(
data
,
x
,
y
,
1
);
break
;
case
CV_
EVENT_RBUTTONDOWN
:
case
EVENT_RBUTTONDOWN
:
addPointRetrainAndRedraw
(
data
,
x
,
y
,
-
1
);
break
;
}
...
...
samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
View file @
6e13ffe1
...
...
@@ -97,7 +97,7 @@ void MatchingMethod( int, void* )
//! [match_template]
/// Do the Matching and Normalize
bool
method_accepts_mask
=
(
CV_TM_SQDIFF
==
match_method
||
match_method
==
CV_
TM_CCORR_NORMED
);
bool
method_accepts_mask
=
(
TM_SQDIFF
==
match_method
||
match_method
==
TM_CCORR_NORMED
);
if
(
use_mask
&&
method_accepts_mask
)
{
matchTemplate
(
img
,
templ
,
result
,
match_method
,
mask
);
}
else
...
...
samples/cpp/tutorial_code/ImgProc/morph_lines_detection/Morphology_3.cpp
View file @
6e13ffe1
...
...
@@ -36,7 +36,7 @@ int main(int argc, char** argv)
if
(
src
.
channels
()
==
3
)
{
cvtColor
(
src
,
gray
,
C
V
_BGR2GRAY
);
cvtColor
(
src
,
gray
,
C
OLOR
_BGR2GRAY
);
}
else
{
...
...
@@ -50,7 +50,7 @@ int main(int argc, char** argv)
//! [bin]
// Apply adaptiveThreshold at the bitwise_not of gray, notice the ~ symbol
Mat
bw
;
adaptiveThreshold
(
~
gray
,
bw
,
255
,
CV_
ADAPTIVE_THRESH_MEAN_C
,
THRESH_BINARY
,
15
,
-
2
);
adaptiveThreshold
(
~
gray
,
bw
,
255
,
ADAPTIVE_THRESH_MEAN_C
,
THRESH_BINARY
,
15
,
-
2
);
// Show binary image
show_wait_destroy
(
"binary"
,
bw
);
...
...
@@ -106,7 +106,7 @@ int main(int argc, char** argv)
// Step 1
Mat
edges
;
adaptiveThreshold
(
vertical
,
edges
,
255
,
CV_
ADAPTIVE_THRESH_MEAN_C
,
THRESH_BINARY
,
3
,
-
2
);
adaptiveThreshold
(
vertical
,
edges
,
255
,
ADAPTIVE_THRESH_MEAN_C
,
THRESH_BINARY
,
3
,
-
2
);
show_wait_destroy
(
"edges"
,
edges
);
// Step 2
...
...
samples/cpp/tutorial_code/ImgTrans/houghlines.cpp
View file @
6e13ffe1
...
...
@@ -56,7 +56,7 @@ int main(int argc, char** argv)
pt1
.
y
=
cvRound
(
y0
+
1000
*
(
a
));
pt2
.
x
=
cvRound
(
x0
-
1000
*
(
-
b
));
pt2
.
y
=
cvRound
(
y0
-
1000
*
(
a
));
line
(
cdst
,
pt1
,
pt2
,
Scalar
(
0
,
0
,
255
),
3
,
CV
_AA
);
line
(
cdst
,
pt1
,
pt2
,
Scalar
(
0
,
0
,
255
),
3
,
LINE
_AA
);
}
//![draw_lines]
...
...
samples/cpp/videowriter_basic.cpp
View file @
6e13ffe1
...
...
@@ -35,7 +35,7 @@ int main(int, char**)
//--- INITIALIZE VIDEOWRITER
VideoWriter
writer
;
int
codec
=
CV_FOURCC
(
'M'
,
'J'
,
'P'
,
'G'
);
// select desired codec (must be available at runtime)
int
codec
=
VideoWriter
::
fourcc
(
'M'
,
'J'
,
'P'
,
'G'
);
// select desired codec (must be available at runtime)
double
fps
=
25.0
;
// framerate of the created video stream
string
filename
=
"./live.avi"
;
// name of the output video file
writer
.
open
(
filename
,
codec
,
fps
,
src
.
size
(),
isColor
);
...
...
samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp
View file @
6e13ffe1
...
...
@@ -63,7 +63,7 @@ void FaceDetection::MainPage::detectBtn_Click(Platform::Object^ sender, Windows:
std
::
vector
<
cv
::
Rect
>
facesColl
;
cv
::
Mat
frame_gray
;
cvtColor
(
groupFaces
,
frame_gray
,
C
V
_BGR2GRAY
);
cvtColor
(
groupFaces
,
frame_gray
,
C
OLOR
_BGR2GRAY
);
cv
::
equalizeHist
(
frame_gray
,
frame_gray
);
// Detect faces
...
...
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