#include <opencv2/opencv.hpp>
enum MyShape{MyCIRCLE=0,MyRECTANGLE,MyELLIPSE};
struct ParamColorMar {
int iColormap;
};
static void TrackColorMap(int x, void *r)
{
std::cout << "selected: " << x << std::endl;
ParamColorMar *p = (ParamColorMar*)r;
p->iColormap= x;
{
if (!lutRND)
{
lutRND = makePtr<Mat>(256, 1,
CV_8UC3);
}
}
else
switch (p->iColormap) {
colorMapName = "Colormap : Autumn";
break;
colorMapName = "Colormap : Bone";
break;
colorMapName = "Colormap : Jet";
break;
colorMapName = "Colormap : Winter";
break;
colorMapName = "Colormap : Rainbow";
break;
colorMapName = "Colormap : Ocean";
break;
colorMapName = "Colormap : Summer";
break;
colorMapName = "Colormap : Spring";
break;
colorMapName = "Colormap : Cool";
break;
colorMapName = "Colormap : HSV";
break;
colorMapName = "Colormap : Pink";
break;
colorMapName = "Colormap : Hot";
break;
colorMapName = "Colormap : Parula";
break;
default:
colorMapName = "User colormap : random";
break;
}
std::cout << "> " << colorMapName << std::endl;
}
static Mat DrawMyImage(
int thickness,
int nbShape)
{
int offsetx = 50, offsety = 25;
int lineLenght = 50;
for (int i=0;i<256;i++)
line(img,
Point(thickness*i+ offsetx, offsety),
Point(thickness*i+ offsetx, offsety+ lineLenght),
Scalar(i), thickness);
int radius;
int width,height;
int angle;
for (int i=1;i<=nbShape;i++)
{
int typeShape = r.
uniform(MyCIRCLE, MyELLIPSE+1);
switch (typeShape) {
case MyCIRCLE:
break;
case MyRECTANGLE:
rc =
Rect(center-
Point(width ,height )/2, center +
Point(width , height )/2);
break;
case MyELLIPSE:
break;
}
}
return img;
}
int main(int argc, char** argv)
{
ParamColorMar p;
if (argc > 1)
else
img = DrawMyImage(2,256);
p.img=img;
p.iColormap=0;
createTrackbar(
"colormap", winName,&p.iColormap,1,TrackColorMap,(
void*)&p);
{
std::cout << "Press 'ESC' to exit" << std::endl;
}
return 0;
}