Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/core/core.hpp>
- #include <opencv2/highgui/highgui.hpp>
- #include <opencv2/imgproc/imgproc.hpp>
- using namespace cv;
- using namespace std;
- int main(){
- Mat img=imread("frame44.jpg");
- //Mat blurred;
- //blur(img,blurred,cv::Size(5,5));
- Mat hsv;
- cvtColor(img,hsv,CV_BGR2HSV);
- Mat binary;
- inRange(hsv,Scalar(23,0,250),Scalar(100,150,255),binary);
- //inRange(src, Scalar(lowBlue, lowGreen, lowRed), Scalar(highBlue, highGreen, highRed), redColorOnly);
- vector<vector<Point>> contours;
- findContours(binary.clone(),contours,RETR_EXTERNAL,CHAIN_APPROX_SIMPLE);
- Mat dst= Mat::zeros(img.size(),img.type());
- drawContours(dst,contours,-1,Scalar::all(255),CV_FILLED);
- dst &=img;
- namedWindow("Original",CV_WINDOW_AUTOSIZE);
- imshow("Original",img);
- namedWindow("HSV result",CV_WINDOW_NORMAL);
- imshow("HSV result",hsv);
- namedWindow("binary result",CV_WINDOW_NORMAL);
- imshow("binary result",binary);
- namedWindow("dst",CV_WINDOW_NORMAL);
- imshow("dst",dst);
- waitKey(0);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement