c++ - Draw Histogram of depth image? -
i working depth image kinect. want calculate histogram of depth image, a/f:
mat depth; //(take kinect sdk) int histsize = 64; // set ranges ( b,g,r) ) float range[] = { 0, 256 } ; const float* histrange = { range }; bool uniform = true; bool accumulate = false; mat depth_hist; // compute histograms: calchist( &depth, 1, 0, mat(), depth_hist, 1, &histsize, &histrange, uniform, accumulate ); // draw histograms depth int hist_w = 320; int hist_h = 240; int bin_w = cvround( (double) hist_w/histsize ); mat histimage( hist_h, hist_w, cv_8uc1, 1 ); // normalize result [ 0, histimage.rows ] normalize(depth_hist, depth_hist, 0, histimage.rows, norm_minmax, -1, mat() ); // draw each channel for( int = 1; < histsize; i++ ) { line( histimage, point( bin_w*(i-1), hist_h - cvround(depth_hist.at<float>(i-1)) ) , point( bin_w*(i), hist_h - cvround(depth_hist.at<float>(i)) ), scalar( 255), 2, 8, 0 ); } // display namedwindow("calchist demo", window_autosize ); imshow("calchist demo", histimage );
but, not working :(. take code grayscale image, works fine. don't know
what error?
thanks!
depth has range bigger 0-256 (you should assume 0-10000), maybe reason failure...
Comments
Post a Comment