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?