0

I try to extract text by detect the color from purple to red. this's the HSV image https://ibb.co/6JKKY68. But it only return black.

#include <opencv2/opencv.hpp>

int main()
{
    cv::Mat tempt;
    cv::Mat img = cv::imread("image.png");

    cv::cvtColor(img, tempt, cv::COLOR_BGR2HSV);

    cv::inRange(tempt, cv::Scalar(274, 50, 60), cv::Scalar(360, 255, 255), img);

    cv::imshow("image", img);
    cv::imshow("tempt", tempt);

    cv::waitKey(0);
    return 0;
}
david
  • 3
  • 4
  • Hello, I might be wrong but I'm pretty sure that in OpenCV, Hue has values from 0 to 180, Saturation and Value from 0 to 255. Thus, OpenCV uses HSV ranges between (0-180, 0-255, 0-255) – Achille G Oct 07 '21 at 11:38
  • @AchilleG ow, i use gimp application to get HSV range, in gimp the range is 360, 100, 100. i read somewhere, 100 equal to 255. okay, i will test the hue divide by 2 – david Oct 07 '21 at 11:49
  • use this : https://i.stack.imgur.com/TSKh8.png – Achille G Oct 07 '21 at 11:54
  • yes, the H value should be divided by 2 – Miki Oct 07 '21 at 12:12
  • @AchilleG i'm using `cv::inRange(tempt, cv::Scalar(143, 50, 150), cv::Scalar(180, 255, 255)`. it only detect first word. "Favor". 180 hue is red with sue, vue max. whats wrong again? – david Oct 07 '21 at 12:37

0 Answers0