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
a937d9d4
Commit
a937d9d4
authored
Nov 29, 2010
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unified the coordinate interpretation in RotatedRect (ticket #425)
parent
4a973d46
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
39 deletions
+51
-39
operations.hpp
modules/core/include/opencv2/core/operations.hpp
+0
-28
drawing.cpp
modules/core/src/drawing.cpp
+1
-1
matrix.cpp
modules/core/src/matrix.cpp
+31
-0
rotcalipers.cpp
modules/imgproc/src/rotcalipers.cpp
+6
-6
camshift.cpp
modules/video/src/camshift.cpp
+7
-1
camshiftdemo.cpp
samples/cpp/camshiftdemo.cpp
+0
-1
fitellipse.cpp
samples/cpp/fitellipse.cpp
+5
-1
acamshift.cpp
tests/cv/src/acamshift.cpp
+1
-1
No files found.
modules/core/include/opencv2/core/operations.hpp
View file @
a937d9d4
...
...
@@ -1765,34 +1765,6 @@ inline RotatedRect::operator CvBox2D() const
CvBox2D
box
;
box
.
center
=
center
;
box
.
size
=
size
;
box
.
angle
=
angle
;
return
box
;
}
inline
void
RotatedRect
::
points
(
Point2f
pt
[])
const
{
double
_angle
=
angle
*
CV_PI
/
180.
;
float
a
=
(
float
)
cos
(
_angle
)
*
0.5
f
;
float
b
=
(
float
)
sin
(
_angle
)
*
0.5
f
;
pt
[
0
].
x
=
center
.
x
-
a
*
size
.
height
-
b
*
size
.
width
;
pt
[
0
].
y
=
center
.
y
+
b
*
size
.
height
-
a
*
size
.
width
;
pt
[
1
].
x
=
center
.
x
+
a
*
size
.
height
-
b
*
size
.
width
;
pt
[
1
].
y
=
center
.
y
-
b
*
size
.
height
-
a
*
size
.
width
;
pt
[
2
].
x
=
2
*
center
.
x
-
pt
[
0
].
x
;
pt
[
2
].
y
=
2
*
center
.
y
-
pt
[
0
].
y
;
pt
[
3
].
x
=
2
*
center
.
x
-
pt
[
1
].
x
;
pt
[
3
].
y
=
2
*
center
.
y
-
pt
[
1
].
y
;
}
inline
Rect
RotatedRect
::
boundingRect
()
const
{
Point2f
pt
[
4
];
points
(
pt
);
Rect
r
(
cvFloor
(
min
(
min
(
min
(
pt
[
0
].
x
,
pt
[
1
].
x
),
pt
[
2
].
x
),
pt
[
3
].
x
)),
cvFloor
(
min
(
min
(
min
(
pt
[
0
].
y
,
pt
[
1
].
y
),
pt
[
2
].
y
),
pt
[
3
].
y
)),
cvCeil
(
max
(
max
(
max
(
pt
[
0
].
x
,
pt
[
1
].
x
),
pt
[
2
].
x
),
pt
[
3
].
x
)),
cvCeil
(
max
(
max
(
max
(
pt
[
0
].
y
,
pt
[
1
].
y
),
pt
[
2
].
y
),
pt
[
3
].
y
)));
r
.
width
-=
r
.
x
-
1
;
r
.
height
-=
r
.
y
-
1
;
return
r
;
}
//////////////////////////////// Scalar_ ///////////////////////////////
...
...
modules/core/src/drawing.cpp
View file @
a937d9d4
...
...
@@ -877,7 +877,7 @@ void ellipse2Poly( Point center, Size axes, int angle,
y
=
size_b
*
SinTable
[
angle
];
Point
pt
;
pt
.
x
=
cvRound
(
cx
+
x
*
alpha
-
y
*
beta
);
pt
.
y
=
cvRound
(
cy
-
x
*
beta
-
y
*
alpha
);
pt
.
y
=
cvRound
(
cy
+
x
*
beta
+
y
*
alpha
);
if
(
pt
!=
prevPt
)
pts
.
push_back
(
pt
);
}
...
...
modules/core/src/matrix.cpp
View file @
a937d9d4
...
...
@@ -3043,6 +3043,37 @@ void normalize( const SparseMat& src, SparseMat& dst, double a, int norm_type )
src
.
convertTo
(
dst
,
-
1
,
scale
);
}
////////////////////// RotatedRect //////////////////////
void
RotatedRect
::
points
(
Point2f
pt
[])
const
{
double
_angle
=
angle
*
CV_PI
/
180.
;
float
b
=
(
float
)
cos
(
_angle
)
*
0.5
f
;
float
a
=
(
float
)
sin
(
_angle
)
*
0.5
f
;
pt
[
0
].
x
=
center
.
x
-
a
*
size
.
height
-
b
*
size
.
width
;
pt
[
0
].
y
=
center
.
y
+
b
*
size
.
height
-
a
*
size
.
width
;
pt
[
1
].
x
=
center
.
x
+
a
*
size
.
height
-
b
*
size
.
width
;
pt
[
1
].
y
=
center
.
y
-
b
*
size
.
height
-
a
*
size
.
width
;
pt
[
2
].
x
=
2
*
center
.
x
-
pt
[
0
].
x
;
pt
[
2
].
y
=
2
*
center
.
y
-
pt
[
0
].
y
;
pt
[
3
].
x
=
2
*
center
.
x
-
pt
[
1
].
x
;
pt
[
3
].
y
=
2
*
center
.
y
-
pt
[
1
].
y
;
}
inline
Rect
RotatedRect
::
boundingRect
()
const
{
Point2f
pt
[
4
];
points
(
pt
);
Rect
r
(
cvFloor
(
min
(
min
(
min
(
pt
[
0
].
x
,
pt
[
1
].
x
),
pt
[
2
].
x
),
pt
[
3
].
x
)),
cvFloor
(
min
(
min
(
min
(
pt
[
0
].
y
,
pt
[
1
].
y
),
pt
[
2
].
y
),
pt
[
3
].
y
)),
cvCeil
(
max
(
max
(
max
(
pt
[
0
].
x
,
pt
[
1
].
x
),
pt
[
2
].
x
),
pt
[
3
].
x
)),
cvCeil
(
max
(
max
(
max
(
pt
[
0
].
y
,
pt
[
1
].
y
),
pt
[
2
].
y
),
pt
[
3
].
y
)));
r
.
width
-=
r
.
x
-
1
;
r
.
height
-=
r
.
y
-
1
;
return
r
;
}
}
...
...
modules/imgproc/src/rotcalipers.cpp
View file @
a937d9d4
...
...
@@ -415,9 +415,9 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
icvRotatingCalipers
(
points
,
n
,
CV_CALIPERS_MINAREARECT
,
(
float
*
)
out
);
box
.
center
.
x
=
out
[
0
].
x
+
(
out
[
1
].
x
+
out
[
2
].
x
)
*
0.5
f
;
box
.
center
.
y
=
out
[
0
].
y
+
(
out
[
1
].
y
+
out
[
2
].
y
)
*
0.5
f
;
box
.
size
.
height
=
(
float
)
sqrt
((
double
)
out
[
1
].
x
*
out
[
1
].
x
+
(
double
)
out
[
1
].
y
*
out
[
1
].
y
);
box
.
size
.
width
=
(
float
)
sqrt
((
double
)
out
[
2
].
x
*
out
[
2
].
x
+
(
double
)
out
[
2
].
y
*
out
[
2
].
y
);
box
.
angle
=
(
float
)
atan2
(
-
(
double
)
out
[
1
].
y
,
(
double
)
out
[
1
].
x
);
box
.
size
.
width
=
(
float
)
sqrt
((
double
)
out
[
1
].
x
*
out
[
1
].
x
+
(
double
)
out
[
1
].
y
*
out
[
1
].
y
);
box
.
size
.
height
=
(
float
)
sqrt
((
double
)
out
[
2
].
x
*
out
[
2
].
x
+
(
double
)
out
[
2
].
y
*
out
[
2
].
y
);
box
.
angle
=
(
float
)
atan2
(
(
double
)
out
[
1
].
y
,
(
double
)
out
[
1
].
x
);
}
else
if
(
n
==
2
)
{
...
...
@@ -425,9 +425,9 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
box
.
center
.
y
=
(
points
[
0
].
y
+
points
[
1
].
y
)
*
0.5
f
;
double
dx
=
points
[
1
].
x
-
points
[
0
].
x
;
double
dy
=
points
[
1
].
y
-
points
[
0
].
y
;
box
.
size
.
height
=
(
float
)
sqrt
(
dx
*
dx
+
dy
*
dy
);
box
.
size
.
width
=
0
;
box
.
angle
=
(
float
)
atan2
(
-
dy
,
dx
);
box
.
size
.
width
=
(
float
)
sqrt
(
dx
*
dx
+
dy
*
dy
);
box
.
size
.
height
=
0
;
box
.
angle
=
(
float
)
atan2
(
dy
,
dx
);
}
else
{
...
...
modules/video/src/camshift.cpp
View file @
a937d9d4
...
...
@@ -275,7 +275,13 @@ cvCamShift( const void* imgProb, CvRect windowIn,
{
box
->
size
.
height
=
(
float
)
length
;
box
->
size
.
width
=
(
float
)
width
;
box
->
angle
=
(
float
)(
theta
*
180.
/
CV_PI
);
box
->
angle
=
(
float
)((
CV_PI
*
0.5
+
theta
)
*
180.
/
CV_PI
);
while
(
box
->
angle
<
0
)
box
->
angle
+=
360
;
while
(
box
->
angle
>=
360
)
box
->
angle
-=
360
;
if
(
box
->
angle
>=
180
)
box
->
angle
-=
180
;
box
->
center
=
cvPoint2D32f
(
comp
.
rect
.
x
+
comp
.
rect
.
width
*
0.5
f
,
comp
.
rect
.
y
+
comp
.
rect
.
height
*
0.5
f
);
}
...
...
samples/cpp/camshiftdemo.cpp
View file @
a937d9d4
...
...
@@ -130,7 +130,6 @@ int main( int argc, char** argv )
backproj
&=
mask
;
RotatedRect
trackBox
=
CamShift
(
backproj
,
trackWindow
,
TermCriteria
(
CV_TERMCRIT_EPS
|
CV_TERMCRIT_ITER
,
10
,
1
));
trackBox
.
angle
=
90
-
trackBox
.
angle
;
if
(
backprojMode
)
cvtColor
(
backproj
,
image
,
CV_GRAY2BGR
);
...
...
samples/cpp/fitellipse.cpp
View file @
a937d9d4
...
...
@@ -71,12 +71,16 @@ void processImage(int h, void*)
Mat
(
contours
[
i
]).
convertTo
(
pointsf
,
CV_32F
);
RotatedRect
box
=
fitEllipse
(
pointsf
);
box
.
angle
=
-
box
.
angle
;
if
(
MAX
(
box
.
size
.
width
,
box
.
size
.
height
)
>
MIN
(
box
.
size
.
width
,
box
.
size
.
height
)
*
30
)
continue
;
drawContours
(
cimage
,
contours
,
(
int
)
i
,
Scalar
::
all
(
255
),
1
,
8
);
ellipse
(
cimage
,
box
,
Scalar
(
0
,
0
,
255
),
1
,
CV_AA
);
ellipse
(
cimage
,
box
.
center
,
box
.
size
*
0.5
f
,
box
.
angle
,
0
,
360
,
Scalar
(
0
,
255
,
255
),
1
,
CV_AA
);
Point2f
vtx
[
4
];
box
.
points
(
vtx
);
for
(
int
j
=
0
;
j
<
4
;
j
++
)
line
(
cimage
,
vtx
[
j
],
vtx
[(
j
+
1
)
%
4
],
Scalar
(
0
,
255
,
0
),
1
,
CV_AA
);
}
imshow
(
"result"
,
cimage
);
...
...
tests/cv/src/acamshift.cpp
View file @
a937d9d4
...
...
@@ -134,7 +134,7 @@ void CV_TrackBaseTest::generate_object()
double
width
=
box0
.
size
.
width
*
0.5
;
double
height
=
box0
.
size
.
height
*
0.5
;
double
angle
=
box0
.
angle
*
CV_PI
/
180.
;
double
a
=
cos
(
angle
),
b
=
sin
(
angle
);
double
a
=
sin
(
angle
),
b
=
-
cos
(
angle
);
double
inv_ww
=
1.
/
(
width
*
width
),
inv_hh
=
1.
/
(
height
*
height
);
img
=
cvCreateMat
(
img_size
.
height
,
img_size
.
width
,
img_type
);
...
...
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