Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv-3.0.0, python, SVM.load() is missing

I have built opencv3.0.0 on my archlinux (x64) and use it in python3 script. Where is SVM.load() method now?

algoritms.py", line 80, in load
self.model.load(fn)
AttributeError: 'cv2.ml_SVM' object has no attribute 'load'

In

class StatModel(object):
    def load(self, fn):
        logging.info(dir(self.model))
        self.model.load(fn)

    def save(self, fn):
        self.model.save(fn)

    def serialize(self):
        data_path = tempfile.mktemp()
        self.save(data_path)

        with open(data_path, 'rb') as fd:
            data = fd.read()

        os.unlink(data_path)
        return data

    def deserialize(self, data):
        data_path = tempfile.mktemp()
        with open(data_path, 'wb') as fd:
            fd.write(data)

        self.load(data_path)
        os.unlink(data_path)

And maybe someone can suggests more suitable serialize/deserialize implementation?

Opencv-3.0.0, python, SVM.load() is missing

Hi everybody, I have built opencv3.0.0 on my archlinux (x64) and use it in python3 script. Where is SVM.load() method now?

algoritms.py", line 80, in load
self.model.load(fn)
AttributeError: 'cv2.ml_SVM' object has no attribute 'load'

In

class StatModel(object):
    def load(self, fn):
        logging.info(dir(self.model))
        self.model.load(fn)

    def save(self, fn):
        self.model.save(fn)

    def serialize(self):
        data_path = tempfile.mktemp()
        self.save(data_path)

        with open(data_path, 'rb') as fd:
            data = fd.read()

        os.unlink(data_path)
        return data

    def deserialize(self, data):
        data_path = tempfile.mktemp()
        with open(data_path, 'wb') as fd:
            fd.write(data)

        self.load(data_path)
        os.unlink(data_path)

And maybe someone can suggests more suitable serialize/deserialize implementation?