[Simple note] opencv error (remember to keep updating!!!)

#Only for personal review notes


1.

Mistake one:

error: OpenCV(4.8.1) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

#This error comes from the cv::cvtColor function in the OpenCV library, which usually means thatthe input image is empty (i.e. _src.empty () is true).

Solution:

Imread reads the image path incorrectly. The code and the image are not in the same folder. It is best to use an absolute path.

2.

Mistake 2:

error: OpenCV(4.8.1) :-1: error: (-5:Bad argument) in function 'grabCut'

Overload resolution failed:
    Can't parse 'rect'. Sequence item with index 2 has a wrong type
    Can't parse 'rect'. Sequence item with index 2 has a wrong type

'''

When using grabCut function,rectangle parameter (rect) has an incorrect input type. The rectangle parameter rectangle = (x, y, width, height) is a tuple with four integer values ​​that specifies the coordinates and dimensions of the target area to be divided.

'''

Solution:

Change all four custom values ​​of x, y, width, and height to integers


2023.11.26

Guess you like

Origin blog.csdn.net/qq_63975182/article/details/134631134