Callback functions
Hello All and thank you for your help.
This time I would like to add about callback functions. For reference (meaning, dont read it if you want) there is something similar to my question on similar question
My question is more general. What is the general flow that we have to employ when using callback functions??
Meaning that if we have for example
callback_f(.....)
{
//Here some processing with the mouse events
// (ZONE F)
}
main()
{
// Here (ZONE A) some processing, opening images etc
setMouseCallback("image", callback_f);
// Here (ZONE B) some other processing involving variables changed in the callback function
while(char(waitKey(1)) != 'q') {}
//while(selected!=true){} //<=== I cant do this??
return 0;
}
does this mean the processing of the program is going to be ZONEA then ZONE B, and then wait for a key or a mouse action?? ZONE B is going to be processed only once right? so any meaningful operation that I want to do after setMouseCallback has to go inside the callback function because otherwise it is useless and the program just runs once to the end???
Also related question but, do I always have to use waitKey?? I tried to use a boolean (like there commented- selected) and all I got was blank windows, an endless loop and no mouse processing at all that I had to kill the program.
I ask this because if that is so, what if I have to put a mouse call back and a trackbar??? do I have to call the main afterprocessing after both callbacks and nothing in the main function??
or maybe do the whole after procesing in another function and just call it from here and there and never more in the main function???
Thanks for your help