Ask Your Question
0

how to get Hue chnanel using open cv in android

asked 2013-12-11 04:46:50 -0600

saad bilal gravatar image

updated 2013-12-11 04:48:41 -0600

i am working on open cv in android, i have detect eye but hue channel is not changed.

Mat eyeball_HSV = new Mat();
   Mat dest = new Mat();  
   Mat eye = new Mat();

   eye = mRgba.submat(eye_template).clone();

   List<Mat> hsv_channel = new ArrayList<Mat>();
    //convert image to HSV 
     // Imgproc.cvtColor(eye, eyeball_RGB, Imgproc.COLOR_RGBA2RGB, 3);
      Imgproc.cvtColor(eye, eyeball_HSV, Imgproc.COLOR_RGB2HSV, 0);
      //Core.inRange(eyeball_HSV, new Scalar(90, 50, 50), new Scalar(130, 255, 255), dest);
     // get HSV channel 
   //hsv_channel[0] is hue
   //hsv_channel[1] is saturation
   //hsv_channel[2] is visibility
      Core.split(eyeball_HSV, hsv_channel);

  try
  {
    hsv_channel.get(0).setTo(new Scalar(145));

    Log.v(TAG, "Got the Channel!");
  }
  catch(Exception ex)
  {
   ex.printStackTrace();
   Log.v(TAG, "Didn't get any channel");
  }

  Imgproc.cvtColor(eyeball_HSV, dest, Imgproc.COLOR_HSV2RGB);
  Imgproc.cvtColor(dest, eye, Imgproc.COLOR_RGB2RGBA);
edit retag flag offensive close merge delete

Comments

2

hsv_channel.get(0).setTo(new Scalar(145)); // only modifies a copy.

also, you've got to merge() your modified h channel back into the hsv (3chan) image

berak gravatar imageberak ( 2013-12-11 05:10:08 -0600 )edit

how to merge your modified h channel back into the hsv (3chan) image ??????????

Pulkit gravatar imagePulkit ( 2016-03-01 02:45:48 -0600 )edit

look at merge()

berak gravatar imageberak ( 2016-03-01 02:54:59 -0600 )edit

i am getting error while using merge function ...

I want to merge V channel with the matrix .

Core.merge(hsv_channel,matrixName);

the error i am getting is

OpenCV Error: Assertion failed (checkScalar(value, type(), _value.kind(), _InputArray::MAT )) in cv::Mat& cv::Mat::setTo(cv::InputArray, cv::InputArray), file /builds/master_pack-android/opencv/modules/core/src/copy.cpp, line 472

com.example.welcome.opencvtest E/org.opencv.core.Mat: Mat::n_1setTo__JJ() caught cv::Exception: /builds/master_pack-android/opencv/modules/core/src/copy.cpp:472: error: (-215) checkScalar(value, type(), _value.kind(), _InputArray::MAT ) in function cv::Mat& cv::Mat::setTo(cv::InputArray, cv::InputArray)

Pulkit gravatar imagePulkit ( 2016-03-01 05:04:58 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-02-14 11:41:38 -0600

manedragon gravatar image

Core.merge(hsv_channel, eyeball_HSV); Imgproc.cvtColor(eyeball_HSV, eye, Imgproc.COLOR_HSV2RGB);

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-12-11 04:46:50 -0600

Seen: 3,389 times

Last updated: Feb 14 '20