title: converting to&from OpenCV cv::Mat, NSImage
body: <p>There's an article describing how to do this  <a href="https://stackoverflow.com/questions/8563356/nsimage-to-cvmat-and-vice-versa">here</a>, that seems to have worked for other people but it does not compile for me.</p>
  
  <p>Here's a copy of the .h file that was used:</p>
  
  <pre><code>//
  //  NSImage+OpenCV.h
  //
  
  #import &lt;AppKit/AppKit.h&gt;
  
  @interface NSImage (NSImage_OpenCV) {
  
  }
  
  +(NSImage*)imageWithCVMat:(const cv::Mat&amp;)cvMat;
  -(id)initWithCVMat:(const cv::Mat&amp;)cvMat;
  
  @property(nonatomic, readonly) cv::Mat CVMat;
  @property(nonatomic, readonly) cv::Mat CVGrayscaleMat;
  
  @end
  </code></pre>
  
  <p>I'm on Xcode 4.4, using openCV 2.4.2.  The compiler errors I'm getting for the header file are 4x of the following:</p>
  
  <p><code>Semantic issue: Use of undeclared identifier 'cv'</code></p>
  
  <p>This error seems rather obvious...the header file does not define what a cv::Mat is.
  So I took a guess from looking at the OpenCV 2.4 tutorial, that I needed to add </p>
  
  <p><code>#include &lt;opencv2/core/core.hpp&gt;</code></p>
  
  <p>This generated 20 other errors, where the compiler was complaining about the core.hpp file.
  The first of which says:</p>
  
  <p><code>Semantic issue: Non-const static data member must be initialized out of line</code></p>
  
  <p>So my question is what am I doing wrong?  How do I get this code to work?</p>