1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-19 02:16:34 +08:00

Created nested namespace 'plot' inside namespace 'cv'. Removed methods 'show' and 'save'. Removed highgui dependency.

This commit is contained in:
nmoutinho
2015-03-16 11:35:35 +00:00
parent 827fc10cc0
commit cad6cbcde2
4 changed files with 35 additions and 106 deletions

View File

@@ -50,11 +50,10 @@
#ifdef __cplusplus #ifdef __cplusplus
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <vector>
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <vector>
/** /**
@defgroup plot Plot function for Mat data @defgroup plot Plot function for Mat data
@@ -62,13 +61,16 @@
namespace cv namespace cv
{ {
namespace plot
{
class CV_EXPORTS Plot class CV_EXPORTS Plot
{ {
protected: protected:
cv::Mat plotDataX; Mat plotDataX;
cv::Mat plotDataY; Mat plotDataY;
cv::Mat plotDataX_plusZero; Mat plotDataX_plusZero;
cv::Mat plotDataY_plusZero; Mat plotDataY_plusZero;
const char * plotName; const char * plotName;
//dimensions and limits of the plot //dimensions and limits of the plot
@@ -85,19 +87,19 @@ namespace cv
int plotLineWidth; int plotLineWidth;
//colors of each plot element //colors of each plot element
cv::Scalar plotLineColor; Scalar plotLineColor;
cv::Scalar plotBackgroundColor; Scalar plotBackgroundColor;
cv::Scalar plotAxisColor; Scalar plotAxisColor;
cv::Scalar plotGridColor; Scalar plotGridColor;
cv::Scalar plotTextColor; Scalar plotTextColor;
//the final plot result //the final plot result
cv::Mat plotResult; Mat plotResult;
public: public:
//constructor accepting only Y data to be plotted //constructor accepting only Y data to be plotted
Plot(cv::Mat _plotData) Plot(Mat _plotData)
{ {
//if the matrix is not Nx1 or 1xN //if the matrix is not Nx1 or 1xN
if(_plotData.cols > 1 && _plotData.rows > 1) if(_plotData.cols > 1 && _plotData.rows > 1)
@@ -131,7 +133,7 @@ namespace cv
} }
//constructor accepting X data and Y data to be plotted //constructor accepting X data and Y data to be plotted
Plot(cv::Mat _plotDataX, cv::Mat _plotDataY) Plot(Mat _plotDataX, Mat _plotDataY)
{ {
//f the matrix is not Nx1 or 1xN //f the matrix is not Nx1 or 1xN
if((_plotDataX.cols > 1 && _plotDataX.rows > 1) || (_plotDataY.cols > 1 && _plotDataY.rows > 1)) if((_plotDataX.cols > 1 && _plotDataX.rows > 1) || (_plotDataY.cols > 1 && _plotDataY.rows > 1))
@@ -185,23 +187,23 @@ namespace cv
{ {
plotLineWidth=_plotLineWidth; plotLineWidth=_plotLineWidth;
} }
void setPlotLineColor(cv::Scalar _plotLineColor) void setPlotLineColor(Scalar _plotLineColor)
{ {
plotLineColor=_plotLineColor; plotLineColor=_plotLineColor;
} }
void setPlotBackgroundColor(cv::Scalar _plotBackgroundColor) void setPlotBackgroundColor(Scalar _plotBackgroundColor)
{ {
plotBackgroundColor=_plotBackgroundColor; plotBackgroundColor=_plotBackgroundColor;
} }
void setPlotAxisColor(cv::Scalar _plotAxisColor) void setPlotAxisColor(Scalar _plotAxisColor)
{ {
plotAxisColor=_plotAxisColor; plotAxisColor=_plotAxisColor;
} }
void setPlotGridColor(cv::Scalar _plotGridColor) void setPlotGridColor(Scalar _plotGridColor)
{ {
plotGridColor=_plotGridColor; plotGridColor=_plotGridColor;
} }
void setPlotTextColor(cv::Scalar _plotTextColor) void setPlotTextColor(Scalar _plotTextColor)
{ {
plotTextColor=_plotTextColor; plotTextColor=_plotTextColor;
} }
@@ -219,26 +221,20 @@ namespace cv
} }
//render the plotResult to a Mat //render the plotResult to a Mat
void render(cv::Mat &_plotResult); void render(Mat &_plotResult);
//show the plotResult from within the class
void show(const char * _plotName);
//save the plotResult as a .png image
void save(const char * _plotFileName);
protected: protected:
//a helper method to be used in the constructor //a helper method to be used in the constructor
void plotHelper(cv::Mat _plotDataX, cv::Mat _plotDataY) void plotHelper(Mat _plotDataX, Mat _plotDataY)
{ {
plotDataX=_plotDataX; plotDataX=_plotDataX;
plotDataY=_plotDataY; plotDataY=_plotDataY;
int NumVecElements = plotDataX.rows; int NumVecElements = plotDataX.rows;
plotDataX_plusZero = cv::Mat::zeros(NumVecElements+1,1,CV_64F); plotDataX_plusZero = Mat::zeros(NumVecElements+1,1,CV_64F);
plotDataY_plusZero = cv::Mat::zeros(NumVecElements+1,1,CV_64F); plotDataY_plusZero = Mat::zeros(NumVecElements+1,1,CV_64F);
for(int i=0; i<NumVecElements; i++){ for(int i=0; i<NumVecElements; i++){
plotDataX_plusZero.at<double>(i,0) = plotDataX.at<double>(i,0); plotDataX_plusZero.at<double>(i,0) = plotDataX.at<double>(i,0);
@@ -283,20 +279,21 @@ namespace cv
setPlotLineWidth(1); setPlotLineWidth(1);
//setting default colors for the different elements of the plot //setting default colors for the different elements of the plot
setPlotAxisColor(cv::Scalar(0, 0, 255)); setPlotAxisColor(Scalar(0, 0, 255));
setPlotGridColor(cv::Scalar(255, 255, 255)); setPlotGridColor(Scalar(255, 255, 255));
setPlotBackgroundColor(cv::Scalar(0, 0, 0)); setPlotBackgroundColor(Scalar(0, 0, 0));
setPlotLineColor(cv::Scalar(0, 255, 255)); setPlotLineColor(Scalar(0, 255, 255));
setPlotTextColor(cv::Scalar(255, 255, 255)); setPlotTextColor(Scalar(255, 255, 255));
} }
cv::Mat linearInterpolation(double Xa, double Xb, double Ya, double Yb, cv::Mat Xdata); Mat linearInterpolation(double Xa, double Xb, double Ya, double Yb, Mat Xdata);
void drawAxis(int ImageXzero, int ImageYzero, double CurrentX, double CurrentY, cv::Scalar axisColor, cv::Scalar gridColor); void drawAxis(int ImageXzero, int ImageYzero, double CurrentX, double CurrentY, Scalar axisColor, Scalar gridColor);
void drawValuesAsText(double Value, int Xloc, int Yloc, int XMargin, int YMargin); void drawValuesAsText(double Value, int Xloc, int Yloc, int XMargin, int YMargin);
void drawValuesAsText(const char * Text, double Value, int Xloc, int Yloc, int XMargin, int YMargin); void drawValuesAsText(const char * Text, double Value, int Xloc, int Yloc, int XMargin, int YMargin);
void drawLine(int Xstart, int Xend, int Ystart, int Yend, cv::Scalar lineColor); void drawLine(int Xstart, int Xend, int Ystart, int Yend, Scalar lineColor);
}; };
} }
}
#endif #endif
#endif #endif

View File

@@ -1,53 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
//################################################################################
//
// Created by Nuno Moutinho
//
//################################################################################
#ifdef __OPENCV_BUILD
#error this is a compatibility header which should not be used inside the OpenCV library
#endif
#include "opencv2/plot.hpp"

View File

@@ -47,7 +47,7 @@
#include "precomp.hpp" #include "precomp.hpp"
using namespace cv; using namespace cv::plot;
using namespace std; using namespace std;
//render the plotResult to a Mat //render the plotResult to a Mat
@@ -94,20 +94,6 @@ void Plot::render(cv::Mat &_plotResult){
} }
//show the plotResult from within the class
void Plot::show(const char * _plotName)
{
namedWindow(_plotName);
imshow(_plotName, plotResult);
waitKey(5);
}
//save the plotResult as a .png image
void Plot::save(const char * _plotFileName)
{
imwrite(_plotFileName, plotResult);
}
void Plot::drawAxis(int ImageXzero, int ImageYzero, double CurrentX, double CurrentY, Scalar axisColor, Scalar gridColor){ void Plot::drawAxis(int ImageXzero, int ImageYzero, double CurrentX, double CurrentY, Scalar axisColor, Scalar gridColor){
drawValuesAsText(0, ImageXzero, ImageYzero, 10, 20); drawValuesAsText(0, ImageXzero, ImageYzero, 10, 20);

View File

@@ -49,7 +49,6 @@
#define __OPENCV_PRECOMP_H__ #define __OPENCV_PRECOMP_H__
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <vector> #include <vector>