[android with opencv ] RGBA to signal channel

asked 2015-08-24 23:00:09 -0600

I want to extract green channel from input.rgba(), my code are below:

enter code here
      mRgba = inputFrame.rgba();
      Rect r = new Rect(150,50,200,200); 
      Core.rectangle(mRgba, r.tl(), r.br(), yellow, 3);
      Mat sub = mRgba.submat(r);
      Mat gchannel = new Mat();
      Core.extractChannel(sub, sub, 1);
      sub.copyTo(mRgba.submat(r));
      return mRgba;

but is doesn't work . Could anybody help me

edit retag flag offensive close merge delete

Comments

I found my bug is signal change to multi-channel, so I add this command
Imgproc.cvtColor(gchannel, gchannel, Imgproc.COLOR_GRAY2RGBA); after the command Core.extractChannel(sub, sub, 1); then is work, but I don't know is it correct answer??

blackStudent gravatar imageblackStudent ( 2015-08-24 23:15:00 -0600 )edit