title: Use OpenCV Threshold with Kinect Image
body: <p>I'm trying to use the OpenCV Threshold with the depthImage retrieved by the OpenCV VideoCapture module, but I get the following error:</p>
  
  <blockquote>
    <p>OpenCV Error: Bad argument  in unknown function,
    file PATHTOOPENCV\opencv\modules\core\src\matrix.cpp line 646</p>
  </blockquote>
  
  <p>My code is as follows:</p>
  
  <pre><code>#include "opencv2/opencv.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/gpu/gpu.hpp"
  
  cv::VideoCapture kinect;
  cv::Mat rgbMap;
  cv::Mat dispMap;
  bool newFrame;
  
  void setup()
  {
      kinect.open(CV_CAP_OPENNI);
      newFrame = false;
  }
  
  void update()
  {
      if(kinect.grab())
      {
          kinect.retrieve( rgbMap, CV_CAP_OPENNI_BGR_IMAGE);
          kinect.retrieve( dispMap, CV_CAP_OPENNI_DISPARITY_MAP );
          newFrame = true;
      }
  }
  
  void draw()
  {
      if(newFrame)
      {
          cv::Mat * _thresSrc = new cv::Mat(dispMap);
          cv::Mat * _thresDst = new cv::Mat(dispMap);
  
          cvThreshold(_thresSrc, _thresDst, 24, 255, CV_THRESH_BINARY);
  
          // Draw _thresDst;
  
          delete _thresSrc;
          delete _thresDst;
          newFrame = false;
      }
  }
  </code></pre>
  
  <p>Thank you very much for your help</p>