title: Convert single BGR color to HSV C++ OpenCV 4
body: <p>I am trying to detect range of Red color using C++ and OpenCV. I have converted my image from <strong>cv::COLOR_BGR2HSV</strong> colorspace already. Now I am trying to convert a single color from BGR to HSV colorspace using the code below:</p>
  
  <pre><code>cv::Mat3f red_lower(cv::Vec3f(54, 41, 203)); // BGR
  cv::Mat3f red_upper(cv::Vec3f(123, 109, 255));// BGR
  cv::Mat3f red_lower_hsv, red_upper_hsv;
  
  LOG("red_lower: " &lt;&lt; red_lower);
  cv::cvtColor(red_lower, red_lower_hsv, cv::COLOR_BGR2HSV);
  LOG("red_lower_hsv: " &lt;&lt; red_lower_hsv);
  LOG("red_upper: " &lt;&lt; red_upper);
  cv::cvtColor(red_upper, red_upper_hsv, cv::COLOR_BGR2HSV);
  LOG("red_upper_hsv: " &lt;&lt; red_upper_hsv);
  
  // get mask
  cv::inRange(image_hsv, red_lower_hsv, red_upper_hsv, OutputImage);
  </code></pre>
  
  <p>The output I get is:</p>
  
  <pre><code>red_lower: [54, 41, 203]
  red_lower_hsv: [355.18518, 0.79802954, 203]
  red_upper: [123, 109, 255]
  red_upper_hsv: [354.24658, 0.57254905, 255]
  </code></pre>
  
  <p>The values are not correct and the image mask is not generated. I even tried with a simple image with just two red boxes.</p>
  
  <p><a href="https://i.stack.imgur.com/zZpDQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zZpDQ.jpg" alt="enter image description here"></a></p>