title: Run time error using cv::imwrite in OpenCV
body: <p>I am using OpenCV 2.3.1.  My language is C++.</p>
  
  <p>cv::imwrite works fine if I hard code the name of the output file like this.</p>
  
  <pre><code>cv::imwrite("/home/peter/BlendedInterpolatedPlane.jpg", srcnorm);
  </code></pre>
  
  <p>However, I get a run time error when I try to pass the output file name as a string like this.</p>
  
  <pre><code>cv::imwrite(outputFileName.c_str(), srcnorm);
  </code></pre>
  
  <p>or like this</p>
  
  <pre><code>cv::imwrite(outputFileName, srcnorm);
  </code></pre>
  
  <p>although there is no compiler error.</p>
  
  <p>outputFileName is declared as std::string and contains the output file name.</p>
  
  <p>The stack trace is as follows.</p>
  
  <pre><code>org.netbeans.modules.viewmodel.TreeModelNode@1999add[Name=, displayName=__kernel_vsyscall()]    
  org.netbeans.modules.viewmodel.TreeModelNode@186304c[Name=, displayName=raise()]    
  org.netbeans.modules.viewmodel.TreeModelNode@cce801[Name=, displayName=abort()] 
  org.netbeans.modules.viewmodel.TreeModelNode@93b1a8[Name=, displayName=__gnu_cxx::__verbose_terminate_handler()()]  
  org.netbeans.modules.viewmodel.TreeModelNode@749412[Name=, displayName=Address: [@0x00554fa5]]  
  org.netbeans.modules.viewmodel.TreeModelNode@1a52b00[Name=, displayName=std::terminate()()] 
  org.netbeans.modules.viewmodel.TreeModelNode@aa277d[Name=, displayName=__cxa_throw()]   
  org.netbeans.modules.viewmodel.TreeModelNode@106904c[Name=, displayName=cv::error(cv::Exception const&amp;)()]  
  org.netbeans.modules.viewmodel.TreeModelNode@1eb6f21[Name=, displayName=cv::imwrite_(std::basic_string&lt;char, std::char_traits&lt;char&gt;,   std::allocator&lt;char&gt; &gt; const&amp;, cv::Mat const&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;, bool)()]   
  org.netbeans.modules.viewmodel.TreeModelNode@1ccf1f3[Name=, displayName=cv::imwrite(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, cv::_InputArray const&amp;, std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;)()]    
  org.netbeans.modules.viewmodel.TreeModelNode@20a41d[Name=, displayName=main(argc=9,argv=0xbffff564) at main.cpp:259]
  </code></pre>
  
  <p>Any assistance would be greatly appreciated,<br>
  Peter</p>