function toDlibXML(imgs){
    var imgXMLStr = "";
    var img_keys = Object.keys(imgs);
    for(var img_i in img_keys){
        var imgName = img_keys[ img_i] ;
        var img = imgs [ imgName ];
        imgXMLStr += "\t<image file='"+ imgName +"'>\n";
        var shapes = img.shapes;
        //if(boxes){
            var shapeIds = Object.keys(shapes);
            for(var shape_i in shapeIds){
                var shapeId = shapeIds[ shape_i ];
                var shapeLabel = shapes [ shapeId ].label;
                var box = shapes [ shapeId ].bbox;
                imgXMLStr += "\t\t<box top='"+box.y+"' left='"+box.x+"' width='"+box.width+"' height='"+box.height+"'>\n";
                imgXMLStr += "\t\t\t<label>"+ shapeLabel +"</label>\n";
                //Add points information
                var fPoints = shapes [ shapeId ].featurePoints;
                //if(fPoints){
                    var fp_keys = Object.keys(fPoints);
                    for(var fPoint_i in fp_keys){
                        var fPointId = fp_keys[ fPoint_i ];
                        var fPoint = fPoints [ fPointId ];
                        imgXMLStr += "\t\t\t<part name='"+ fPoint.label +"' x='"+ fPoint.x+"' y='"+ fPoint.y +"'/>\n";
                    }
                //}
                imgXMLStr += "\t\t</box>\n"
            }
        //}
        imgXMLStr += "\t</image>\n";
    }

    return dlib_header + imgXMLStr + dlib_footer;
}
//each labelled box can have multiple feature points called parts
each labelled box can have multiple feature points called parts
each labelled box can have multiple feature points called parts
function toDlibXML(imgs){
    var imgXMLStr = "";
    var img_keys = Object.keys(imgs);
    for(var img_i in img_keys){
        var imgName = img_keys[ img_i] ;
        var img = imgs [ imgName ];
        imgXMLStr += "\t<image file='"+ imgName +"'>\n";
        var shapes = img.shapes;
            var shapeIds = Object.keys(shapes);
            for(var shape_i in shapeIds){
                var shapeId = shapeIds[ shape_i ];
                var shapeLabel = shapes [ shapeId ].label;
                var box = shapes [ shapeId ].bbox;
                imgXMLStr += "\t\t<box top='"+box.y+"' left='"+box.x+"' width='"+box.width+"' height='"+box.height+"'>\n";
                imgXMLStr += "\t\t\t<label>"+ shapeLabel +"</label>\n";
                var fPoints = shapes [ shapeId ].featurePoints;
                    var fp_keys = Object.keys(fPoints);
                    for(var fPoint_i in fp_keys){
                        var fPointId = fp_keys[ fPoint_i ];
                        var fPoint = fPoints [ fPointId ];
                        imgXMLStr += "\t\t\t<part name='"+ fPoint.label +"' x='"+ fPoint.x+"' y='"+ fPoint.y +"'/>\n";
                    }
                imgXMLStr += "\t\t</box>\n"
            }
        imgXMLStr += "\t</image>\n";
    }
    return dlib_header + imgXMLStr + dlib_footer;
}
function toDlibXML ( imgs ) { var imgXMLStr = "" ; var img_keys = Object . keys ( imgs ) ; for ( var img_i in img_keys ) { var imgName = img_keys [ img_i ] ; var img = imgs [ imgName ] ; imgXMLStr += "\t<image file='" + imgName + "'>\n" ; var shapes = img . shapes ; var shapeIds = Object . keys ( shapes ) ; for ( var shape_i in shapeIds ) { var shapeId = shapeIds [ shape_i ] ; var shapeLabel = shapes [ shapeId ] . label ; var box = shapes [ shapeId ] . bbox ; imgXMLStr += "\t\t<box top='" + box . y + "' left='" + box . x + "' width='" + box . width + "' height='" + box . height + "'>\n" ; imgXMLStr += "\t\t\t<label>" + shapeLabel + "</label>\n" ; var fPoints = shapes [ shapeId ] . featurePoints ; var fp_keys = Object . keys ( fPoints ) ; for ( var fPoint_i in fp_keys ) { var fPointId = fp_keys [ fPoint_i ] ; var fPoint = fPoints [ fPointId ] ; imgXMLStr += "\t\t\t<part name='" + fPoint . label + "' x='" + fPoint . x + "' y='" + fPoint . y + "'/>\n" ; } imgXMLStr += "\t\t</box>\n" } imgXMLStr += "\t</image>\n" ; } return dlib_header + imgXMLStr + dlib_footer ; }
each labelled box can have multiple feature points called parts
each labelled box can have multiple feature points called parts
//if(boxes){ //Add points information //if(fPoints){ //} //}