gpt4 book ai didi

Java OpenCV - 检测 ROI、创建 submat 并复制到原始 mat

转载 作者:行者123 更新时间:2023-12-02 03:32:50 25 4
gpt4 key购买 nike

我正在尝试模糊网络摄像头检测到的所有人的脸部。问题是,当网络摄像头检测到人脸时,程序会显示带有模糊人脸的裁剪垫。

我尝试将模糊面放入原始垫子中,但不起作用。

for(Rect rect : faces.toArray()){
Imgproc.rectangle(frame, rect.tl(), rect.br(), new Scalar(0,0,255),3);
Rect rectCrop = new Rect(rect.x, rect.y , rect.width, rect.height);
Mat imageROI = grayFrame.submat(rectCrop);

//frame is the original mat with the correct size
Imgproc.GaussianBlur(imageROI, frame, new Size(55, 55), 55);
}

没有人脸检测:

No face detection

通过人脸检测:

With face detection

最佳答案

使用Mat的这个构造函数

Mat imageROI = new Mat(grayFrame,rectCrop);

而不是

 Mat imageROI = grayFrame.submat(rectCrop);

构造函数为您提供对grayFrame 拥有的数据矩阵的引用。因此对 submat 的任何修改都会影响 bigmat。submat 提供裁剪矩形的 GrayFrame 数据矩阵的副本。因此对 submat 的修改不会影响 bigmat。

关于Java OpenCV - 检测 ROI、创建 submat 并复制到原始 mat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37849313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com