There are plenty of tutorials on this, but I think I'm missing something important about the HSV realm.
I'm looking specifically for the color (RGB) 98,199,166
an off blue color.
In my code I convert my image to HSV like so.
cvtColor(OriginalImage, HSVImage, COLOR_BGR2HSV);
I then find the RBG range of colors around that blue, so I choose 68, 83, 119
and 150, 164, 194
for my lower bound and upper bound respectively.
Using this website I convert the lowerbound and upperbound to HSV to get 222, 42.9, 46.7
and 221, 22.7, 76.1
Then in my C++ code I use the inrange function
inRange(HSVImage, Scalar(222, 42.9, 46.7), Scalar(221, 22.7, 76.1), ImgColorFound);
When I display this, it has not found the specific color I am looking for.
imshow("ObjectOfSpecificColor", ImgColorFound);
I'm not sure what i am missing or not understanding, but from the tutorials I've seen, it seems like this should find my color.
I'm also using the latest OpenCV (401 I believe)
EDIT
#include <opencv2/opencv.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core.hpp"
#include <Windows.h>
#include <iostream>
#include <tchar.h>
using namespace std;
using namespace cv;
Scalar BGR2HSV(uchar B, uchar G, uchar R)
{
Mat hsv;
Mat bgr(1, 1, CV_8UC3, Scalar(B, G, R));
cvtColor(bgr, hsv, COLOR_BGR2HSV);
return Scalar(hsv.data[0], hsv.data[1], hsv.data[2]);
}
int main(int argc, char **argv)
{
Mat Img = imread("C:\\TestImage.png");
Mat FindBlueArea;
Mat HSVImage;
cvtColor(Img, HSVImage, COLOR_BGR2HSV);
inRange(HSVImage, BGR2HSV(119, 83, 68), BGR2HSV(194, 164, 150), FindBlueArea);
namedWindow("Original Image", WINDOW_NORMAL);
imshow("Original Image", Img);
namedWindow("HSVImage", WINDOW_NORMAL);
imshow("HSVImage", HSVImage);
namedWindow("BlueArea", WINDOW_NORMAL);
imshow("BlueArea", FindBlueArea);
waitKey(5000);
}
In the actual program this is read from frame of an active window, but at any rate it still doesn't behave how I expect.
The image is a little small, but I'm trying to find only the blue blob part, and leave all the small blue circles and everything else out.