BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.88k stars 611 forks source link

Use MotionDetector but output raw footage #194

Open achimhoth opened 7 years ago

achimhoth commented 7 years ago

I have a simple application in mind: The iPhones camera is used as a security camera. When motion is detected (via MotionDetector) it should display the cameras raw footage. How do I do that?

Currently it seems the motionDetectedCallback is only fired when I feed it's output to the RenderView. However I don't want the filtered output to be displayed but rather the original footage.

I want something like:

...
let motionDetector = MotionDetector()
motionDetector.motionDetectedCallback = motionDetected
camera --> motionDetector
camera --> renderView
...

func motionDetected(p: Position, strength: Float){
       if (strength > 0.1){
          print('intruder detected!')
       }
}

But the motionDetectedCallback does not get fired like that.

achimhoth commented 7 years ago

I think I found the solution. In MotionDetector.swift I changed the output like this:

self.configureGroup{input, output in
            input --> output
            input --> self.motionComparison --> self.averageColorExtractor // --> output
            input --> self.lowPassFilter --> self.motionComparison
}