Draw a frequency histogram in C++/OpenCV
问题 An array of frequency is created. int arr[10]; arr[0] = 24; arr[1] = 28; arr[2] = 23; arr[3] = 29; //and so on How do i draw a histogram using OpenCV in C++ based on the array? 回答1: OpenCV is not really suited for plotting. However, for simple histograms, you can draw a rectangle for each column (eventually with alternating colors) This is the code: #include <opencv2\opencv.hpp> #include <algorithm> using namespace std; using namespace cv; void drawHist(const vector<int>& data, Mat3b& dst,