Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ideas about improving plot module #1306

Open
sturkmen72 opened this issue Jul 31, 2017 · 3 comments
Open

ideas about improving plot module #1306

sturkmen72 opened this issue Jul 31, 2017 · 3 comments

Comments

@sturkmen72
Copy link
Contributor

sturkmen72 commented Jul 31, 2017

test code

#include <opencv2/highgui.hpp>
#include <opencv2/plot.hpp>
#include <iostream>

using namespace cv;

int main(int argc, char** argv)
{
	Mat data_x(1, 11, CV_64F);
	Mat data_y(1, 11, CV_64F);

	for (int i = 0; i < 11; i++)
	{
		data_x.at<double>(0, i) = i - 5;
		data_y.at<double>(0, i) = i - 5;
	}

	std::cout << "data_x : " << data_x << std::endl;
	std::cout << "data_y : " << data_y << std::endl;

	Mat plot_result0, plot_result1, plot_result2;

	Ptr<plot::Plot2d> plot = plot::createPlot2d(data_x, data_y);
	plot->render(plot_result0);
	plot->setPlotSize(500, 500);
	plot->render(plot_result1);

	//plot->setPlotAxisColor( Scalar(0, 0, 0) );
	plot->setPlotGridColor( Scalar(0, 0, 0) );
	plot->setPlotTextColor( Scalar(0, 0, 0) );
	plot->render(plot_result2);

	imshow("plot0", plot_result0);
	imshow("plot1", plot_result1);
	imshow("plot2", plot_result2);
	waitKey();

	return 0;
}

1

output plot0 (PlotSize is 600x400 default)

plot0

output plot1 (PlotSize is 500x500)
plot1

two graphs with same data and different size. i think there is a problem to be solved.

2

actually by setting PlotGridColor,PlotTextColor etc. you can do some customization on display like
plot2

probably adding some more functions to customization like setShowGrid(), setShowText() etc. will be fine

@catree
Copy link
Contributor

catree commented Aug 1, 2017

I never used this plot module but I use matplotlib. My suggestions would be to add the basic features of matplotlib:

  • legend, xlabel, ylabel, plot title
  • xrange, yrange (already exist with setMaxX, setMaxY, ...)
  • save figure
  • possibility to subplot
  • tick label
  • documentation + examples
  • 3D plot?

Example image:
image

Probably for nice plotting people will use dedicated tool (matplotlib, gnuplot, ...). The main purpose of this plot module should be for debugging in my opinion:

  • real time plotting: when the xrange and yrange are unknown, be able to adapt accordingly
  • save data in a text file to easily plot with another tool: in row, the data at time t, in column the data (xdata, ydata, ...)

Example code to import the data (here the text file is [x1,y1,z1], [x2,y2,z2], [x3,y3,z3], 3 curves, the zdata is not used):

import numpy as np
import matplotlib.pyplot as plt

data = np.loadtxt('pose_info.txt', skiprows=1)
fig = plt.figure()

for i in xrange(0, data.shape[1], 3):
  plt.plot(data[:,i], data[:,i+1])

plt.show()

Probably some features already exist.

@sturkmen72
Copy link
Contributor Author

img
i impressed @leonardvandriel's work and opened leovandriel/cvplot#1

i can try to help @leonardvandriel about contributing his framework to OpenCV if it will be useful. @vpisarev @alalek Could you share your opinion on this subject

@wpalfi
Copy link

wpalfi commented May 26, 2020

Related to #2414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants