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
e3941d09
Commit
e3941d09
authored
Jan 16, 2013
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored approxpoly
parent
867ddebe
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
25 deletions
+41
-25
core.hpp
modules/core/include/opencv2/core/core.hpp
+5
-1
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+36
-7
approx.cpp
modules/imgproc/src/approx.cpp
+0
-0
contours.cpp
modules/imgproc/src/contours.cpp
+0
-17
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
e3941d09
...
...
@@ -3107,6 +3107,10 @@ public:
void
allocate
(
size_t
_size
);
//! deallocates the buffer if it was dynamically allocated
void
deallocate
();
//! resizes the buffer and preserves the content
void
resize
(
size_t
_size
);
//! returns the current buffer size
size_t
size
()
const
;
//! returns pointer to the real buffer, stack-allocated or head-allocated
operator
_Tp
*
();
//! returns read-only pointer to the real buffer, stack-allocated or head-allocated
...
...
@@ -3116,7 +3120,7 @@ protected:
//! pointer to the real buffer, can point to buf if the buffer is small enough
_Tp
*
ptr
;
//! size of the real buffer
size_t
s
ize
;
size_t
s
z
;
//! pre-allocated buffer
_Tp
buf
[
fixed_size
+
buffer_padding
];
};
...
...
modules/core/include/opencv2/core/operations.hpp
View file @
e3941d09
...
...
@@ -2537,13 +2537,13 @@ inline Point LineIterator::pos() const
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
AutoBuffer
<
_Tp
,
fixed_size
>::
AutoBuffer
()
{
ptr
=
buf
;
s
ize
=
fixed_size
;
s
z
=
fixed_size
;
}
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
AutoBuffer
<
_Tp
,
fixed_size
>::
AutoBuffer
(
size_t
_size
)
{
ptr
=
buf
;
s
ize
=
fixed_size
;
s
z
=
fixed_size
;
allocate
(
_size
);
}
...
...
@@ -2552,13 +2552,16 @@ template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::~A
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
void
AutoBuffer
<
_Tp
,
fixed_size
>::
allocate
(
size_t
_size
)
{
if
(
_size
<=
size
)
if
(
_size
<=
sz
)
{
sz
=
_size
;
return
;
}
deallocate
();
if
(
_size
>
fixed_size
)
{
ptr
=
cv
::
allocate
<
_Tp
>
(
_size
)
;
s
ize
=
_size
;
ptr
=
new
_Tp
[
_size
]
;
s
z
=
_size
;
}
}
...
...
@@ -2566,12 +2569,38 @@ template<typename _Tp, size_t fixed_size> inline void AutoBuffer<_Tp, fixed_size
{
if
(
ptr
!=
buf
)
{
cv
::
deallocate
<
_Tp
>
(
ptr
,
size
)
;
delete
[]
ptr
;
ptr
=
buf
;
s
ize
=
fixed_size
;
s
z
=
0
;
}
}
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
void
AutoBuffer
<
_Tp
,
fixed_size
>::
resize
(
size_t
_size
)
{
if
(
_size
<=
sz
)
{
sz
=
_size
;
return
;
}
size_t
i
,
prevsize
=
sz
,
minsize
=
MIN
(
prevsize
,
_size
);
_Tp
*
prevptr
=
ptr
;
ptr
=
_size
>
fixed_size
?
new
_Tp
[
_size
]
:
buf
;
sz
=
_size
;
if
(
ptr
!=
prevptr
)
for
(
i
=
0
;
i
<
minsize
;
i
++
)
ptr
[
i
]
=
prevptr
[
i
];
for
(
i
=
prevsize
;
i
<
_size
;
i
++
)
ptr
[
i
]
=
_Tp
();
if
(
prevptr
!=
buf
)
delete
[]
prevptr
;
}
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
size_t
AutoBuffer
<
_Tp
,
fixed_size
>::
size
()
const
{
return
sz
;
}
template
<
typename
_Tp
,
size_t
fixed_size
>
inline
AutoBuffer
<
_Tp
,
fixed_size
>::
operator
_Tp
*
()
{
return
ptr
;
}
...
...
modules/imgproc/src/approx.cpp
View file @
e3941d09
This diff is collapsed.
Click to expand it.
modules/imgproc/src/contours.cpp
View file @
e3941d09
...
...
@@ -1753,23 +1753,6 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours,
findContours
(
_image
,
_contours
,
noArray
(),
mode
,
method
,
offset
);
}
void
cv
::
approxPolyDP
(
InputArray
_curve
,
OutputArray
_approxCurve
,
double
epsilon
,
bool
closed
)
{
Mat
curve
=
_curve
.
getMat
();
int
npoints
=
curve
.
checkVector
(
2
),
depth
=
curve
.
depth
();
CV_Assert
(
npoints
>=
0
&&
(
depth
==
CV_32S
||
depth
==
CV_32F
));
CvMat
_ccurve
=
curve
;
MemStorage
storage
(
cvCreateMemStorage
());
CvSeq
*
result
=
cvApproxPoly
(
&
_ccurve
,
sizeof
(
CvContour
),
storage
,
CV_POLY_APPROX_DP
,
epsilon
,
closed
);
if
(
result
->
total
>
0
)
{
_approxCurve
.
create
(
result
->
total
,
1
,
CV_MAKETYPE
(
curve
.
depth
(),
2
),
-
1
,
true
);
cvCvtSeqToArray
(
result
,
_approxCurve
.
getMat
().
data
);
}
}
double
cv
::
arcLength
(
InputArray
_curve
,
bool
closed
)
{
Mat
curve
=
_curve
.
getMat
();
...
...
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