Export annotations in interoperable format? #977
Replies: 2 comments
-
Note: Not a developer, just an end-user From my experience Or alternatively in the annotations csv output The information is split into two parts, the "Shape ID" describes the geometry type of the annotation, and then the vertices of the shape are described under "points". I agree that it's not the most interoperable way of storing these data, I had to write the following (rather dodgy) R code to convert the outputs into something vaguely usable for R (Well known text), but storing the geometry internally as SVG or another existing standard would be preferable for direct access. ## Only implemented for Points, lines, rectangles and polygon annotation types
## Will not work for anything else (Circles,Ellipses...) that will have to be added in at some point, but is a little more complex as would likely need to do some sort of buffer.
biigle_to_WKT <- function(vertexvector, geomtype){
if(geomtype=='Point'){
WKT <- sprintf('POINT (%s %s)', vertexvector[1], vertexvector[2])
}else if(geomtype=='LineString'){
chr_vtx <- pair_up_vector_coords(vertexvector)
WKT <- paste0("LINESTRING (",chr_vtx,")")
}else if(geomtype=='Polygon'){
chr_vtx <- pair_up_vector_coords(vertexvector)
WKT <- paste0("POLYGON ((",chr_vtx,"))")
}else if(geomtype=='Rectangle'){
WKT <- sprintf('POLYGON ((%s %s, %s %s, %s %s, %s %s, %s %s))',
vertexvector[1], vertexvector[2],
vertexvector[3], vertexvector[4],
vertexvector[5], vertexvector[6],
vertexvector[7], vertexvector[8],
vertexvector[1], vertexvector[2],)
}
return(WKT)
}
## FUNCTION: Turns a vector into a string of paired numbers, used in biigle_to_WKT function to make the vertex bit of the WKT.
pair_up_vector_coords <- function(vertexvector, chunkLength=2){
nested_vtx <- split(vertexvector,ceiling(seq_along(vertexvector) / chunkLength))
chr_vtx <- paste(sapply(nested_vtx, paste, collapse=' '), collapse = ", ")
return(chr_vtx)
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for chiming in @GMDuncan! @lupinthief you can export the annotations via a machine-readable report file. Possible options are CSV (image and video annotations) or COCO and iFDO (only image annotations). |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I'm scoping out using BIIGLE for a project and am struggling to find how to export the annotations (in this case polygons) in an interoperable format. The label tree exports don't seem to contain any information on the actual geometry of the polygons. I am sort of looking for how to export as masks, but if that's not implemented, then can anyone point me at the docs for how to export them in other formats?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions