function toDlib(imgs){
    var imgXMLStr = "";
    var img_keys = Object.keys(imgs);
    for(var img_i in img_keys){
        var img = imgs [ img_keys[img_i] ];
        imgXMLStr += "\t<image file='"+ img_keys[img_i] +"'>\n";
        var boxes = img.boxes;
        if(boxes){
            var b_keys = Object.keys(boxes);
            for(var box_i in b_keys){
                var box = boxes [ b_keys[box_i] ];
                var l = box.left, t = box.top;
                imgXMLStr += "\t\t<box top='"+t+"' left='"+l+"' width='"+box.width+"' height='"+box.height+"'>\n";
                imgXMLStr += "\t\t\t<label>"+b_keys[box_i]+"</label>\n";
                //Add points information
                var points = box.points;
                if(points){
                    var p_keys = Object.keys(points);
                    for(var point_i in p_keys){
                        var point = points [ p_keys[point_i] ];
                        imgXMLStr += "\t\t\t<part name='"+p_keys[point_i]+"' x='"+(point.x + l)+"' y='"+(point.y + t)+"'/>\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 toDlib(imgs){
    var imgXMLStr = "";
    var img_keys = Object.keys(imgs);
    for(var img_i in img_keys){
        var img = imgs [ img_keys[img_i] ];
        imgXMLStr += "\t<image file='"+ img_keys[img_i] +"'>\n";
        var boxes = img.boxes;
        if(boxes){
            var b_keys = Object.keys(boxes);
            for(var box_i in b_keys){
                var box = boxes [ b_keys[box_i] ];
                var l = box.left, t = box.top;
                imgXMLStr += "\t\t<box top='"+t+"' left='"+l+"' width='"+box.width+"' height='"+box.height+"'>\n";
                imgXMLStr += "\t\t\t<label>"+b_keys[box_i]+"</label>\n";
                var points = box.points;
                if(points){
                    var p_keys = Object.keys(points);
                    for(var point_i in p_keys){
                        var point = points [ p_keys[point_i] ];
                        imgXMLStr += "\t\t\t<part name='"+p_keys[point_i]+"' x='"+(point.x + l)+"' y='"+(point.y + t)+"'/>\n";
                    }
                }
                imgXMLStr += "\t\t</box>\n"
            }
        }
        imgXMLStr += "\t</image>\n";
    }
    return dlib_header + imgXMLStr + dlib_footer;
}
function toDlib ( imgs ) { var imgXMLStr = "" ; var img_keys = Object . keys ( imgs ) ; for ( var img_i in img_keys ) { var img = imgs [ img_keys [ img_i ] ] ; imgXMLStr += "\t<image file='" + img_keys [ img_i ] + "'>\n" ; var boxes = img . boxes ; if ( boxes ) { var b_keys = Object . keys ( boxes ) ; for ( var box_i in b_keys ) { var box = boxes [ b_keys [ box_i ] ] ; var l = box . left , t = box . top ; imgXMLStr += "\t\t<box top='" + t + "' left='" + l + "' width='" + box . width + "' height='" + box . height + "'>\n" ; imgXMLStr += "\t\t\t<label>" + b_keys [ box_i ] + "</label>\n" ; var points = box . points ; if ( points ) { var p_keys = Object . keys ( points ) ; for ( var point_i in p_keys ) { var point = points [ p_keys [ point_i ] ] ; imgXMLStr += "\t\t\t<part name='" + p_keys [ point_i ] + "' x='" + ( point . x + l ) + "' y='" + ( point . y + t ) + "'/>\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
//Add points information