This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A yaml constructor is for loading from a yaml node. | |
# This is taken from @misha 's answer: http://stackoverflow.com/a/15942429 | |
def opencv_matrix_constructor(loader, node): | |
mapping = loader.construct_mapping(node, deep=True) | |
mat = np.array(mapping["data"]) | |
mat.resize(mapping["rows"], mapping["cols"]) | |
return mat | |
yaml.add_constructor(u"tag:yaml.org,2002:opencv-matrix", opencv_matrix_constructor) | |
# A yaml representer is for dumping structs into a yaml node. |
NewerOlder