GPUImage2:HarrisCornerDetector没有调用回调 [英] GPUImage2 : HarrisCornerDetector not calling callback

查看:230
本文介绍了GPUImage2:HarrisCornerDetector没有调用回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用GPUImage实现角点检测时遇到了一个奇怪的问题。

I have an odd problem implementing corner detection using GPUImage.

我正在尝试使用Brad下载的过滤器模板作为起点,但我可以生成图像和角点的复合视图(作为单个白色像素),当我尝试添加十字准线生成器时,永远不会调用回调函数。

I'm trying to use the filter template from Brad's download as a starting point, but although I can generate a composite view of the image and the corner points (as single white pixels), when I try to add in the crosshair generator, the callback function is never called.

在我的简化示例中,我有一个输出视图配置为 RenderView 和videoCamera定义为相机?

In my simplified example, I have an output view configured as RenderView and videoCamera defined as Camera?

    do {
        videoCamera = try Camera(sessionPreset:AVCaptureSessionPreset640x480, location:.backFacing)
        videoCamera!.runBenchmark = true
    } catch {
        videoCamera = nil
        print("Couldn't initialize camera with error: \(error)")
    }

    let filter = HarrisCornerDetector()

    let crosshairGenerator = CrosshairGenerator(size: Size(width: 480, height: 640))

    filter.cornersDetectedCallback = { corners in
        crosshairGenerator.renderCrosshairs(corners)
    }
    videoCamera! --> filter

    let blendFilter = AlphaBlend()
    videoCamera! --> blendFilter --> renderView
    //crosshairGenerator --> blendFilter    // INPUT 1: if I add this line, the callback never happens
    filter --> blendFilter                  // INPUT 2: with this input to blendFilter, the callback is good

如图所示,回调函数按预期调用,我在输出中看到小白点。

As shown, the callback function is called as expected, and I see little white dots in the output.

如果我删除注释以启用INPUT 1,并注释掉INPUT 2,显示屏将显示仅限摄像头,永远不会调用角点检测回调。

If I remove comments to enable INPUT 1, and comment out INPUT 2, the display shows the camera only, and the corner detection callback is never called.

Brad提供的示例项目在我的设备上运行,所以我知道没有硬件或iOS问题!

The sample project that Brad provides works on my device, so I know there's no hardware or iOS issue!

有什么想法吗?

推荐答案

你忘了输入十字准线宽度

You forgot to input your crosshair width

crosshairGenerator.crosshairWidth = 15.0

并且没有您声明的阈值

这篇关于GPUImage2:HarrisCornerDetector没有调用回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆