Created
January 14, 2020 18:44
-
-
Save roman-smirnov/f6c58a516ed4599c21573d26f515ae3f to your computer and use it in GitHub Desktop.
how to plot a graph via OpenCV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <opencv2/highgui/highgui.hpp> | |
#include <opencv2/plot.hpp> | |
int main() { | |
std::vector<double> x{0,1,2,3,4,5,6,7,8,9}; | |
std::vector<double> y{0,-1,-3,-6,-7,-6,-5,-3,-1,0}; | |
cv::Mat1d xData(x); | |
cv::Mat1d yData(y); | |
cv::Ptr<cv::plot::Plot2d> plot = cv::plot::Plot2d::create(xData, yData); | |
plot->setPlotSize(1920, 1080); | |
cv::Mat display; | |
plot->render(display); | |
cv::imshow("Graph Plot", display); | |
cv::waitKey(0); | |
return 0; | |
} |
Author
roman-smirnov
commented
Jan 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment