How can I get Opencv cv::Mat hsv pixels value?

时间:2017-04-10 00:38:50

标签: c++ opencv image-processing hsv

I have a frame which is taken from video:

VideoCapture cap(videoPath);
Mat frame;
cap >> frame;

Frame have target which is blue. So I use Hsv:

Mat blue_hsv;
cvtColor(frame, blue_hsv, cv::COLOR_RGB2HSV);
inRange(blue_hsv, cv::Scalar(0, 50, 50), cv::Scalar(30, 255, 255), blue_hsv);

HSV İmage

Next, I want to get value of pixels. Is pixel white or black. But it didn't work:

for (int i = 0; i<blue_hsv.rows; i++)
 {
    for (int j = 0; j<blue_hsv.cols; j++)
    {
        Vec3b& hsv = blue_hsv.at<Vec3b>(i, j);

        cout << hsv[0] << ",";
        cout << hsv[1] << ",";
        cout << hsv[2] << endl;
    }
}

I take the "abord()" error. My main purpose is bringing the figure straight with using Pixels. So what can I do for it? How can reach value of hsv pixels?

0 个答案:

没有答案