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 8513963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:43:51+00:00 2026-06-11T04:43:51+00:00

I was reading this and this paper about hand/head tracking. They both talk about

  • 0

I was reading this and this paper about hand/head tracking. They both talk about detecting motion computing the difference in a neighborhood of each pixel and comparing the result with a threshold:

Quoting from the first paper:

We use the temporal differencing method described in Ref. [41], which computes the absolute value of differences in the neighborhood surrounding each pixel, and then derive the accumulated differ- ence by summing the difference of all neighboring pixels. When the accumulated difference is above a predetermined thresh- old, the pixel is assigned to the moving region.

Is there an efficient way to do it (possibly in OpenCV)?
The code I wrote is pretty naive and, besides losing the real-time, seems not to give better results than a simpler pixel-to-pixel difference:

template<class T> class Image {
private:
    IplImage* imgp;
public:
    Image(IplImage* img=0) {imgp=img;}
    ~Image(){imgp=0;}
    void operator=(IplImage* img) {imgp=img;}
    inline T* operator[](const int rowIndx) {
        return ((T *)(imgp->imageData + rowIndx*imgp->widthStep));}
};

typedef Image<unsigned char>  BwImage;
typedef Image<float>          BwImageFloat;


void computeMovingRegion( IplImage* prev,  IplImage* cur, IplImage *mov) {

    BwImage _prev(prev);
    BwImage _cur(cur);
    BwImage _mov(mov);

    for (int i = 3; i<prev->height-3; i++) {
        for (int j=3; j<prev->width-3; j++) {

            int res=0;

            for (int k=i-3; k<i+3; k++) 
                for (int n=j-3; n<j+3; n++) 
                    res += abs(_cur[k][n] -_prev[k][n]);

            if (res>2000) {
                _mov[i][j]=_cur[i][j];
            }
            else
                _mov[i][j]=0;

        }
    }
}

Images are in grayscale. Don’t think it matters, but I’m using MacOS 10.8 and Xcode 4.4.2.

  • 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-11T04:43:52+00:00Added an answer on June 11, 2026 at 4:43 am

    You should be able remove a lot of the redundancy if you first calculate the absolute difference image (i.e. abs(_cur[] - prev[])) and then just iterate over this. There are a lot more optimisations you can do beyond this, but this would be a good start for relatively little effort.

    Also note that your loop indexing looks wrong – if you want to do a 7×7 neighbourhood operation it should be:

    for (int k=i-3; k<=i+3; k++) 
        for (int n=j-3; n<=j+3; n++) 
            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading this paper: Enforcing Strict Model-View Separation in Template Engines (PDF). It
I'm reading the block sort algorithm from the Burrows and Wheeler paper. This a
I'm reading some paper about computer vision. It looks like a simple fact but
This is a followup to my earlier question about deciding if a hand is
I recently came across the subject of exact real arithmetic after reading this paper
Reading through a paper for the ARM Cortex-M3 CPU I found this line confusing:
I've been reading a lot about information transformations/distortions on here and elsewhere, and they
I have been reading this paper titled Clone Detection using Abstract Syntax Trees by
Reading this excellent answer about password hashing and wondering how to implement it: The
When reading through parfib.hs code on github, I saw this comment about memory allocation

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.