title: Declaring OpenCV 3.0 GpuMat Mask and Filling With Value
body: <p>I am using OpenCV 3.0 with VS2012 C++/CLI on a Win 8.1 64 bit machine.</p>
  
  <p>In addition, I have an NVidia GTX 760 with CUDA 7.0.</p>
  
  <p>I am trying to detect SURF keypoints but only within an ROI. I got this working in non-GPU code and am now trying to do the same thing using the GPU implementation. In order to do that, I understand that I first need to create a mask filled with a background value (0) and then specify an ROI within the mask and fill that with another value (255). I then pass this mask in as part of the SURF call.</p>
  
  <p>The following code is supposed to create the mask and fill it with zeros.</p>
  
  <pre><code>cuda::GpuMat tMask(dImages-&gt;d_gpuGrayFrame-&gt;size(), dImages-&gt;d_gpuGrayFrame-&gt;type());
  tMask.setTo(Scalar::all(0));  // crashes on this line
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>cuda::GpuMat tMask(dImages-&gt;d_gpuGrayFrame-&gt;size(),CV_8U);
  tMask.setTo(Scalar::all(0));  // crashes on this line
  </code></pre>
  
  <p>I have also tried both of the above but with the setTo line as:</p>
  
  <pre><code>tMask.setTo(0);  // crashes on this line
  </code></pre>
  
  <p>But that still crashes.  It is a bit perplexing because I see examples like: <a href="https://stackoverflow.com/questions/24252019/open-cv-object-detection-orb-gpu-detector-and-surf-gpu-descriptor-extractor">link</a> where the mask is defined like:</p>
  
  <pre><code>GpuMat mask(object_gpu.size(), CV_8U, 0xFF);
  mask.setTo(0xFF);
  </code></pre>
  
  <p>When I try something like that, I do not even get past the compiler because it says that the mask call is unrecognized as a variant.</p>
  
  <p>Any help on figuring out what is going on appreciated.</p>