Problem Saving trained EM (Java)

asked 2013-06-26 09:53:45 -0600

Nicolas gravatar image

Hi to all,

Using the OpenCV 2.4.5 bindings for desktop Java, I've successfully estimated the parameters of a Gaussian mixture model (GMM) using EM and a set of samples. For later use, I would like to save the trained model. Unfortunately I couldn't find a way to do that using the bindings for desktop Java (no save(...) or write(...) method, unlike in C++ Algorithm).

Does anyone has an idea how I could save the trained GMM to a file and later load it again? As far as I understood, I should have the same methods in Java available as in C++, right? So is this a bug?

Thanks in advance.

edit retag flag offensive close merge delete


Hi Nicolas, I am also facing same problem, did you manage to solve the problem (saving trained EM model in java)? I think one needs to use class CVStatModel.Java As per description it says it save complete model state to XML/YAML File. One can also load trained models using same class. Haven't tried it yet myself, will try tomorrow. I have just tried OpenCV 3.0.0 and with that you can save the model but I am now unable to load that model.

    EM model = EM.create();
    model.setTermCriteria(new TermCriteria(TermCriteria.COUNT+TermCriteria.EPS, 500, 0.001));
   boolean b = model.trainEM(mGray);
Muaaz gravatar imageMuaaz ( 2015-09-22 18:02:07 -0600 )edit