<p dir="auto">This simple code example ends in an Segmentation fault error.</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Mat test(720, 1280, CV_8UC3);
string text = &quot;&quot;;
putText(out, text, Point(10, 10), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 0), 2);"><pre class="notranslate">Mat <span class="pl-en">test</span>(<span class="pl-c1">720</span>, <span class="pl-c1">1280</span>, CV_8UC3);
string text = <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>;
<span class="pl-en">putText</span>(out, text, <span class="pl-c1">Point</span>(<span class="pl-c1">10</span>, <span class="pl-c1">10</span>), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(<span class="pl-c1">0</span>, <span class="pl-c1">0</span>, <span class="pl-c1">0</span>), 2);</pre></div>
<p dir="auto">The reason is the empty string (""), using any other string, that is not empty, works fine.<br>
This did not happen in OpenCV 2.4.8.<br>
Is this meant to work this way now, that one has to check the string if it is empty before drawing it?</p>
<p dir="auto"><code class="notranslate">putText</code> throws a segmentation fault when an empty <code class="notranslate">std::string</code> is passed as the <code class="notranslate">text</code> argument. It doesn't happen with an "empty" char array:</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="cv::Mat im(640, 480, CV_8UC3);
std::cout &lt;&lt; &quot;a&quot; &lt;&lt; std::endl;
cv::putText(im, &quot;&quot;, cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(255, 255, 255));
std::cout &lt;&lt; &quot;b&quot; &lt;&lt; std::endl;
cv::putText(im, std::string(&quot;&quot;), cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(255, 255, 255));
std::cout &lt;&lt; &quot;c&quot; &lt;&lt; std::endl;"><pre class="notranslate">cv::Mat <span class="pl-en">im</span>(<span class="pl-c1">640</span>, <span class="pl-c1">480</span>, CV_8UC3);
std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
<span class="pl-en">cv::putText</span>(im, <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>, cv::<span class="pl-c1">Point</span>(<span class="pl-c1">10</span>, <span class="pl-c1">30</span>), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(<span class="pl-c1">255</span>, <span class="pl-c1">255</span>, <span class="pl-c1">255</span>));
std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span> &lt;&lt; std::endl;
<span class="pl-en">cv::putText</span>(im, std::string(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>), cv::Point(<span class="pl-c1">10</span>, <span class="pl-c1">30</span>), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(<span class="pl-c1">255</span>, <span class="pl-c1">255</span>, <span class="pl-c1">255</span>));
std::cout &lt;&lt; <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span> &lt;&lt; std::endl;</pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a
b
Segmentation fault (core dumped)"><pre class="notranslate"><code class="notranslate">a
b
Segmentation fault (core dumped)
</code></pre></div>
<p dir="auto">OpenCV version 3.0.0. GCC <code class="notranslate">g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4</code>. Linux <code class="notranslate">3.16.0-50-generic x86_64</code>.</p>