[OpenCV]카메라 영상에서 특정값 검출(HSV컬러모델)

OpenCV/example 2013. 5. 10. 10:13

 

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;
using namespace cv;

 

int main()
{

VideoCapture camera(CV_CAP_ANY);
Mat input;
Mat output(Size(input.size().height,input.size().width),input.type());
Mat img_thresh(Size(640,480),input.type());

 

namedWindow("input",0);
namedWindow("output",0);

namedWindow("threshold",0);

 

Scalar hsv_min = cvScalar(70 , 100, 100, 0);

Scalar hsv_max = cvScalar(130, 255, 255, 0);

for(;;)
{

camera >> input;

cvtColor(input,output,CV_BGR2HSV,1);
inRange(output,hsv_min,hsv_max,img_thresh); 

imshow("input",input);
imshow("output",output);
imshow("threshold",img_thresh);

waitKey(30);    

}

 return 0;
}

반응형