Problem with frame differencing with kinect?

Hi list, i tried to implement frame differencing with kinect, but im getting wierd results.
My kinect camera is only capturing a very limited range and my threshold is not working as expected.

any idea what am i doing wrong?
maybe im missing something?

cheers

ofxCvGrayscaleImage 	grayImageCurrent;
ofxCvGrayscaleImage 	grayBg;  
ofxCvGrayscaleImage 	grayDiff;   // this is the frame differencing image


update (){
....

if(kinect.isFrameNew()) {
         grayImageCurrent.setFromPixels(kinect.getDepthPixelsRef());
         grayDiff.absDiff(grayBg, grayImageCurrent);
         grayDiff.threshold(239);   
         grayBg =  grayImageCurrent ;
          


}
....
}

are you setting the depths limits with?:

void setDepthClipping(float nearClip=500, float farClip=4000);

maybe the depth map its too much noise, you can try doing a blur in grayDiff

Hi, i just realize what was the problem.

It was a misconception of how the .threshold method works.

The code is working, but what i need is to set a threshold of the amount of change between the previous frame and the new frame.

Because the problem i have is that even if i dont move my hand ( there is always a little movement) im still getting images, and the idea is to get only images when there is a significant move in front of kinect.

How can i control the threshold of the amount of change ?

read this, maybe its aplicable

so lets say that you have something like that:

int moveAmount = grayDiff.countNonZeroInRegion(0, 0, grayDiff.getWidth(), grayDiff.getHeight());

and do aomething like

if(moveAmount > myMovementThreshold){
do…
}

Hi Pandereto , ive tried your approach , it works fine but only depending on the size of the moving “thing” in front of the kinect , for example, if i use a threshold value that works fine with my “hand” and then i put my body , even if i dont move my body at all, its gonna detect movement because my body is much bigger than my hand and its gonna create much more white pixels than the non moving hand.

Do anybody have an idea of how to solve this problem?
Is there is a way of detecting significant movement that not depends on the size of the moving object?

what about getting the bigest blob area and make that moveAmount relative to the size of the bigest blob

for curiosity… what are you trying to do¿