Black frame around Kinect / OpenCV frames

Hi I’m working with the kinect and OpenCV libraries trying to create blob tracking in front of a projector screen. But I can’t figure out why there is a black frame around three sides of the two openCV tracking images (which is throwing off the blob tracking). From other people’s projects I don’t see this problem happening for other people and the frame appears regardless of where the kinect is pointed so I don’t think it is a threshold problem. Worst case I could crop it out of the feed I guess…

1 Like

Hi, that’s OK.
what’s going on is that you have enabled the feature from OpenNI enables the correction of the depth image in relationship with the color one.
At least in ofxOpenNI you can toggle that with ofxOpenNiContext::toggleRegisterViewport()
I don’t remember how to call that directly from openCv, yet I remember that I’ve done so.

Cropping the image will do the job.
or you can use the valid pixels mask that openCv can get from the kinect,

cv::Mat maskMap;  
cv::VideoCapture capture;  
capture.retrieve( maskMap, CV_CAP_OPENNI_VALID_DEPTH_MASK);  

essentially this masks out all the pixels with a value of zero, like the borders but also all the pixels that are invalid. (this are mostly because of occlusion or reflective surfaces)

good luck with it!

Ah thanks, I figured it was something like that. I’ll go ahead and play around with that.

I’m not sure is this the best thread to ask about this, but is there a way to translate this opencv code:
to be used in openframeworks & ofxKinect, the part I need is the in painting algorithm in order to smooth the depthMap, because otherwise the ofxCvOpticalFlowLK got a lots of errors (peaks).

Any references will help.

@baz that link looks like it is a technique to fill the holes - this may help

@jvcleave Thank you!
I’ve got it running with OF 007, and the result is very promising.

Turms out that the line is right at the top of the example kinect routine.

// enable depth->rgb image calibration