title: pass by reference a mat object OpenCv
body: <p>I'm trying get the web camera video feed from a thread(different class).. and i wanted to return the Mat object in to main method... so far i know only to do that is to pass a reference of a Mat object which created in the main method to the thread. 
   but it was not working perfectly, this error appears
  (Unhandled exception at 0x00983489 (opencv_core248d.dll) in ConsoleApplication10.exe: 0xC0000005: Access violation writing location 0x05671050.).
  can any one help me to get through this problem.</p>
  
  <p>the reason is this my development goes to build in based on Moderator design pattern that's why. 
  thank you...!!! </p>
  
  <pre><code>#include &lt;opencv/cv.h&gt;
  #include &lt;opencv/highgui.h&gt;
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  #include &lt;thread&gt;
  
  using namespace std;
  using namespace cv;
  class Camera
  {
  public:
      void abc(Mat &amp;img){ //camara method
  
          Mat image;
          VideoCapture cap(0);
          namedWindow("window", CV_WINDOW_AUTOSIZE);
          namedWindow("win2", CV_WINDOW_AUTOSIZE);
  
          while(true)
          {
              cap &gt;&gt; image;   
              if(!image.empty())
              {
                  img=image.clone();
                  imshow("win2", img);
                  imshow("window", image);
              }
              waitKey(1);
          }
      }
      void operator()(Mat &amp;img){//thred method of the class
          abc(img); // passing Object TO method
      }
  };
  
  int main ()
  {
      Mat mImg;//main method Mat
      namedWindow("win3", CV_WINDOW_AUTOSIZE);
      thread t1((Camera()),ref(mImg)); //passing main method Mat to the Tread PASSING BY REFF
      while(true)
      {
          if(!mImg.empty())
              imshow("win3", mImg);// display main method mat Object
          waitKey(1);
      }
  
      system("pause");
      return 0;
  }  
  </code></pre>