#include "opencv.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat rgbImage = imread("hand.jpg");
// Mat rgbImage = imread("flower.jpg");
imshow("rgbImage", rgbImage);
Mat hsvImage;
cvtColor(rgbImage, hsvImage, COLOR_BGR2HSV);
imshow("hsvImage", hsvImage);
// hand.jpg
Scalar lowerb(0, 40, 0);
Scalar upperb(20, 180, 255);
// flower.jpg
// Scalar lowerb(150, 100, 100);
// Scalar upperb(180, 255, 255);
Mat dstImage;
inRange(hsvImage, lowerb, upperb, dstImage);
imshow("dstImage1", dstImage);
// check HSV range in object hand
vector<Mat> planes;
split(hsvImage, planes);
// imshow("planes[0]", planes[0]);
// imshow("planes[1]", planes[1]);
// imshow("planes[2]", planes[2]);
double minH, maxH;
minMaxLoc(planes[0], &minH, &maxH, NULL, NULL, dstImage);
cout << "minH =" << minH << ", maxH =" << maxH << endl;
double minS, maxS;
minMaxLoc(planes[1], &minS, &maxS, NULL, NULL, dstImage);
cout << "minS =" << minS << ", maxS =" << maxS << endl;
double minV, maxV;
minMaxLoc(planes[2], &minV, &maxV, NULL, NULL, dstImage);
cout << "minV =" << minV << ", maxV =" << maxV << endl;
waitKey();
return 0;
}
'OpenCV' 카테고리의 다른 글
블러함수들 (0) | 2017.11.11 |
---|---|
merge, split 함수 (0) | 2017.11.11 |
Template Matching 이용해 모양찾기 (0) | 2017.11.04 |
OpenCV 이미지 크기 조정하기 (0) | 2017.11.04 |
OpenCV Assertion failed (size.width>0 && size.height>0) Error (0) | 2017.11.04 |