maskApi.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**************************************************************************
  2. * Microsoft COCO Toolbox. version 2.0
  3. * Data, paper, and tutorials available at: http://mscoco.org/
  4. * Code written by Piotr Dollar and Tsung-Yi Lin, 2015.
  5. * Licensed under the Simplified BSD License [see coco/license.txt]
  6. **************************************************************************/
  7. #pragma once
  8. #include <stdbool.h>
  9. typedef unsigned int uint;
  10. typedef unsigned long siz;
  11. typedef unsigned char byte;
  12. typedef double* BB;
  13. typedef struct { siz h, w, m; uint *cnts; } RLE;
  14. // Initialize/destroy RLE.
  15. void rleInit( RLE *R, siz h, siz w, siz m, uint *cnts );
  16. void rleFree( RLE *R );
  17. // Initialize/destroy RLE array.
  18. void rlesInit( RLE **R, siz n );
  19. void rlesFree( RLE **R, siz n );
  20. // Encode binary masks using RLE.
  21. void rleEncode( RLE *R, const byte *mask, siz h, siz w, siz n );
  22. // Decode binary masks encoded via RLE.
  23. void rleDecode( const RLE *R, byte *mask, siz n );
  24. // Compute union or intersection of encoded masks.
  25. void rleMerge( const RLE *R, RLE *M, siz n, bool intersect );
  26. // Compute area of encoded masks.
  27. void rleArea( const RLE *R, siz n, uint *a );
  28. // Compute intersection over union between masks.
  29. void rleIou( RLE *dt, RLE *gt, siz m, siz n, byte *iscrowd, double *o );
  30. // Compute intersection over union between bounding boxes.
  31. void bbIou( BB dt, BB gt, siz m, siz n, byte *iscrowd, double *o );
  32. // Get bounding boxes surrounding encoded masks.
  33. void rleToBbox( const RLE *R, BB bb, siz n );
  34. // Convert bounding boxes to encoded masks.
  35. void rleFrBbox( RLE *R, const BB bb, siz h, siz w, siz n );
  36. // Convert polygon to encoded mask.
  37. void rleFrPoly( RLE *R, const double *xy, siz k, siz h, siz w );
  38. // Get compressed string representation of encoded mask.
  39. char* rleToString( const RLE *R );
  40. // Convert from compressed string representation of encoded mask.
  41. void rleFrString( RLE *R, char *s, siz h, siz w );