title: Passing an array from c # to c++ like parameter
body: <p>I am using native code in C #. I'm trying to pass an array from C# to C++ using Pinvoke. Once in C++, I want to fill that array that I passed as parameter with the values ​​of a cv::Mat. The problem is that I am using the copy function and I do not think that this is happening well the parameters. Can anybody help me? Greetings and thank you.</p>
  
  <p>C++ code:</p>
  
  <pre><code>__declspec(dllexport)
  void ProcessFrame(unsigned char* arr) {
  VideoCapture camera;
  if (!camera.open(0))
  {
      return;
  }
  
  Mat frame;
  camera &gt;&gt; frame;
  if (frame.empty()) {
      return;
  }
  int tam = frame.cols * frame.rows;
  copy(frame.begin, frame.end, arr);
  }
  </code></pre>
  
  <p>C# code:</p>
  
  <pre><code>[DllImport("NativoPrincipio.dll")]
  public static extern void ProcessFrame(out byte[] img);
  
          byte[] imgData = new byte[webcamTexture.width * webcamTexture.height];
          ProcessFrame(out imgData);
  
          Debug.Log(imgData.Length);
          Texture2D tex = new Texture2D(webcamTexture.width, webcamTexture.height, TextureFormat.RGB24, false);
          tex.LoadRawTextureData(imgData);
          tex.Apply();
          GetComponent&lt;Renderer&gt;().material.mainTexture = tex;
  </code></pre>