Note that there are some explanatory texts on larger screens.

plurals
  1. POPython's OpenCV cv2.imread always returns None and cvFeatDetector crashes python
    primarykey
    data
    text
    <p>I'm getting my feet wet with opencv in python, and I figure a good place to start is loading an image. </p> <p>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. </p> <p>Here is some code that demonstrates the problem: </p> <pre><code>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 </code></pre> <p>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? </p> <p>When I create </p> <pre><code> cvFeatDetector = cv2.FeatureDetector_create("MSER") </code></pre> <p>I get , so that part of cv2 seems to work </p> <hr> <p>As a workaround I just loaded the image with numpy</p> <pre><code> 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 </code></pre> <p>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. </p> <hr> <p>Edit. I fixed this by installing the released 2.4 of opencv. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload