Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Max threshold to the default algorithm, and added a "do not engage" default algorithm #524

Closed
wants to merge 9 commits into from

Conversation

kkanzelmeyer
Copy link
Contributor

@kkanzelmeyer kkanzelmeyer commented Jan 25, 2017

I have a camera fixed outside watching an area of my house. It's been using this webcam-capture library for almost two years. Its been great! I noticed that when clouds pass in front of the sun it would cause the aperture of the webcam to open. Then when the clouds passed the camera would be flooded with light for one or two frames while the exposure adjusted to the light, which triggered a motion event. I was able to to mostly negate the problem by setting a fixed exposure value so that the exposure wouldn't change so much when the environmental light changes. However, it gave me the idea to implement a max threshold feature in the motion sensor algorithm so that sudden "white outs" caused by exposure would not trigger a motion event. The default max threshold is set to 100, effectively removing the limit. An accessor method has been added to allow the user to adjust the value.
visitor20160816-133026
visitor20160816-131820

Another challenge I encountered having a motion detection camera deployed is the hanging flower seen in the upper right of the image below. When the wind blows and the plant swings it would trigger a motion event (rightfully so). It gave me the idea to add a "Do Not Engage" feature to the algorithm. The "Do No Engage" feature is simply a rectangle specified by the user in which the algorithm will ignore motion. The feature is implemented by allowing the user to pass a Rectangle into the algorithm, and then the algorithm only processes pixels that are not contained in the Rectangle.

visitor20160601-154220

@@ -401,12 +401,14 @@ public void setDne(Rectangle rectangle) {
*/
public ArrayList<Integer> getThresholds()
{
if (detectorAlgorithm instanceof WebcamMotionDetectorDefaultAlgorithm
|| detectorAlgorithm instanceof WebcamMotionDetectorDefaultWithDNE)
if (detectorAlgorithm instanceof WebcamMotionDetectorDefaultAlgorithm)
Copy link
Owner

@sarxos sarxos May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kkanzelmeyer,

This code is of course valid, but it would be better to have getThreasholds() extracted to an interface, such as:

public interface ThresholdsAlgorithm {
  ArrayList<Integer> getThresholds();
}

And then, both WebcamMotionDetectorDefaultAlgorithm and WebcamMotionDetectorDefaultWithDNE can implement this interface. With this we can change this code to check instanceof interface instead of every class:

public ArrayList<Integer> getThresholds()
  if (detectorAlgorithm instanceof ThresholdsAlgorithm) {
    return ((ThresholdsAlgorithm) detectorAlgorithm).getThresholds();
  }
  throw new UnsupportedOperationException("This method is only valid for algorithms which implements " + ThresholdsAlgorithm.class);
}

<name>Webcam Capture - GStreamer 1.x Driver</name>
<description>Webcam Capture driver using GStreamer 1.x framework to grab frames from camera devices</description>

<repositories>
<repository>
<id>ftp-repo</id>
<name>sarxos-ftp-repo</name>
<url>http://sarxos.pl/maven2</url>
<!-- <url>http://repo.sarxos.pl/maven2</url> -->
<url>http://repo.sarxos.pl/maven2/index.php</url>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be without index.php. I'm not sure if this won't confuse Maven when it tries to download artifact from this repo.

sarxos pushed a commit that referenced this pull request Aug 18, 2017
The "Do No Engage" algorithm is simply a rectangle specified by the user in
which the algorithm will ignore motion. The feature is implemented by allowing
the user to pass a Rectangle into the algorithm, and then the algorithm
only processes pixels that are not contained in the Rectangle.

This commit is a squash of pull request #524 by Kevin Kanzelmeyer (@kkanzelmeyer).

It was produced by cherry picking all changes into the master, squasing,
removing all changes that relates to pom.xml files (these were unnecessary)
and the ones related to GStramer 1.x driver and then finally reworking to address
comments from review.
@sarxos
Copy link
Owner

sarxos commented Aug 18, 2017

Hi @kkanzelmeyer,

I downloaded your pull request, squashed multiplied commits into one, removed unnecessary changes and reworked it to remove other issues I found when testing. I also simplified the solution by removing debugging mechanisms, integrating DNE feature into default motion detection algorithm and I also added example demonstrating how to use it.

You can find changes in: 9ee9d94

Since this feature is already merged into the master as one commit I will simply close this pull request.

Thank you Kevin!

@sarxos sarxos closed this Aug 18, 2017
@kkanzelmeyer
Copy link
Contributor Author

kkanzelmeyer commented Aug 18, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants