[opencv] matlab生成opencv可读的xml

 1 xdoc=com.mathworks.xml.XMLUtils.createDocument('opencv_storage');
 2 xroot=xdoc.getDocumentElement;
 3 [m,n]=size(datatest);
 4 type=xdoc.createElement(name);
 5 xroot.appendChild(type);
 6 type.setAttribute('type_id','opencv-matrix')
 7 rows=xdoc.createElement('rows');
 8 rows.appendChild(xdoc.createTextNode(sprintf('%d',m)));
 9 type.appendChild(rows);
10 cols=xdoc.createElement('cols');
11 cols.appendChild(xdoc.createTextNode(sprintf('%d',n)));
12 type.appendChild(cols);
13 dt=xdoc.createElement('dt');
14 dt.appendChild(xdoc.createTextNode(sprintf('%s','f')));
15 type.appendChild(dt);
16 data=xdoc.createElement('data');
17 data.appendChild(xdoc.createTextNode(sprintf('%f ',datatest)));
18 type.appendChild(data);
19 str=strcat(name,'.xml');
20 xmlwrite(str,xdoc);

代码下载:  https://github.com/zhanxiage1994/Cplusplus-matlabCalibrationCamera.git

原文地址:https://www.cnblogs.com/zhanxiage1994/p/6383021.html