How to get depth from depth images in OpenCV

asked 2017-05-23 15:58:06 -0600

imranz gravatar image

updated 2017-05-24 00:35:30 -0600

LBerger gravatar image

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;

        }
    }
edit retag flag offensive close merge delete

Comments

hmm, depth data is usually CV_16S, and for sure you should not access frame.data, or write loops like that.

berak gravatar imageberak ( 2017-05-24 00:53:27 -0600 )edit

where did the depth images come from ? (and in what format are those?)

berak gravatar imageberak ( 2017-05-24 00:54:10 -0600 )edit