Hi Guys,
I am trying to detect colors using opencv. To do that, I convert the image to HSV colorspace first and then do the operation. And to provide the range of hsv min and max, I wanted to use the trackbars but it seems like I can not create trackbars with normal functions.
#include<iostream>
#include<opencv2/imgcodecs.hpp>
#include<opencv2/imgproc.hpp>
#include<opencv2/highgui.hpp>
int hmin = 0, smin = 110, vmin = 153, hmax = 19, smax = 240, vmax = 255;
int main() {
std::string imagePath = "/Users/apple/Learning/youtubeCourse/Learn-OpenCV-cpp-in-4-Hours-main/Resources/lambo.png";
cv::Mat imageMat = cv::imread(imagePath);
cv::imshow("Original image", imageMat);
cv::Mat hsvMat;
cv::cvtColor(imageMat, hsvMat, cv::COLOR_BGR2HSV);
cv::imshow("HSV image", hsvMat);
cv::namedWindow("Trackbars", 0);
cv::createTrackbar("Hue min", "Trackbars", &hmin, 200, 0);
cv::Mat oneColorMatrix;
while(true) {
cv::Scalar lower(hmin, smin, vmin);
cv::Scalar higher(hmax, smax, vmax);
cv::inRange(hsvMat, lower, higher, oneColorMatrix);
cv::imshow("One color matrix", oneColorMatrix);
}
cv::waitKey(0);
}
And the error message I get during execution is this:
[ WARN:0] global /tmp/opencv-20210728-15491-hx6tk7/opencv-4.5.3/modules/highgui/src/window.cpp (704) createTrackbar UI/Trackbar(Hue min@Trackbars): Using 'value' pointer is unsafe and deprecated. Use NULL as value pointer. To fetch trackbar value setup callback.
Does this ring a bell to anyone?