Ask Your Question
0

OpenCV image display

asked 2020-09-16 11:36:28 -0600

updated 2020-09-20 10:18:36 -0600

supra56 gravatar image

Hello World!

I have been very interested in OpenCV for a while now, but never bothered getting it. I ended up downloading it through pip, making sure I had numpy, matplotlib, and the cv2 modules working. I tried running a very simple program:

from __future__ import print_function

import cv2 as cv

src1 = cv.imread(cv.samples.findFile('LinuxLogo.jpg'))
src2 = cv.imread(cv.samples.findFile('WindowsLogo.jpg'))

however I get this error:

Traceback (most recent call last):  
File
"C:/Users/•••••••••/Documents/Python_Programs/adding_images.py",
line 5, in <module>
src1 = cv.imread(cv.samples.findFile('LinuxLogo.jpg'))
cv2.error: OpenCV(4.4.0)
C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-m5rt9vz0\opencv\modules\core\src\utils\samples.cpp:62:
error: (-2:Unspecified error) OpenCV
 samples: Can't find required data
 file: LinuxLogo.jpg in function
 'cv::samples::findFile'

I think what may be happening here is that this module was set up on the user appveyor and it doesn't work on my computer? Or, (probably more likely) something completely different. Either way, any help is greatly appreciated! (Note:Open CV version is up to date, python 3 is used)

edit retag flag offensive close merge delete

Comments

1

I guess you should forget samples.findFile and just call imread with your own path to any file you wish to open, unless you have a specific need to open that logo, that way...

mvuori gravatar imagemvuori ( 2020-09-16 12:36:10 -0600 )edit
sturkmen gravatar imagesturkmen ( 2020-09-16 12:44:49 -0600 )edit

mvuroi what would be the syntax to do that?

pythonCoder gravatar imagepythonCoder ( 2020-09-16 13:05:42 -0600 )edit

I saw the documentation about the .findFile part but not sure how to use it.

pythonCoder gravatar imagepythonCoder ( 2020-09-16 13:10:39 -0600 )edit

Both @berak, @mvuori and @sturkmen are pointing wrong

supra56 gravatar imagesupra56 ( 2020-09-20 10:43:40 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-09-20 03:19:11 -0600

berak gravatar image

I ended up downloading it through pip

that's why you don't have a samples or even samples/data folder, so the helper functions from cv2.samples cannot find anything. just remove the cv2.samples.findFile() part from your code, and manage your images manually.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-09-16 11:36:28 -0600

Seen: 988 times

Last updated: Sep 20 '20