Skip to content

FreeType::putText write to 4 channels Mat (BGRA) #2009

@xamix

Description

@xamix

Hello,

I need some feedback about an Assert used in freetype module of OpenCv:

System information (version)
  • OpenCV => 3.4.5-dev
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2017
Detailed description

I have a Mat which is created with BGRA data layout -> CV_8UC(4).
I need to write some special text on it and so I cannot use cv::putText.
So I used the function FreeType2::putText

However the Assert at line 196 in freetype.cpp is triggering because my image has 4 channels
but the code seem to handle only 3 channels:
https://github.com/opencv/opencv_contrib/blob/3.4/modules/freetype/src/freetype.cpp#L196

I tested to remove the test to check number of channels and all seem good as far as I know (text seem to be drawn correctly):

CV_Assert( ( _img.empty()    == false ) &&
               ( _img.isMat()    == true  ) &&
               ( _img.depth()    == CV_8U ) &&
               ( _img.dims()     == 2     ) /*&&
               ( _img.channels() == 3     )*/ );

So my question is:
Is there any reason to limit FreeType2::putText function only to RGB image i.e channels = 3 but not channels = 4?, For example the cv::putText function works on both RGB and RGBA image.

Regards

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions