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
3496ed59
Commit
3496ed59
authored
Sep 19, 2017
by
Suleyman TURKMEN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update plot module
parent
b9541897
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
27 deletions
+31
-27
plot.hpp
modules/plot/include/opencv2/plot.hpp
+3
-4
plot_demo.cpp
modules/plot/samples/plot_demo.cpp
+16
-10
plot.cpp
modules/plot/src/plot.cpp
+12
-13
No files found.
modules/plot/include/opencv2/plot.hpp
View file @
3496ed59
...
...
@@ -87,6 +87,7 @@ namespace cv
CV_WRAP
virtual
void
setShowGrid
(
bool
needShowGrid
)
=
0
;
CV_WRAP
virtual
void
setShowText
(
bool
needShowText
)
=
0
;
CV_WRAP
virtual
void
setGridLinesNumber
(
int
gridLinesNumber
)
=
0
;
CV_WRAP
virtual
void
setInvertOrientation
(
bool
_invertOrientation
)
=
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).
*
...
...
@@ -99,19 +100,17 @@ namespace cv
* @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
* @param _invertOrientation true means the y axis is inverted
* will be equal to indexes of correspondind elements in data matrix.
*/
CV_WRAP
static
Ptr
<
Plot2d
>
create
(
InputArray
data
,
bool
_invertOrientation
=
false
);
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.
* @param _invertOrientation true means the y axis is inverted
*/
CV_WRAP
static
Ptr
<
Plot2d
>
create
(
InputArray
dataX
,
InputArray
dataY
,
bool
_invertOrientation
=
false
);
CV_WRAP
static
Ptr
<
Plot2d
>
create
(
InputArray
dataX
,
InputArray
dataY
);
};
//! @}
}
...
...
modules/plot/samples/plot_demo.cpp
View file @
3496ed59
...
...
@@ -6,13 +6,14 @@ using namespace cv;
int
main
()
{
Mat
data_x
(
1
,
50
,
CV_64F
);
Mat
data_y
(
1
,
50
,
CV_64F
);
Mat
data_x
(
1
,
51
,
CV_64F
);
Mat
data_y
(
1
,
51
,
CV_64F
);
for
(
int
i
=
0
;
i
<
50
;
i
++
)
for
(
int
i
=
0
;
i
<
data_x
.
cols
;
i
++
)
{
data_x
.
at
<
double
>
(
0
,
i
)
=
(
i
-
25
);
data_y
.
at
<
double
>
(
0
,
i
)
=
(
i
-
25
)
*
(
i
-
25
)
*
(
i
-
25
);
double
x
=
(
i
-
data_x
.
cols
/
2
);
data_x
.
at
<
double
>
(
0
,
i
)
=
x
;
data_y
.
at
<
double
>
(
0
,
i
)
=
x
*
x
*
x
;
}
std
::
cout
<<
"data_x : "
<<
data_x
<<
std
::
endl
;
...
...
@@ -20,15 +21,20 @@ int main()
Mat
plot_result
;
Ptr
<
plot
::
Plot2d
>
plot
=
plot
::
Plot2d
::
create
(
data_x
,
data_y
);
Ptr
<
plot
::
Plot2d
>
plot
=
plot
::
Plot2d
::
create
(
data_x
,
data_y
);
plot
->
render
(
plot_result
);
imshow
(
"default orientation"
,
plot_result
);
imshow
(
"The plot rendered with default visualization options"
,
plot_result
);
plot
=
plot
::
Plot2d
::
create
(
data_x
,
data_y
,
true
);
plot
->
render
(
plot_result
);
plot
->
setShowText
(
false
);
plot
->
setShowGrid
(
false
);
plot
->
setPlotBackgroundColor
(
Scalar
(
255
,
200
,
200
)
);
plot
->
setPlotLineColor
(
Scalar
(
255
,
0
,
0
)
);
plot
->
setPlotLineWidth
(
2
);
plot
->
setInvertOrientation
(
true
);
plot
->
render
(
plot_result
);
imshow
(
"inverted orientation"
,
plot_result
);
imshow
(
"The plot rendered with some of custom visualization options"
,
plot_result
);
waitKey
();
return
0
;
...
...
modules/plot/src/plot.cpp
View file @
3496ed59
...
...
@@ -57,9 +57,8 @@ namespace cv
{
public
:
Plot2dImpl
(
InputArray
plotData
,
bool
_invertOrientation
)
Plot2dImpl
(
InputArray
plotData
)
{
invertOrientation
=
_invertOrientation
;
Mat
_plotData
=
plotData
.
getMat
();
//if the matrix is not Nx1 or 1xN
if
(
_plotData
.
cols
>
1
&&
_plotData
.
rows
>
1
)
...
...
@@ -85,9 +84,8 @@ namespace cv
}
Plot2dImpl
(
InputArray
plotDataX_
,
InputArray
plotDataY_
,
bool
_invertOrientation
)
Plot2dImpl
(
InputArray
plotDataX_
,
InputArray
plotDataY_
)
{
invertOrientation
=
_invertOrientation
;
Mat
_plotDataX
=
plotDataX_
.
getMat
();
Mat
_plotDataY
=
plotDataY_
.
getMat
();
//f the matrix is not Nx1 or 1xN
...
...
@@ -134,6 +132,10 @@ namespace cv
{
plotLineWidth
=
_plotLineWidth
;
}
void
setInvertOrientation
(
bool
_invertOrientation
)
{
invertOrientation
=
_invertOrientation
;
}
void
setNeedPlotLine
(
bool
_needPlotLine
)
{
needPlotLine
=
_needPlotLine
;
...
...
@@ -270,7 +272,7 @@ namespace cv
double
plotMinY_plusZero
;
double
plotMaxY_plusZero
;
int
plotLineWidth
;
bool
invertOrientation
;
bool
invertOrientation
;
bool
needShowGrid
;
bool
needShowText
;
int
gridLinesNumber
;
...
...
@@ -314,6 +316,7 @@ namespace cv
double
MaxY_plusZero
;
needPlotLine
=
true
;
invertOrientation
=
false
;
//Obtain the minimum and maximum values of Xdata
minMaxLoc
(
plotDataX
,
&
MinX
,
&
MaxX
);
...
...
@@ -384,7 +387,6 @@ namespace cv
}
}
//Vertical Y axis
drawLine
(
ImageXzero
,
ImageXzero
,
0
,
plotSizeHeight
,
axisColor
);
LineSpace
=
cvRound
(
LineSpace
*
(
float
)
plotSizeWidth
/
plotSizeHeight
);
...
...
@@ -413,7 +415,6 @@ namespace cv
if
(
Ydata
.
at
<
double
>
(
i
,
0
)
<
0
)
Ydata
.
at
<
double
>
(
i
,
0
)
=
0
;
}
return
Ydata
;
...
...
@@ -457,18 +458,16 @@ namespace cv
line
(
plotResult
,
Axis_start
,
Axis_end
,
lineColor
,
plotLineWidth
,
8
,
0
);
}
};
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotData
,
bool
_invertOrientation
)
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotData
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotData
,
_invertOrientation
));
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotData
));
}
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotDataX
,
InputArray
_plotDataY
,
bool
_invertOrientation
)
Ptr
<
Plot2d
>
Plot2d
::
create
(
InputArray
_plotDataX
,
InputArray
_plotDataY
)
{
return
Ptr
<
Plot2dImpl
>
(
new
Plot2dImpl
(
_plotDataX
,
_plotDataY
,
_invertOrientation
));
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