Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing and Plotting graph in OpenCV

Tags:

opencv

Does OpenCV provide a function on how to draw and plot a graph?

I found this link by Shervin Emami http://www.shervinemami.info/graphs.html which was created by himself.

like image 994
Mzk Avatar asked Feb 12 '12 15:02

Mzk


2 Answers

No. It does not. There is a plot contrib module, but it is very basic.

You could try Profactor CvPlot https://github.com/Profactor/cv-plot. (I am the developer). It is very easy to integrate, purely opencv based and can be extended with custom controls. This is how you can plot to a cv::Mat or show a diagram with an interactive viewer:

#include <CvPlot/cvplot.h>
std::vector<double> x(20*1000), y1(x.size()), y2(x.size()), y3(x.size());
for (size_t i = 0; i < x.size(); i++) {
    x[i] = i * CV_2PI / x.size();
    y1[i] = std::sin(x[i]);
    y2[i] = y1[i] * std::sin(x[i]*50);
    y3[i] = y2[i] * std::sin(x[i]*500);
}
auto axes = CvPlot::makePlotAxes();
axes.create<CvPlot::Series>(x, y3, "-g");
axes.create<CvPlot::Series>(x, y2, "-b");
axes.create<CvPlot::Series>(x, y1, "-r");

//plot to a cv::Mat
cv::Mat mat = axes.render(300, 400);

//or show with interactive viewer
CvPlot::show("mywindow", axes);

CvPlot

You may also want to try Leonardvandriel's cvplot. It works similar but cannot be extended with custom drawables.

like image 105
palfi Avatar answered Sep 27 '22 22:09

palfi


you can try this: https://code.google.com/p/cvplot/

Matlab style plot functions for OpenCV, based on highgui. By the way, it's for C++ only.

It's open source.

like image 44
bobov Avatar answered Sep 27 '22 21:09

bobov