@@ -57,8 +57,9 @@ namespace cv
57
57
{
58
58
public:
59
59
60
- Plot2dImpl (InputArray plotData)
60
+ Plot2dImpl (InputArray plotData, bool _invertOrientation )
61
61
{
62
+ invertOrientation = _invertOrientation;
62
63
Mat _plotData = plotData.getMat ();
63
64
// if the matrix is not Nx1 or 1xN
64
65
if (_plotData.cols > 1 && _plotData.rows > 1 )
@@ -84,8 +85,9 @@ namespace cv
84
85
85
86
}
86
87
87
- Plot2dImpl (InputArray plotDataX_, InputArray plotDataY_)
88
+ Plot2dImpl (InputArray plotDataX_, InputArray plotDataY_, bool _invertOrientation )
88
89
{
90
+ invertOrientation = _invertOrientation;
89
91
Mat _plotDataX = plotDataX_.getMat ();
90
92
Mat _plotDataY = plotDataY_.getMat ();
91
93
// f the matrix is not Nx1 or 1xN
@@ -199,11 +201,15 @@ namespace cv
199
201
int NumVecElements = plotDataX.rows ;
200
202
201
203
Mat InterpXdata = linearInterpolation (plotMinX, plotMaxX, 0 , plotSizeWidth, plotDataX);
202
- Mat InterpYdata = linearInterpolation (plotMinY, plotMaxY, 0 , plotSizeHeight, plotDataY);
204
+ Mat InterpYdata = invertOrientation ?
205
+ linearInterpolation (plotMaxY, plotMinY, 0 , plotSizeHeight, plotDataY) :
206
+ linearInterpolation (plotMinY, plotMaxY, 0 , plotSizeHeight, plotDataY);
203
207
204
208
// Find the zeros in image coordinates
205
209
Mat InterpXdataFindZero = linearInterpolation (plotMinX_plusZero, plotMaxX_plusZero, 0 , plotSizeWidth, plotDataX_plusZero);
206
- Mat InterpYdataFindZero = linearInterpolation (plotMinY_plusZero, plotMaxY_plusZero, 0 , plotSizeHeight, plotDataY_plusZero);
210
+ Mat InterpYdataFindZero = invertOrientation ?
211
+ linearInterpolation (plotMaxY_plusZero, plotMinY_plusZero, 0 , plotSizeHeight, plotDataY_plusZero) :
212
+ linearInterpolation (plotMinY_plusZero, plotMaxY_plusZero, 0 , plotSizeHeight, plotDataY_plusZero);
207
213
208
214
int ImageXzero = (int )InterpXdataFindZero.at <double >(NumVecElements,0 );
209
215
int ImageYzero = (int )InterpYdataFindZero.at <double >(NumVecElements,0 );
@@ -264,6 +270,7 @@ namespace cv
264
270
double plotMinY_plusZero;
265
271
double plotMaxY_plusZero;
266
272
int plotLineWidth;
273
+ bool invertOrientation;
267
274
bool needShowGrid;
268
275
bool needShowText;
269
276
int gridLinesNumber;
@@ -453,15 +460,15 @@ namespace cv
453
460
454
461
};
455
462
456
- Ptr<Plot2d> Plot2d::create (InputArray _plotData)
463
+ Ptr<Plot2d> Plot2d::create (InputArray _plotData, bool _invertOrientation )
457
464
{
458
- return Ptr<Plot2dImpl> (new Plot2dImpl (_plotData));
465
+ return Ptr<Plot2dImpl> (new Plot2dImpl (_plotData, _invertOrientation ));
459
466
460
467
}
461
468
462
- Ptr<Plot2d> Plot2d::create (InputArray _plotDataX, InputArray _plotDataY)
469
+ Ptr<Plot2d> Plot2d::create (InputArray _plotDataX, InputArray _plotDataY, bool _invertOrientation )
463
470
{
464
- return Ptr<Plot2dImpl> (new Plot2dImpl (_plotDataX, _plotDataY));
471
+ return Ptr<Plot2dImpl> (new Plot2dImpl (_plotDataX, _plotDataY, _invertOrientation ));
465
472
}
466
473
}
467
474
}
0 commit comments