`cv::line()` does not draw draw line at all if the image type is CV_8UC4 and line type is set to `CV_AA` (Bug #3634)


Added by Stefan R almost 11 years ago. Updated over 10 years ago.


Status:Done Start date:2014-04-07
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

100%

Category:core
Target version:2.4.10
Affected version:2.4.0 - 2.4.8 Operating System:Linux
Difficulty: HW Platform:x64
Pull request:

Description

`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.

#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);
}

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

$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

testimage.png (4.6 kB) Stefan R, 2014-04-07 01:14 pm


Associated revisions

Revision f6c561a0
Added by Vadim Pisarevsky almost 10 years ago

Merge pull request #3634 from mshabunin:transition-guide

History

Updated by Stefan R almost 11 years ago

A minor addition: This issue occurs only if line width is set to 1.

Updated by Steven Puttemans almost 11 years ago

Actually I find it quite weird to define a 4 channel image but only assign a 3 channel scalar for the coloring.
Shouldn't an alpha value be added to the scalar?

  • Description changed from `cv::line()` does not draw line at all if the image type is CV_8UC4 and line... to `cv::line()` does not draw line at all if the image type is CV_8UC4 and line ... More

Updated by Stefan R almost 11 years ago

That is true. I actually do that in my real code where I produce a transparent png image. I forgot to properly set the alpha values in the test code. Nevertheless, the issue remains.

Updated by Alexander Smorkalov almost 11 years ago

  • Target version changed from 2.4.9 to 2.4.10

Updated by Dmitry Retinskiy almost 11 years ago

Similar problem has been reported in #3112

  • Affected version changed from 2.4.0 - 2.4.7 to 2.4.0 - 2.4.8

Updated by Dmitry Retinskiy almost 11 years ago

Vadim, could you check this problem?

  • Status changed from New to Open

Updated by Nisarg Thakkar over 10 years ago

  • Status changed from Open to Done
  • % Done changed from 0 to 100

Also available in: Atom PDF