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.
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);
You may also want to try Leonardvandriel's cvplot. It works similar but cannot be extended with custom drawables.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With