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.
python opencv
Erotemic
source share