Hello everybody,
I begin to use the openCV library and I don't succed to binarize an image. I want to put a tennis ball in white and the rest of the background in black. This is my code :
int main()
{
int lowH = 40; //color green
int highH = 70;
int lowS = 230;
int highS = 255;
int lowV = 230;
int highV = 255;
Mat inputFrame, hsvFrame, outputFrame;
VideoCapture camCapture(0);
cvNamedWindow("Stream cam input", CV_WINDOW_NORMAL);
cvNamedWindow("Stream cam hsv", CV_WINDOW_NORMAL);
cvNamedWindow("Stream cam output", CV_WINDOW_NORMAL);
if (!camCapture.isOpened()) std::cout << "error cam stream" << std::endl;
while (1)
{
camCapture.read(inputFrame);
cvtColor(inputFrame, hsvFrame, CV_BGR2HSV);
cv::inRange(hsvFrame, cv::Scalar(lowH, lowS, lowV), cv::Scalar(highH, highS, highV), outputFrame);
keyboard = waitKey(30);
if (keyboard == 27) break;
imshow("Stream cam input", inputFrame);
imshow("Stream cam hsv", hsvFrame);
imshow("Stream cam output", outputFrame);
}
cvDestroyWindow("Stream cam input");
cvDestroyWindow("Stream cam hsv");
cvDestroyWindow("Stream cam output");
}
with this code I can see the image from the webam, I can also see the converting in HSV, but the outputFrame is all black and I detect nothing, no object...
Could you help me
Thank you