GPUImage2 : HarrisCornerDetector not calling callback

感情迁移 提交于 2019-12-10 00:36:19

问题


I have an odd problem implementing corner detection using GPUImage.

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.

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.

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.

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

Any thoughts?


回答1:


You forgot to input your crosshair width

crosshairGenerator.crosshairWidth = 15.0

and there is no threshold that you declared




回答2:


Make the Harris-detector object an instance property.



来源:https://stackoverflow.com/questions/43980462/gpuimage2-harriscornerdetector-not-calling-callback

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!