Updated by Steven Puttemans almost 11 years ago


`cv::line()` does not draw line at all if the image type is CV_8UC4 and line type is set to `CV_AA`. See example code and attached example output image.
It might be that other drawing functions are affected too.

<pre>
#include <opencv/cxcore.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>

int main(int argc, char** argv)
{
// two cases depending on the image depth
//cv::Mat im(400, 400, CV_8UC3); // unproblematic
cv::Mat im(400, 400, CV_8UC4); // problematic

cv::Point p1(100, 100);
cv::Point p2(300, 100);
cv::Point p3(300, 300);
cv::Point p4(100, 300);

cv::Point pp1(130, 100);
cv::Point pp2(330, 100);
cv::Point pp3(330, 300);
cv::Point pp4(130, 300);

cv::Scalar color1(0, 0, 255, 255);
cv::Scalar color2(0, 255, 0, 255);

cv::line(im, p1, p3, color1, 1, 0); // drawn in both cases
cv::line(im, p2, p4, color2, 1, CV_AA); // NOT drawn if im.type() == CV_8UC4 but drawn if im.type() == CV8UC3

cv::line(im, pp1, pp3, color1, 2, 0); // drawn in both cases
cv::line(im, pp2, pp4, color2, 2, CV_AA); // drawn in both cases

cv::imshow("im", im);
cv::imwrite("testimage.png", im),
cv::waitKey(0);
}

</pre>

Affected Version:
ros-hydro-opencv2, 2.4.6-3precise-20140303-2244-+0000

<pre>
$cat /etc/*-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"
NAME="Ubuntu"
VERSION="12.04.4 LTS, Precise Pangolin"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu precise (12.04.4 LTS)"
VERSION_ID="12.04"

$ uname -a
Linux myname 3.11.0-19-generic #33~precise1-Ubuntu SMP Wed Mar 12 21:16:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
</pre>

Back