-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from krok32/master
Customizable WebcamMotionDetector
- Loading branch information
Showing
4 changed files
with
307 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
webcam-capture/src/main/java/com/github/sarxos/webcam/WebcamMotionDetectorAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import java.awt.Point; | ||
import java.awt.image.BufferedImage; | ||
|
||
|
||
/** | ||
* Implementation of this interface is responsible for decision whether the | ||
* difference between two images represents movement or not. Instance may | ||
* specified as parameter of WebcamMotionDetector constructor, otherwise | ||
* WebcamMotionDetectorDefaultAlgorithm is used. | ||
*/ | ||
public interface WebcamMotionDetectorAlgorithm { | ||
|
||
/** | ||
* WebcamMotionDetector calls this method for each image used as parameter | ||
* of the method {@link #detect(BufferedImage, BufferedImage)}. | ||
* Implementation may transform the original image and prepare it for | ||
* comparison of two images. | ||
* May return the same instance if no there is no need to transform. | ||
* | ||
* @param original image | ||
* @return modified image | ||
*/ | ||
BufferedImage prepareImage(BufferedImage original); | ||
|
||
/** | ||
* Detects motion by comparison of the two specified images content. | ||
* {@link #prepareImage(BufferedImage)} method was called for both specified images. | ||
* | ||
* @param previousModified | ||
* @param currentModified | ||
* @return If the motion was detected returns true, otherwise returns false | ||
*/ | ||
boolean detect(BufferedImage previousModified, BufferedImage currentModified); | ||
|
||
/** | ||
* Get motion center of gravity. When no motion is detected this value | ||
* points to the image center. | ||
* May return null before the first movement check. | ||
* | ||
* @return Center of gravity point | ||
*/ | ||
Point getCog(); | ||
|
||
/** | ||
* Get percentage fraction of image covered by motion. 0 means no motion on | ||
* image and 100 means full image covered by spontaneous motion. | ||
* | ||
* @return Return percentage image fraction covered by motion | ||
*/ | ||
double getArea(); | ||
} |
Oops, something went wrong.