Trackbar created but not updating, i mean the image are not blending [closed]
header file --------------------
class Blending
{
public:
Blending(void)
{
alpha = beta = key = defaultvalue = 0;
}
static void Blend(int, void*);
int Blended();
//int imageinput();
double alpha, beta;
int key;
int defaultvalue;
};
cpp and main file----------
int maximumvalue = 100;
int defaultvalue = 50;
void Blending::Blend(int, void*)
{
Blending blean;
blean.alpha = (double)blean.defaultvalue / 100;
addWeighted(img, blean.alpha,img2, 1.0 - blean.alpha, 0, des);
imshow("Blendimage", des);
}
int main()
{
Blending::Blend(defaultvalue, 0);
createTrackbar("Blend", "Blendimage", &defaultvalue,maximumvalue,Blending::Blend);
waitKey(0);
}
when i run the code everything works well but the images in the windows does not blend, any help
have you read https://docs.opencv.org/trunk/da/d6a/... ?
@Allaye, take a break from opencv, invest half a year at learnng basic things, your programming language, etc.
you never NEED a silly Blending class AT ALL.
for the failure -- you're instancing a new Blending instance inside Blending::Blend() (that's already facepalm), but now look at the constructor !
(it's setting everything to 0, so ofc. it won't blend anything)
thank but the code works when i remove the class from my code, that just my problem...
can you please tell me how to resolve the problem, when i remove the constructor the i get an error to initialize the class variable, so please how can you help.
@Allaye -- I already told you this, but you really need to read The C++ Programming Language by Stroustrup. Search for that on google and you'll find a free, pirated copy of the book, version 3. I would prefer if you bought it instead, of course. You need to get rid of those duplicate variables that exist outside of the class.
at first i wrote the code without classes, so i have to make the variable extern and declare the variable outside the cpp file, so later i decided to put the in a class and i forgot to remove the variable from the global scope
Good luck.