Python OpenCV cv2.imread always returns None, and cvFeatDetector - python crash

I force my feet to wet with opencv in python, and I find that a good place to download is to load the image.

I created opencv on my system and linked python and opensv dll in the tpl / opencv directory that belongs to my project.

Here is the code that demonstrates the problem:

from tpl.opencv import cv2 from tpl.opencv.cv2 import cv from PIL import Image pil_img = Image.open('C:/test_file.jpg') #Read a temp file, the input is actually a computed image chip tmpname = 'C:/tmp.png' pil_img.save(tmpname,'PNG') # Write the image chip to disk im = cv.LoadImage(tmpname) # This seems to work im2 = cv2.imread(tmpname) # This always returns None 

There is no error message, im2 is always always None. Can I ruin something by the way I import opencv? Is there an easy way?

When i create

  cvFeatDetector = cv2.FeatureDetector_create("MSER") 

I get so the cv2 part seems to work


As a workaround, I just uploaded the image using numpy

  im2 = numpy.imread(inname) im = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY) # This works. I was able to imshow it too cvFeatDetector = cv2.FeatureDetector_create("MSER") # Seems to produce a valid object cvFeatExtractor = cv2.DescriptorExtractor_create("SIFT") # Seems to produce a valid object kpts = cvFeatDetector.detect(im) # Crashes python 

I find this very strange because cv2.cvtColor converts the image to grayscale. Therefore, some cv2 functions work, while others do not to varying degrees.


Change I fixed this by installing the released 2.4 opencv.

+8
python opencv
source share

No one has answered this question yet.

See related questions:

607
Python `if x is not None` or` if not x is None '?
413
no test in python
eleven
OpenCV imread hangs on call from web request
7
How to read alpha channel of TIFF image in Python OpenCV?
2
Want to add color images to a list and convert this list to shades of gray using OpenCV
one
What is the difference between the InRange method in opencv with python / cv2 and C # / emgu?
one
Python opencv cv2 cap.read () returns None in PyInstaller on Windows
one
Opencv MSER detectRegions C ++ Vs. python
0
OpenCV for python error
0
How to fix error writing data to pgm file

All Articles