Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8971557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:59:09+00:00 2026-06-15T17:59:09+00:00

I’ve got a ConcurrentQueue which is being populated with a stream of images. For

  • 0

I’ve got a ConcurrentQueue which is being populated with a stream of images. For simplicity’s sake, assume they’re frames from a webcam.

What I’d ideally like to do is detect

  • if there’s any motion at all
  • Where the largest (by size not speed) motion is in the frame
  • Where the second largest motion is in the frame

Presumably I need to composite a reference image over the last N frames (so that semi-permanent changes are accounted for eg day/night, parked cars, etc…) and then difference the current frame from the reference frame.

The frames have a (minimal) level of noise so exact colour-comparison isn’t a viable option.

I’m sure I’ve seen tutorials on this before (culminating in a “box” around large areas of movement) but I can’t find them now.

Can someone point me at a decent algorithm/tutorial?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:59:09+00:00Added an answer on June 15, 2026 at 5:59 pm

    If you just want a solution that works, ZoneMinder or Motion are two pieces of software that run under linux using the video4linux interface.

    If you need to roll your own for some reason there are a lot of techniques or strategies you can use. You are largely on the right track with what you’ve outlined. You’re missing a few important details though.

    1. Since the camera is stationary, keep a record of the last N frames as your “background” image. Average them all.

      http://opencv.willowgarage.com/documentation/cpp/imgproc_motion_analysis_and_object_tracking.html

    2. Subtract the background from the current image. What you’re left with we’ll call the foreground.

      http://opencv.willowgarage.com/documentation/cpp/core_operations_on_arrays.html#cv-absdiff

    3. Optionally perform dilation or erosion (or both) to remove noise or join nearly connection regions.

      http://opencv.willowgarage.com/documentation/image_filtering.html#dilate

    4. Threshold the foreground image to determine what’s important and what’s not.

      http://docs.opencv.org/doc/tutorials/imgproc/threshold/threshold.html

    5. Optionally use the findContours function to get a description of what’s “moved”

      http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html

      Once you have the contours you can also find the bounding rectangles if that’s more what you’re going for.

      http://opencv.willowgarage.com/documentation/python/structural_analysis_and_shape_descriptors.html#boundingrect

    This will not be perfect and when debugging or optimizing you have to show output after every step to figure out what’s working right and what isn’t. Spend some time building the infrastructure to make that easier. Once you have source data and most of a working pipeline tuning to get the results you want is quite doable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.