java roi区域检测,OpenCV的Andr​​oid的Java的矩阵子矩阵(感兴趣的ROI区域)

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值