0
我正在使用kinect的深度圖像。我想計算的深度圖像的直方圖,A/F:繪製深度圖像的直方圖?
Mat depth; //(take from kinect sdk)
int histSize = 64;
// Set the ranges (for B,G,R))
float range[] = { 0, 256 } ;
const float* histRange = { range };
bool uniform = true; bool accumulate = false;
Mat depth_hist;
// Compute the histograms:
calcHist(&depth, 1, 0, Mat(), depth_hist, 1, &histSize, &histRange, uniform, accumulate);
// Draw the histograms for 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 the result to [ 0, histImage.rows ]
normalize(depth_hist, depth_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());
// Draw for each channel
for(int i = 1; i < 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);
但是,它不工作:(我把爲灰度圖像這個代碼,它工作正常,我不知道
。是什麼錯誤?
謝謝!
什麼是不工作。你會得到什麼,你期望得到什麼。此外,請張貼與您如何獲取深度圖像相關的任何代碼,以及是否對其進行了任何處理。 –