I'm getting my feet wet with opencv in python, and I figure a good place to start is loading an image.
I've built opencv on my system, and have the python bindings and opencv dlls in the directory tpl/opencv, which is relative to my project.
Here is some 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 just always None. Could I have messed something up with the way I'm importing opencv? Is there a simple workaround?
When I create
cvFeatDetector = cv2.FeatureDetector_create("MSER")
I get , so that part of cv2 seems to work
As a workaround I just loaded the image with 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 odd, because cv2.cvtColor converts the image successfully to grayscale. So some cv2 functions do work, and others fail to varying degrees.
Edit. I fixed this by installing the released 2.4 of opencv.
As stated in the edited question, this is a bug that was fixed in a newer release of v2.4 of OpenCV. No further info seems to be currently available about the bug fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With