OpenCV的Android的Java的矩阵子矩阵(感兴趣的ROI区域) [英] opencv android java matrix submatrix (ROI Region of Interest)
问题描述
我有 mRgba矩阵和矩形 - [R
(东西在帧识别)
我想要的帧的这一部分是由矩形R所规定的一个子矩阵
当我使用它是这样的:
子= mRgba.submat(R);
我得到正确的子矩阵,但我有一个问题,下一个步骤,我想改变框架的这一部分,然后再复制到原来的。
的例如:的
Imgproc.cvtColor(分,分,Imgproc.COLOR_RGBA2GRAY,1); //使其灰色
Imgproc.cvtColor(分,分,Imgproc.COLOR_GRAY2RGBA,4); //改变为rgb
我怎么能复制这个改变的子矩阵回到原来的。
或者我如何能得到/都只用一个矩形R部分全部为零创建一个面具一样大小mRgba?
子= mRgba.submat(R);Imgproc.cvtColor(分,分,Imgproc.COLOR_RGBA2GRAY,1); //使其灰色
Imgproc.cvtColor(分,分,Imgproc.COLOR_GRAY2RGBA,4); //改变为rgbsub.copyTo(mRgba.submat(R));
确定这似乎这样的伎俩:)它复制更改子图/矩阵回源的区域。(什么通常与setROI和CopyTo用于完成)
I've mRgba Matrix and a Rect r
(something recognized in the frame)
I want a sub-matrix of this part of the frame which is defined by the Rect r.
when I use it like this:
sub = mRgba.submat(r);
I get the right sub-matrix, but I've a problem with the next steps, I want to change this part of the frame and then copy it back to the original.
For example:
Imgproc.cvtColor(sub, sub, Imgproc.COLOR_RGBA2GRAY, 1); //make it gray
Imgproc.cvtColor(sub, sub, Imgproc.COLOR_GRAY2RGBA, 4); //change to rgb
How can I copy this changed sub-matrix back to the original. or how can I get/create a Mask same size as mRgba with all zeros except the Rect r part?
sub = mRgba.submat(r);
Imgproc.cvtColor(sub, sub, Imgproc.COLOR_RGBA2GRAY, 1); //make it gray
Imgproc.cvtColor(sub, sub, Imgproc.COLOR_GRAY2RGBA, 4); //change to rgb
sub.copyTo(mRgba.submat(r));
ok this seems to do the trick :) it copies the changed subpicture/matrix back in the region of the source.. (what is normally done with setROI and copyto)
这篇关于OpenCV的Android的Java的矩阵子矩阵(感兴趣的ROI区域)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!