Skip to content

Relax the restriction of 3-channel #3276

@volezheng

Description

@volezheng

( _img.channels() == 3 ) );

With the restriction, it's not allowed to put text on grayscale text directly.

img = np.zeros((full, full), dtype=np.uint8)
# ft.putText(img, char, textOrg, height, 255,
#            thickness, 8, bottomLeftOrigin=True)
cv.putText(img, 'l', textOrg, cv.FONT_HERSHEY_SIMPLEX, 0.3, 255)  # this works

The ft version fails with:
cv2.error: OpenCV(4.4.0) /private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pip-req-build-7r9u7hyj/opencv_contrib/modules/freetype/src/freetype.cpp:196: error: (-215:Assertion failed) ( _img.empty() == false ) && ( _img.isMat() == true ) && ( _img.depth() == CV_8U ) && ( _img.dims() == 2 ) && ( _img.channels() == 3 ) in function 'putText'

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