How to get depth from depth images in OpenCV
Hi everyone, I have depth image sequences and I have to extract the hand from the depth image. How can I read the depth image in opencv and extract the hand.
I am doing something like this roughly but it doesn't work.
Mat frame, hand;
cap >> frame;
hand = Mat::zeros(frame.cols, frame.rows, CV_8UC1);
for(int x = 0; x<frame.cols; x++)
{
for(int y = 0; y<frame.rows; y++)
{
int offset = x + y*frame.rows;
int d = frame.data[offset];
if(d<min)
min = d;
if(d>max)
max = d;
if(d>minThreshold && d<maxThreshold && x>100)
hand.data[offset] = d;
}
}
hmm, depth data is usually CV_16S, and for sure you should not access frame.data, or write loops like that.
where did the depth images come from ? (and in what format are those?)