title: Create Mat from uint16 pointer
body: <p>I am discovering openCV and working on a project in which I have a <strong>C# Plugin</strong> which call a <strong>C++ DLL</strong> to do the treatments. C# deals with Mat but my partner send me a pointer to this matrix from C# to C++. So I am trying to use this pointer to create again a matrix because I don't know how to pass a Mat object between two differente langages through a DLL.</p>
  
  <p>For now, my C++ method is :</p>
  
  <pre><code>double CustomData::calculate(LPVOID ptr)
  {
      double sum = 0;
      UINT16* src = (UINT16*)ptr;
  
      for (int y = 0; y &lt; _height; y++) {
          for (int x = 0; x &lt; _width; x++) {
              sum += src[y*_width + x];
          }
      }
      return sum;
  }
  </code></pre>
  
  <p>I want to use <code>Mat</code> from <strong>openCV</strong> now to see if the time of the calculation is faster for a mean, and also because I need to perform more operations on this matrix after. So I need to create a <code>Mat</code> object from the pointer I get. My best try is the next one :</p>
  
  <pre><code>Mat image(_height, _width, CV_16UC1, src);
  </code></pre>
  
  <p>But I get <code>unsigned char</code> as data of this matrix. I think I am using correctly the constructor so I think the problem is more in the pointer I pass to the function ?</p>