Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vec3b does not take three arguments?

Tags:

opencv

Im using classes to create a function. The function must find a selected colour in the image provided. So I made it so that the function takes a Vec3b value since it is an RGB value we are talking about.

class colorcompare
{
private:
int threshold;
Vec3b color;

void setcolor(Vec3b);
Mat process(Mat&);
void setthresh(const int);
int getdist(Vec3b);
};

void colorcompare::setcolor(Vec3b colr)
{
color = colr;
}

int _tmain(int argc, _TCHAR* argv[])
{

colorcompare cc1;
Mat image;

image = imread("c:\\car2.jpg", -1);

cc1.setcolor(19,69,139); //This is where im getting error
cc1.setthresh(100);
namedWindow("meh");

imshow("meh", cc1.process(image));
waitKey(0);



return 0;
}

Now the error I am getting is this: 'colorcompare::setcolor' : function does not take 3 arguments

I know that vec3b is a vector of 3 values, so in other words I can access the individual values of vec3b as color[0], color[1] and color[2].

And I know I can define it like such in the function above but it shouldnt the vec3b be able to take 3 values? Like I did in my code?

like image 857
StuckInPhDNoMore Avatar asked Sep 10 '26 08:09

StuckInPhDNoMore


1 Answers

Classic mistake: the function expects a cv::Vec3b object, not 3 int variables.

If you want a single line solution, try this:

cc1.setcolor(cv::Vec3b(19,69,139));
like image 108
karlphillip Avatar answered Sep 12 '26 02:09

karlphillip