title: Unchanging Values Obtained from compareHist
body: <p>I am trying to compare successive frames from a video feed. At every frame, I do the following check:</p>
  
  <pre><code>bool
  DMSUSBVideoDevicePlugin::_hasImageChanged()
  {
      using namespace cv;
      Mat src = cv::Mat(_captureHeight, _captureWidth, CV_8UC3, (void*) _imageData);
      /// Separate the image in 3 places ( B, G and R )
      vector&lt;Mat&gt; bgr_planes;
      split( src, bgr_planes );
  
      /// Establish the number of bins
      int histSize = 256;
  
      /// Set the ranges ( for B,G,R) )
      float range[] = { 0, 256 };
      const float* histRange = { range };
  
      bool uniform = true; 
      bool accumulate = false;
  
      Mat g_hist;
  
      /// Compute the histograms:
      calcHist(&amp;bgr_planes[1], 1, 0, Mat(), g_hist, 1, &amp;histSize, &amp;histRange, uniform, accumulate);
  
      // Draw the histograms for Green channel alone since we know that that's where all the action is
      int hist_w = 512; int hist_h = 400;
      int bin_w = cvRound( (double) hist_w/histSize );
      Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );
  
      normalize(g_hist, g_hist, 0.0, histImage.rows, 32, -1, Mat());
  
      static bool isFirstFrame = true;
      if(isFirstFrame)
      {
          _lastGreenHistogram = g_hist;
          isFirstFrame = false;
          return true;
      }
  
      double diff = compareHist(g_hist, _lastGreenHistogram, CV_COMP_BHATTACHARYYA);
      _lastGreenHistogram = g_hist;
      std::cout &lt;&lt; "Diff val: " &lt;&lt; diff &lt;&lt; std::endl;
      if(diff &gt; 1.f)
      {
          return true;
      }
  
      return false;
  }
  </code></pre>
  
  <p>Even when the video content changes drastically, there is no change in the histogram value obtained from the current frame viz-a-viz that obtained from the previous (basically, diff is always static in value). </p>
  
  <p>The following are the values I get with different methods:</p>
  
  <pre><code>CV_COMP_CORREL  0 
  CV_COMP_CHISQR  1
  CV_COMP_INTERSECT 400
  CV_COMP_BHATTACHARYYA   0
  </code></pre>
  
  <p>Can someone please help point me to what I am doing wrong?</p>