You might have seen my previous post regarding the HSV values extraction. That code used Sliders to vary the value of the parameter passed to the thresholding algorithm. In this post, we are going to learn ahow to add a Slider or Trackbar to a cvWindow.
the function below will create and add a trackbar to the window "Output"
cvCreateTrackbar("LowHue", "Output", &lowHue, max, onLowHue);
you see here five arguments to the function.
"LowHue" - it is a string, used as caption on the cvWindow above the Trackbar. something like a name for the trackbar.
"Output" - name of the window, which must be created using cvNamedWindow("Output", CV_WINDOW_NORMAL ) before attaching a trackbar to it.
cvNamedWindow("Output",CV_WINDOW_NORMAL)
&lowHue - it is a variable, corresponding to the slider position.
int lowHue = 10;
max - maximum value for the slider. the value corresponding to slider postion when it is at the rightmost end.
int max = 255;
onLowHue - it is a function pointer, which will be called when, there is a change in slider position due to user interaction.
void onLowHue (int value )
{
lowHue = value;
}
voila!!!
the function below will create and add a trackbar to the window "Output"
cvCreateTrackbar("LowHue", "Output", &lowHue, max, onLowHue);
you see here five arguments to the function.
"LowHue" - it is a string, used as caption on the cvWindow above the Trackbar. something like a name for the trackbar.
"Output" - name of the window, which must be created using cvNamedWindow("Output", CV_WINDOW_NORMAL ) before attaching a trackbar to it.
cvNamedWindow("Output",CV_WINDOW_NORMAL)
&lowHue - it is a variable, corresponding to the slider position.
int lowHue = 10;
max - maximum value for the slider. the value corresponding to slider postion when it is at the rightmost end.
int max = 255;
onLowHue - it is a function pointer, which will be called when, there is a change in slider position due to user interaction.
void onLowHue (int value )
{
lowHue = value;
}
voila!!!