Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

easy answer: the load() function returns a new object, it does not use the one you call it on ,so the old one is still empty ! (same for all other ml classes, btw). see for your self:

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

RTrees_load(...)
    RTrees_load(filepath[, nodeName]) -> retval
    .   @brief Loads and creates a serialized RTree from a file
    .   *
    .   * Use RTree::save to serialize and store an RTree to disk.
    .   * Load the RTree from this file again, by calling this function with the path to the file.
    .   * Optionally specify the node for the file containing the classifier
    .   *
    .   * @param filepath path to serialized RTree
    .   * @param nodeName name of node containing the classifier

so, you have to use:

    model = cv2.ml.RTrees_load(load_file)

NOT:

    model = cv2.ml.RTrees_create()
    model.load(load_file)