unable to use cv2.imread(cv2.samples.findfile("lena.jpg")) in opencv

asked 2019-12-14 22:58:59 -0500

Gourav gravatar image

updated 2019-12-14 23:00:24 -0500

I have installed OpenCV in pycharm and when i use image=cv2.imread(cv2.samples.findfile("lena.jpg")) in my code it gives the following error
[ WARN:0] global C:\projects\opencv-python\opencv\modules\core\src\utils\samples.cpp (59) cv::samples::findFile cv::samples::findFile('lena.jpg') => '' Traceback (most recent call last):
File "D:/all_libraries/main.py", line 5, in <module>
image=cv2.imread(cv2.samples.findFile("lena.jpg"))
cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\core\src\utils\samples.cpp:62: error:
(-2:Unspecified error) OpenCV samples: Can't find required data file: lena.jpg in function 'cv::samples::findFile'

edit retag flag offensive close merge delete

Comments

Sorry, I don't know where your missing file is...

mvuori gravatar imagemvuori ( 2019-12-15 02:58:37 -0500 )edit

@Gourav.The error telling you that you can't used cv2.samples.findfile to search in your current folder.

supra56 gravatar imagesupra56 ( 2019-12-15 07:47:55 -0500 )edit

try NOT to use pycharm. (considered harmful)

berak gravatar imageberak ( 2019-12-16 09:56:39 -0500 )edit

@Gourav. Are you using python 2 or python 3?

supra56 gravatar imagesupra56 ( 2020-01-03 07:06:44 -0500 )edit

I am usign python 3

Gourav gravatar imageGourav ( 2020-01-03 10:10:37 -0500 )edit