Skip to content

Incorrect error message for non-integer points in rectangle draw function: TypeError: function takes exactly 4 arguments (2 given) #15465

@maxschommer

Description

@maxschommer
System information (version)
  • OpenCV => 4.1
  • Operating System / Platform => Ubuntu 18.04 64 Bit
  • Compiler => ❔
Detailed description

The rectangle function is meant to take integer tuples for p1 and p2, however when floats are used instead, a TypeError: function takes exactly 4 arguments (2 given) error is given, instead of a TypeError: integer argument expected, got float, which is the response given by the line function. The error given is very misleading, and I believe it would be more useful to give the same error that other drawing functions give when non-integers are used.

Steps to reproduce
import numpy as np
import cv2

img = cv2.rectangle(np.ones((10, 10)),(384.2,0),(510,128),1)

This throws the error, TypeError: function takes exactly 4 arguments (2 given), while

img = cv2.line(np.ones((10, 10)),(384.2,0),(510,128),1) throws TypeError: integer argument expected, got float.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions