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
e955bcb8
Commit
e955bcb8
authored
Oct 11, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9824 from sturkmen72:upd_minEnclosingTriangle
parents
ec240915
af9c8377
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
27 deletions
+10
-27
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+3
-5
min_enclosing_triangle.cpp
modules/imgproc/src/min_enclosing_triangle.cpp
+1
-13
minarea.cpp
samples/cpp/minarea.cpp
+6
-9
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
e955bcb8
...
...
@@ -3920,9 +3920,8 @@ CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
/** @brief Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a
specified point set. See the OpenCV sample minarea.cpp . Developer should keep in mind that the
returned rotatedRect can contain negative indices when data is close to the containing Mat element
boundary.
specified point set. Developer should keep in mind that the returned RotatedRect can contain negative
indices when data is close to the containing Mat element boundary.
@param points Input vector of 2D points, stored in std::vector\<\> or Mat
*/
...
...
@@ -3943,8 +3942,7 @@ CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points);
/** @brief Finds a circle of the minimum area enclosing a 2D point set.
The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. See
the OpenCV sample minarea.cpp .
The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm.
@param points Input vector of 2D points, stored in std::vector\<\> or Mat
@param center Output center of the circle.
...
...
modules/imgproc/src/min_enclosing_triangle.cpp
View file @
e955bcb8
...
...
@@ -129,8 +129,6 @@ static bool areOnTheSameSideOfLine(const cv::Point2f &p1, const cv::Point2f &p2,
static
double
areaOfTriangle
(
const
cv
::
Point2f
&
a
,
const
cv
::
Point2f
&
b
,
const
cv
::
Point2f
&
c
);
static
void
copyResultingTriangle
(
const
std
::
vector
<
cv
::
Point2f
>
&
resultingTriangle
,
cv
::
OutputArray
triangle
);
static
void
createConvexHull
(
cv
::
InputArray
points
,
std
::
vector
<
cv
::
Point2f
>
&
polygon
);
static
double
distanceBtwPoints
(
const
cv
::
Point2f
&
a
,
const
cv
::
Point2f
&
b
);
...
...
@@ -324,7 +322,7 @@ static void findMinEnclosingTriangle(cv::InputArray points,
createConvexHull
(
points
,
polygon
);
findMinEnclosingTriangle
(
polygon
,
resultingTriangle
,
area
);
c
opyResultingTriangle
(
resultingTriangle
,
triangle
);
c
v
::
Mat
(
resultingTriangle
).
copyTo
(
triangle
);
}
//! Create the convex hull of the given set of points
...
...
@@ -364,16 +362,6 @@ static void findMinEnclosingTriangle(const std::vector<cv::Point2f> &polygon,
}
}
//! Copy resultingTriangle to the OutputArray triangle
/*!
* @param resultingTriangle Minimum area triangle enclosing the given polygon found by the algorithm
* @param triangle Minimum area triangle enclosing the given polygon returned to the user
*/
static
void
copyResultingTriangle
(
const
std
::
vector
<
cv
::
Point2f
>
&
resultingTriangle
,
cv
::
OutputArray
triangle
)
{
cv
::
Mat
(
resultingTriangle
).
copyTo
(
triangle
);
}
//! Initialisation function
/*!
* @param triangle Minimum area triangle enclosing the given polygon
...
...
samples/cpp/minarea.cpp
View file @
e955bcb8
...
...
@@ -11,10 +11,7 @@ static void help()
cout
<<
"This program demonstrates finding the minimum enclosing box, triangle or circle of a set
\n
"
<<
"of points using functions: minAreaRect() minEnclosingTriangle() minEnclosingCircle().
\n
"
<<
"Random points are generated and then enclosed.
\n\n
"
<<
"Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.
\n\n
"
<<
"Call:
\n
"
<<
"./minarea
\n
"
<<
"Using OpenCV v"
<<
CV_VERSION
<<
"
\n
"
<<
endl
;
<<
"Press ESC, 'q' or 'Q' to exit and any other key to regenerate the set of points.
\n\n
"
;
}
int
main
(
int
/*argc*/
,
char
**
/*argv*/
)
...
...
@@ -40,18 +37,18 @@ int main( int /*argc*/, char** /*argv*/ )
}
// Find the minimum area enclosing bounding box
RotatedRect
box
=
minAreaRect
(
Mat
(
points
));
Point2f
vtx
[
4
];
RotatedRect
box
=
minAreaRect
(
points
);
box
.
points
(
vtx
);
// Find the minimum area enclosing triangle
vector
<
Point2f
>
triangle
;
minEnclosingTriangle
(
points
,
triangle
);
// Find the minimum area enclosing circle
Point2f
center
,
vtx
[
4
]
;
Point2f
center
;
float
radius
=
0
;
minEnclosingCircle
(
Mat
(
points
),
center
,
radius
);
box
.
points
(
vtx
);
minEnclosingCircle
(
points
,
center
,
radius
);
img
=
Scalar
::
all
(
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