Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I draw a boundary across a particular colour in opencv?

#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include<stdio.h>
#include<opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
    VideoCapture cap(0);
    while(true)
    {
    Mat img;
    cap.read(img);
    Mat dst;
    Mat imghsv;
    cvtColor(img, imghsv, COLOR_BGR2HSV);
    inRange(imghsv,
           Scalar(0, 30, 60),
           Scalar(20, 150, 255),
           dst
           );
    imshow("name",dst);
    if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break;
       }
}

My inrange functions work fine. But I am unable to find a method with which i can draw a boundary to across all the pixels satisfying my threshold range