Hello All,
I'm trying to use trackbars on my project and for some reason they're unresponsive and can't interact with them.
Below is my code:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
//global variables
int h_min_slider;
int s_min_slider;
static void on_Hchange (int hvalue,void *userData) {
cout << "Changing H" << endl ;
}
static void on_Vchange (int vvalue, void *userData) {
cout << "Changing V" << endl;
}
int main(int argc, const char * argv[]) {
// insert code here...
VideoCapture capture(0);
if (!capture.isOpened()) {
cout << "Webcam is not opened" << endl;
}
//create bars windows
namedWindow("Trackbars",1);
//initialize bars
h_min_slider = 100;
s_min_slider = 100;
//create Trackbars
createTrackbar("H_min", "Trackbars", 0, 255,on_Hchange,&s_min_slider);
createTrackbar("S_min", "Trackbars", 0, 255,on_Vchange,&h_min_slider);
capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
Mat image;
while (true) {
Mat image;
Mat HSVImage;
Mat processedImage;
capture.read(image); //read raw image from Camera
cvtColor(image, HSVImage, CV_BGR2HSV); //convert image to HSV and save into HSVImage
inRange(HSVImage, Scalar(0,136,192), Scalar(171,205,255), processedImage);
imshow("Image", image);
imshow("Processed Image", processedImage);
}
return 0;
}
Here is a picture of the trackbars, also, they don't show the current value either
Thank you for your help!