title: Can't save an image captured from webcam (imwrite compile error with OpenCV 2.3)
body: <p>I'm making simple webcam program using OpenCV 2.3 and got stuck by the compile error. Any idea will be appreciated.</p>
  
  <p>Upon compile, I get the following error at imwrite (in read function in the code below).</p>
  
  <p><a href="https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/stereo_match.cpp" rel="nofollow">This sample</a> that uses imwrite to save an image works on my environment, which indicates imwrite in OpenCV 2.3 should work on my env.</p>
  
  <p>error:</p>
  
  <pre><code>error: invalid initialization of reference of type ‘const cv::_InputArray&amp;’ from expression of type ‘cv::Mat*’
  /usr/local/include/opencv2/highgui/highgui.hpp:110: error: in passing argument 2 of ‘bool cv::imwrite(const std::string&amp;, const cv::_InputArray&amp;, const std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;)’
  </code></pre>
  
  <p>code excerpt:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "opencv2/highgui/highgui.hpp"
  #include "opencv2/core/core.hpp"
  #include "opencv2/imgproc/imgproc.hpp"
  
  using namespace std;
  using namespace cv;
  
  //IplImage* SampleClassA::dispImg = NULL;
  Mat* SampleClassA::dispImg = NULL;
  
  int read()
  {
          Mat* sharedImg;
      sharedImg = getFrame();
      if (sharedImg)
      {
          if (dispImg == NULL)
          {
              SampleClassA::dispImg = sharedImg;
          }
          Mat outMat;
          outMat = imwrite("./out/sample.jpg", sharedImg);
      }
      sleep(100);
      return 1;
  }
  
  Mat* getFrame()
  //IplImage* ReadRealTime::getFrame()
  {
      if (!capture.isOpened()) // Actual capturing part is omitted here.
      {
          return NULL;
      }
      Mat frame;
      capture &gt;&gt; frame;
      return &amp;frame;
  }
  &lt;/code&gt;
  </code></pre>
  
  <p>Btw, I'm confused whether imwrite takes 2 arguments or 3. Both the following link and highgui.hpp on my machine say 3 args, but the sample code I cited above (<a href="https://code.ros.org/svn/opencv/trunk/opencv/samples/cpp/stereo_match.cpp" rel="nofollow">from ros.org</a>) uses only 2 (which is because I'm doing the same).
  <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imwrite#imwrite" rel="nofollow">http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=imwrite#imwrite</a></p>
  
  <p>ps. Forgive my posting the same question here with the one I sent to OpenCV@yahoogroups.com if you are subscribing to it. The reason I did this is because this website seems more interactive and convenient for various purposes.</p>