Why does this use of Smooth cause Python to crash?
I'm using Python 2.6 against OpenCV 2.0. I've started a file capture and pulled frames. I've displ开发者_如何学运维ayed the image to make sure it's valid. When I call this routine, python crashes:
def SmoothImage(self,SmoothingMaskSize=3):
temp=cv.CreateImage(cv.GetSize(self._lpImage),self._lpImage.depth,self._lpImage.nChannels)
cv.Smooth(self._lpImage,temp)
self._lpImage=temp
I've also tried smoothing it in-place, using cv.Smooth(self._lpImage, self._lpImage)
I'm new to Python- am I missing something obvious?
Thanks!
The bindings that come with the OpenCV 2.0 installer are buggy; I had similar problem where some very simple operations triggered crashes. Compiling from the source should fix it.
If you don't need access to the object-oriented parts of OpenCV, you should take a look at ctypes-opencv, which is a better set of python bindings. It is lovingly hand-crafted, in contrast to the SWIG-generated bindings that come with OpenCV, and I have never found any bugs in it.
http://code.google.com/p/ctypes-opencv/
Can you isolate the problem by removing the class definition? I get this working:
planes = [cv.CreateImage(cv.GetSize(image), cv.IPL_DEPTH_32F, 1) for i in range(3)]
cv.Split(image, planes[0], planes[1], planes[2], None)
for plane in planes:
cv.Smooth(plane, plane, smoothtype=cv.CV_GAUSSIAN, param1=9, param2=0, param3=0, param4=0)
精彩评论