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
9ed1d7e6
Commit
9ed1d7e6
authored
Sep 29, 2016
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #787 from sovrasov:plot_update
parents
aa5281c1
b6369772
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
24 deletions
+62
-24
CMakeLists.txt
modules/plot/CMakeLists.txt
+1
-1
plot.hpp
modules/plot/include/opencv2/plot.hpp
+16
-3
plot.cpp
modules/plot/src/plot.cpp
+45
-20
No files found.
modules/plot/CMakeLists.txt
View file @
9ed1d7e6
set
(
the_description
"Plot function for Mat data."
)
ocv_define_module
(
plot opencv_core opencv_highgui
)
ocv_define_module
(
plot opencv_core opencv_highgui
WRAP python
)
modules/plot/include/opencv2/plot.hpp
View file @
9ed1d7e6
...
...
@@ -68,17 +68,30 @@ namespace cv
CV_WRAP
virtual
void
setMaxX
(
double
_plotMaxX
)
=
0
;
CV_WRAP
virtual
void
setMaxY
(
double
_plotMaxY
)
=
0
;
CV_WRAP
virtual
void
setPlotLineWidth
(
int
_plotLineWidth
)
=
0
;
CV_WRAP
virtual
void
setNeedPlotLine
(
bool
_needPlotLine
)
=
0
;
CV_WRAP
virtual
void
setPlotLineColor
(
Scalar
_plotLineColor
)
=
0
;
CV_WRAP
virtual
void
setPlotBackgroundColor
(
Scalar
_plotBackgroundColor
)
=
0
;
CV_WRAP
virtual
void
setPlotAxisColor
(
Scalar
_plotAxisColor
)
=
0
;
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
render
(
Mat
&
_plotResult
)
=
0
;
CV_WRAP
virtual
void
render
(
OutputArray
_plotResult
)
=
0
;
};
CV_EXPORTS_W
Ptr
<
Plot2d
>
createPlot2d
(
Mat
data
);
CV_EXPORTS_W
Ptr
<
Plot2d
>
createPlot2d
(
Mat
dataX
,
Mat
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_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
);
}
}
...
...
modules/plot/src/plot.cpp
View file @
9ed1d7e6
...
...
@@ -57,8 +57,9 @@ namespace cv
{
public
:
Plot2dImpl
(
Mat
_
plotData
)
Plot2dImpl
(
InputArray
plotData
)
{
Mat
_plotData
=
plotData
.
getMat
();
//if the matrix is not Nx1 or 1xN
if
(
_plotData
.
cols
>
1
&&
_plotData
.
rows
>
1
)
{
...
...
@@ -91,8 +92,10 @@ namespace cv
}
Plot2dImpl
(
Mat
_plotDataX
,
Mat
_plotDataY
)
Plot2dImpl
(
InputArray
plotDataX_
,
InputArray
plotDataY_
)
{
Mat
_plotDataX
=
plotDataX_
.
getMat
();
Mat
_plotDataY
=
plotDataY_
.
getMat
();
//f the matrix is not Nx1 or 1xN
if
((
_plotDataX
.
cols
>
1
&&
_plotDataX
.
rows
>
1
)
||
(
_plotDataY
.
cols
>
1
&&
_plotDataY
.
rows
>
1
))
{
...
...
@@ -143,7 +146,11 @@ namespace cv
}
void
setPlotLineWidth
(
int
_plotLineWidth
)
{
plotLineWidth
=
_plotLineWidth
;
plotLineWidth
=
_plotLineWidth
;
}
void
setNeedPlotLine
(
bool
_needPlotLine
)
{
needPlotLine
=
_needPlotLine
;
}
void
setPlotLineColor
(
Scalar
_plotLineColor
)
{
...
...
@@ -179,10 +186,12 @@ namespace cv
}
//render the plotResult to a Mat
void
render
(
Mat
&
_plotResult
)
void
render
(
OutputArray
_plotResult
)
{
//create the plot result
plotResult
=
Mat
(
plotSizeHeight
,
plotSizeWidth
,
CV_8UC3
,
plotBackgroundColor
);
_plotResult
.
create
(
plotSizeHeight
,
plotSizeWidth
,
CV_8UC3
);
plotResult
=
_plotResult
.
getMat
();
plotResult
.
setTo
(
plotBackgroundColor
);
int
NumVecElements
=
plotDataX
.
rows
;
...
...
@@ -199,26 +208,37 @@ namespace cv
double
CurrentX
=
plotDataX
.
at
<
double
>
(
NumVecElements
-
1
,
0
);
double
CurrentY
=
plotDataY
.
at
<
double
>
(
NumVecElements
-
1
,
0
);
//Draw the plot by connecting lines between the points
Point
p1
;
p1
.
x
=
(
int
)
InterpXdata
.
at
<
double
>
(
0
,
0
);
p1
.
y
=
(
int
)
InterpYdata
.
at
<
double
>
(
0
,
0
);
drawAxis
(
ImageXzero
,
ImageYzero
,
CurrentX
,
CurrentY
,
plotAxisColor
,
plotGridColor
);
for
(
int
r
=
1
;
r
<
InterpXdata
.
rows
;
r
++
){
Point
p2
;
p2
.
x
=
(
int
)
InterpXdata
.
at
<
double
>
(
r
,
0
);
p2
.
y
=
(
int
)
InterpYdata
.
at
<
double
>
(
r
,
0
);
if
(
needPlotLine
)
{
//Draw the plot by connecting lines between the points
Point
p1
;
p1
.
x
=
(
int
)
InterpXdata
.
at
<
double
>
(
0
,
0
);
p1
.
y
=
(
int
)
InterpYdata
.
at
<
double
>
(
0
,
0
);
line
(
plotResult
,
p1
,
p2
,
plotLineColor
,
plotLineWidth
,
8
,
0
);
for
(
int
r
=
1
;
r
<
InterpXdata
.
rows
;
r
++
)
{
Point
p2
;
p2
.
x
=
(
int
)
InterpXdata
.
at
<
double
>
(
r
,
0
);
p2
.
y
=
(
int
)
InterpYdata
.
at
<
double
>
(
r
,
0
);
p1
=
p2
;
line
(
plotResult
,
p1
,
p2
,
plotLineColor
,
plotLineWidth
,
8
,
0
)
;
p1
=
p2
;
}
}
else
{
for
(
int
r
=
0
;
r
<
InterpXdata
.
rows
;
r
++
)
{
Point
p
;
p
.
x
=
(
int
)
InterpXdata
.
at
<
double
>
(
r
,
0
);
p
.
y
=
(
int
)
InterpYdata
.
at
<
double
>
(
r
,
0
);
_plotResult
=
plotResult
.
clone
();
circle
(
plotResult
,
p
,
1
,
plotLineColor
,
plotLineWidth
,
8
,
0
);
}
}
}
protected
:
...
...
@@ -252,6 +272,9 @@ namespace cv
//the final plot result
Mat
plotResult
;
//flag which enables/disables connection of plotted points by lines
bool
needPlotLine
;
void
plotHelper
(
Mat
_plotDataX
,
Mat
_plotDataY
)
{
plotDataX
=
_plotDataX
;
...
...
@@ -276,6 +299,8 @@ namespace cv
double
MinY_plusZero
;
double
MaxY_plusZero
;
needPlotLine
=
true
;
//Obtain the minimum and maximum values of Xdata
minMaxLoc
(
plotDataX
,
&
MinX
,
&
MaxX
);
...
...
@@ -411,13 +436,13 @@ namespace cv
};
Ptr
<
Plot2d
>
createPlot2d
(
Mat
_plotData
)
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
_plotData
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotData
));
}
Ptr
<
Plot2d
>
createPlot2d
(
Mat
_plotDataX
,
Mat
_plotDataY
)
Ptr
<
Plot2d
>
createPlot2d
(
InputArray
_plotDataX
,
InputArray
_plotDataY
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotDataX
,
_plotDataY
));
}
...
...
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