I'm using OpenCV 2.4.1 and Python 2.7 (Enthought EPD 7.3 running under Visual Studio Python Tools). I'm trying to read an xml file using OpenCV Load() function:
import cv2
import numpy as np
reprojectionError=cv2.Load("calib.xml")
but I'm getting this error:
reprojectionError=cv2.Load("calib.xml")
AttributeError: 'module' object has no attribute 'Load'
Press any key to continue . . .
Any ideas?
I too had the same error. After searching, I found out some discussion on it in OpenCV bug tracker. From their discussion, what I understood is (of course there are lot of things i couldn't understand like some encoding etc), OpenCV load only valid xml file.
Valid means, it should be some OpenCV structures like IplImage, cvSeq etc. Otherwise it throws some errors.
When I tried to load a haarcascade xml file, It returned NULL.
TypeError: OpenCV returned NULL
When I tried to load some arbitrary xml, (got from somewhere,not related to OpenCV):
error: The node does not represent a user object (unknown type?)
Finally, I loaded an image, saved it in xml file using cv.Save, and tried to load it as follows :
import cv2
import numpy as np
img = cv2.cv.LoadImage('0.jpg',0)
cv2.cv.Save('sof.xml',img)
e=cv2.cv.Load("sof.xml")
print e
And I got the following result, which is correct :
<iplimage(nChannels=1 width=300 height=300 widthStep=300 )>
So what I understood from these examples and discussions on bug tracker is that OpenCV loads only xml files with valid OpenCV structures in it. (And it is a good option. Why should OpenCV try to load all the xml files out there? It have to open only files related to it).
This is what i know about this. Hope it helps !!!
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