Ask Your Question

Revision history [back]

finding blue in HSV is easier so you can use a tricky way

consider the code below.

  Mat hsvImage = new Mat();       
  // convert the frame to HSV
  // using COLOR_RGB2HSV flag will change red to blue
  Imgproc.cvtColor(frame, hsvImage, Imgproc.COLOR_RGB2HSV);
  // Limit color range to blue in the image
  Mat blueMask = new Mat(); 
  Core.inRange(hsvImage, new Scalar(110, 50, 50), new Scalar(130, 255, 255), blueMask);

finding blue in HSV is easier so you can use a tricky wayCOLOR_RGB2HSV flag instead of COLOR_BGR2HSV

consider you can test the code below.below and see the result.

  Mat hsvImage = new Mat();       
  // convert the frame to HSV
  // using COLOR_RGB2HSV flag will change red to blue
  Imgproc.cvtColor(frame, hsvImage, Imgproc.COLOR_RGB2HSV);
  // Limit color range to blue in the image
  Mat blueMask = new Mat(); 
  Core.inRange(hsvImage, new Scalar(110, 50, 50), new Scalar(130, 255, 255), blueMask);