e95d2a95502ce17fd0a22ebdf94eba31d5faae40
[platform/upstream/opencv.git] / samples / cpp / gencolors.cpp
1 #include "opencv2/imgproc/imgproc.hpp"
2 #include "opencv2/contrib/contrib.hpp"
3 #include "opencv2/highgui/highgui.hpp"
4
5 #include <cstdio>
6 #include <iostream>
7 #include <ctime>
8
9 using namespace cv;
10 using namespace std;
11
12 int main(int argc, char** argv)
13 {
14     if( argc != 2 )
15     {
16         cout << "Colors count should be passed." << endl;
17         return -1;
18     }
19
20     int colorsCount = atoi(argv[1]);
21     vector<Scalar> colors;
22     theRNG() = (uint64)time(0);
23     generateColors( colors, colorsCount );
24
25     int stripWidth = 20;
26     Mat strips(300, colorsCount*stripWidth, CV_8UC3);
27     for( int i = 0; i < colorsCount; i++ )
28     {
29         strips.colRange(i*stripWidth, (i+1)*stripWidth) = colors[i];
30     }
31
32     imshow( "strips", strips );
33     waitKey();
34
35     return 0;
36 }