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 );

しかし、それは機能していません:(。グレースケール画像に対してこのコードを使用しますが、正常に機能します。わかりません

エラーとは何ですか?

ありがとう!

4

1 に答える 1

0

Depth の範囲が 0 ~ 256 より大きい (0 ~ 10000 を想定する必要があります)。おそらくこれが失敗の原因です...

于 2013-08-22T13:24:03.797 に答える