How to get corners using GPUImageHarrisCornerDetectionFilter

一个人想着一个人 提交于 2019-12-03 22:27:26
filter.cornersDetectedBlock = { (cornerArray:UnsafeMutablePointer<GLfloat>, cornersDetected:UInt, frameTime:CMTime) in
    for index in 0..<Int(cornersDetected) {
        points.append(CGPoint(x:CGFloat(cornerArray[index * 2]), y:CGFloat(cornerArray[(index * 2) + 1])))
    }
}

This code you have here sets a block that gets called every frame.

This is an asynchronous process so when your function returns that has never been called yet and your array should always be empty. It should be called after the frame has finished processing.

To verify this, set a breakpoint inside that block and see if it gets called.

Warning from Brad Larson (creator of GPUImage) in the comments:

The GPUImage you create here stillImageSource will be deallocated after this function exits and may cause crashes in this case.

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