Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
5c2dfcd4
Commit
5c2dfcd4
authored
Aug 01, 2017
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plot: make the module more customizable
parent
2a9d1b22
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
28 deletions
+71
-28
plot.hpp
modules/plot/include/opencv2/plot.hpp
+25
-15
plot.cpp
modules/plot/src/plot.cpp
+45
-12
benchmark.cpp
modules/tracking/samples/benchmark.cpp
+1
-1
No files found.
modules/plot/include/opencv2/plot.hpp
View file @
5c2dfcd4
...
...
@@ -84,23 +84,33 @@ namespace cv
CV_WRAP
virtual
void
setPlotGridColor
(
Scalar
_plotGridColor
)
=
0
;
CV_WRAP
virtual
void
setPlotTextColor
(
Scalar
_plotTextColor
)
=
0
;
CV_WRAP
virtual
void
setPlotSize
(
int
_plotSizeWidth
,
int
_plotSizeHeight
)
=
0
;
CV_WRAP
virtual
void
setShowGrid
(
bool
needShowGrid
)
=
0
;
CV_WRAP
virtual
void
setShowText
(
bool
needShowText
)
=
0
;
CV_WRAP
virtual
void
setGridLinesNumber
(
int
gridLinesNumber
)
=
0
;
/**
* @brief Sets the index of a point which coordinates will be printed on the top left corner of the plot (if ShowText flag is true).
*
* @param pointIdx index of the required point in data array.
*/
CV_WRAP
virtual
void
setPointIdxToPrint
(
int
pointIdx
)
=
0
;
CV_WRAP
virtual
void
render
(
OutputArray
_plotResult
)
=
0
;
};
/**
* @brief Creates Plot2d object
*
* @param data \f$1xN\f$ or \f$Nx1\f$ matrix containing \f$Y\f$ values of points to plot. \f$X\f$ values
* will be equal to indexes of correspondind elements in data matrix.
*/
CV_EXPORTS_W
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
data
);
/**
* @brief Creates Plot2d object
*
* @param dataX \f$1xN\f$ or \f$Nx1\f$ matrix \f$X\f$ values of points to plot.
* @param dataY \f$1xN\f$ or \f$Nx1\f$ matrix containing \f$Y\f$ values of points to plot.
*/
CV_EXPORTS_W
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
dataX
,
InputArray
dataY
);
/**
* @brief Creates Plot2d object
*
* @param data \f$1xN\f$ or \f$Nx1\f$ matrix containing \f$Y\f$ values of points to plot. \f$X\f$ values
* will be equal to indexes of correspondind elements in data matrix.
*/
CV_WRAP
static
Ptr
<
Plot2d
>
create
(
InputArray
data
);
/**
* @brief Creates Plot2d object
*
* @param dataX \f$1xN\f$ or \f$Nx1\f$ matrix \f$X\f$ values of points to plot.
* @param dataY \f$1xN\f$ or \f$Nx1\f$ matrix containing \f$Y\f$ values of points to plot.
*/
CV_WRAP
static
Ptr
<
Plot2d
>
create
(
InputArray
dataX
,
InputArray
dataY
);
};
//! @}
}
}
...
...
modules/plot/src/plot.cpp
View file @
5c2dfcd4
...
...
@@ -168,7 +168,26 @@ namespace cv
else
plotSizeHeight
=
300
;
}
void
setShowGrid
(
bool
_needShowGrid
)
{
needShowGrid
=
_needShowGrid
;
}
void
setShowText
(
bool
_needShowText
)
{
needShowText
=
_needShowText
;
}
void
setGridLinesNumber
(
int
_gridLinesNumber
)
{
if
(
_gridLinesNumber
<=
0
)
_gridLinesNumber
=
1
;
gridLinesNumber
=
_gridLinesNumber
;
}
void
setPointIdxToPrint
(
int
_cursorPos
)
{
if
(
_cursorPos
>=
plotDataX
.
rows
||
_cursorPos
<
0
)
_cursorPos
=
plotDataX
.
rows
-
1
;
cursorPos
=
_cursorPos
;
}
//render the plotResult to a Mat
void
render
(
OutputArray
_plotResult
)
{
...
...
@@ -189,8 +208,8 @@ namespace cv
int
ImageXzero
=
(
int
)
InterpXdataFindZero
.
at
<
double
>
(
NumVecElements
,
0
);
int
ImageYzero
=
(
int
)
InterpYdataFindZero
.
at
<
double
>
(
NumVecElements
,
0
);
double
CurrentX
=
plotDataX
.
at
<
double
>
(
NumVecElements
-
1
,
0
);
double
CurrentY
=
plotDataY
.
at
<
double
>
(
NumVecElements
-
1
,
0
);
double
CurrentX
=
plotDataX
.
at
<
double
>
(
cursorPos
,
0
);
double
CurrentY
=
plotDataY
.
at
<
double
>
(
cursorPos
,
0
);
drawAxis
(
ImageXzero
,
ImageYzero
,
CurrentX
,
CurrentY
,
plotAxisColor
,
plotGridColor
);
...
...
@@ -245,6 +264,10 @@ namespace cv
double
plotMinY_plusZero
;
double
plotMaxY_plusZero
;
int
plotLineWidth
;
bool
needShowGrid
;
bool
needShowText
;
int
gridLinesNumber
;
int
cursorPos
;
//colors of each plot element
Scalar
plotLineColor
;
...
...
@@ -319,22 +342,30 @@ namespace cv
setPlotBackgroundColor
(
Scalar
(
0
,
0
,
0
));
setPlotLineColor
(
Scalar
(
0
,
255
,
255
));
setPlotTextColor
(
Scalar
(
255
,
255
,
255
));
setShowGrid
(
true
);
setShowText
(
true
);
setGridLinesNumber
(
10
);
setPointIdxToPrint
(
-
1
);
}
void
drawAxis
(
int
ImageXzero
,
int
ImageYzero
,
double
CurrentX
,
double
CurrentY
,
Scalar
axisColor
,
Scalar
gridColor
)
{
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
10
,
20
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
-
20
,
20
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
10
,
-
10
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
-
20
,
-
10
);
drawValuesAsText
(
"X = %g"
,
CurrentX
,
0
,
0
,
40
,
20
);
drawValuesAsText
(
"Y = %g"
,
CurrentY
,
0
,
20
,
40
,
20
);
if
(
needShowText
)
{
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
10
,
20
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
-
20
,
20
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
10
,
-
10
);
drawValuesAsText
(
0
,
ImageXzero
,
ImageYzero
,
-
20
,
-
10
);
drawValuesAsText
((
format
(
"X_%d = "
,
cursorPos
)
+
"%g"
).
c_str
(),
CurrentX
,
0
,
0
,
40
,
20
);
drawValuesAsText
((
format
(
"Y_%d = "
,
cursorPos
)
+
"%g"
).
c_str
(),
CurrentY
,
0
,
20
,
40
,
20
);
}
//Horizontal X axis and equispaced horizontal lines
int
LineSpace
=
50
;
int
LineSpace
=
cvRound
(
plotSizeHeight
/
(
float
)
gridLinesNumber
)
;
int
TraceSize
=
5
;
drawLine
(
0
,
plotSizeWidth
,
ImageYzero
,
ImageYzero
,
axisColor
);
if
(
needShowGrid
)
for
(
int
i
=-
plotSizeHeight
;
i
<
plotSizeHeight
;
i
=
i
+
LineSpace
){
if
(
i
!=
0
){
...
...
@@ -349,7 +380,9 @@ namespace cv
//Vertical Y axis
drawLine
(
ImageXzero
,
ImageXzero
,
0
,
plotSizeHeight
,
axisColor
);
LineSpace
=
cvRound
(
LineSpace
*
(
float
)
plotSizeWidth
/
plotSizeHeight
);
if
(
needShowGrid
)
for
(
int
i
=-
plotSizeWidth
;
i
<
plotSizeWidth
;
i
=
i
+
LineSpace
){
if
(
i
!=
0
){
...
...
@@ -420,13 +453,13 @@ namespace cv
};
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
_plotData
)
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotData
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotData
));
}
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
_plotDataX
,
InputArray
_plotDataY
)
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotDataX
,
InputArray
_plotDataY
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotDataX
,
_plotDataY
));
}
...
...
modules/tracking/samples/benchmark.cpp
View file @
5c2dfcd4
...
...
@@ -165,7 +165,7 @@ struct AlgoWrap
void
plotLTRC
(
Mat
&
img
)
const
{
Ptr
<
plot
::
Plot2d
>
p_
=
plot
::
createPlot2d
(
getLTRC
());
Ptr
<
plot
::
Plot2d
>
p_
=
plot
::
Plot2d
::
create
(
getLTRC
());
p_
->
render
(
img
);
}
...
...
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