After cloning the GitHub repo of OpenCV, I am trying to run grabcut.py but I am getting error : Traceback (most recent call last): File "grabcut.py", line 114, in img = cv.imread(cv.samples.findFile(filename)) AttributeError: module 'cv2.cv2' has no attribute 'samples'
Here is the link to the file: https://github.com/opencv/opencv/blob/master/samples/python/grabcut.py
cv2.samples.findFile
is used to find filepath. At least inOpenCV 4.0.1 (python)
, there is nocv2.samples
submodule. You can just write afindFile
to generate absolute path, such asos.path.join("/ABSOLUTE_OPENCV/samples/data/", filename)
. Notice, you can downloadsamples/data
from github/opencv – Kinght 金