Ask Your Question
1

load the existing svm with python

asked 2016-08-16 22:45:16 -0600

littletom gravatar image

How can I load the existing svm in opencv3 by python?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-08-16 23:02:19 -0600

berak gravatar image

if that is opencv3.1 (it won't work with 3.0), you should have a SVM_load() function, which creates a new SVM from a pretrained model like this:

 svm = cv2.ml.SVM_load("mymodel.xml")

you can check in the repl:

>>> help(cv2.ml.SVM_load)
Help on built-in function SVM_load:

SVM_load(...)
    SVM_load(filepath) -> retval
edit flag offensive delete link more

Comments

import cv2 help(cv2.ml.SVM_load) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'SVM_load'

well,the version of cv on my pc is indeed 3.1.0

littletom gravatar imagelittletom ( 2016-08-17 01:34:47 -0600 )edit

so your opencv version is too old (check cv2.__version__)

you're lacking this patch

berak gravatar imageberak ( 2016-08-17 01:47:42 -0600 )edit

cv2.__version__ '3.1.0'

littletom gravatar imagelittletom ( 2016-08-17 02:16:52 -0600 )edit

I've downloaded the zip file.What should I do for handling this file.

littletom gravatar imagelittletom ( 2016-08-17 02:18:09 -0600 )edit

yes, ok. missed it in the comment before.

so, what now ? either apply the patch, or get latest src from github. in both cases, it needs rebuilding opencv

berak gravatar imageberak ( 2016-08-17 02:19:38 -0600 )edit

How to apply the patch?by the way,where are you come from?I'm just curious about it.

littletom gravatar imagelittletom ( 2016-08-17 02:26:35 -0600 )edit
berak gravatar imageberak ( 2016-08-17 02:27:34 -0600 )edit

that's wonderful! although I have no idea how to build it ,since I use the python(x,y) that allows me to apply the binary file directly.you help me a lot.

littletom gravatar imagelittletom ( 2016-08-17 02:56:22 -0600 )edit
0

answered 2016-09-02 16:26:24 -0600

valium123 gravatar image

I just downloaded and installed the latest opencv-master repo. But I still can't find that function

edit flag offensive delete link more

Comments

maybe you need a master,for example,the guy who'd already answered this question.

littletom gravatar imagelittletom ( 2016-09-02 21:38:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-08-16 22:45:16 -0600

Seen: 2,394 times

Last updated: Sep 02 '16