ebc7892da38289b459d6be824e1f849878bd4069
[ealt-edge.git] / example-apps / PDD / pcb-defect-detection / data / lib_coco / common / maskApi.h
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
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
15 /* Initialize/destroy RLE. */
16 void rleInit( RLE *R, siz h, siz w, siz m, uint *cnts );
17 void rleFree( RLE *R );
18
19 /* Initialize/destroy RLE array. */
20 void rlesInit( RLE **R, siz n );
21 void rlesFree( RLE **R, siz n );
22
23 /* Encode binary masks using RLE. */
24 void rleEncode( RLE *R, const byte *mask, siz h, siz w, siz n );
25
26 /* Decode binary masks encoded via RLE. */
27 void rleDecode( const RLE *R, byte *mask, siz n );
28
29 /* Compute union or intersection of encoded masks. */
30 void rleMerge( const RLE *R, RLE *M, siz n, int intersect );
31
32 /* Compute area of encoded masks. */
33 void rleArea( const RLE *R, siz n, uint *a );
34
35 /* Compute intersection over union between masks. */
36 void rleIou( RLE *dt, RLE *gt, siz m, siz n, byte *iscrowd, double *o );
37
38 /* Compute non-maximum suppression between bounding masks */
39 void rleNms( RLE *dt, siz n, uint *keep, double thr );
40
41 /* Compute intersection over union between bounding boxes. */
42 void bbIou( BB dt, BB gt, siz m, siz n, byte *iscrowd, double *o );
43
44 /* Compute non-maximum suppression between bounding boxes */
45 void bbNms( BB dt, siz n, uint *keep, double thr );
46
47 /* Get bounding boxes surrounding encoded masks. */
48 void rleToBbox( const RLE *R, BB bb, siz n );
49
50 /* Convert bounding boxes to encoded masks. */
51 void rleFrBbox( RLE *R, const BB bb, siz h, siz w, siz n );
52
53 /* Convert polygon to encoded mask. */
54 void rleFrPoly( RLE *R, const double *xy, siz k, siz h, siz w );
55
56 /* Get compressed string representation of encoded mask. */
57 char* rleToString( const RLE *R );
58
59 /* Convert from compressed string representation of encoded mask. */
60 void rleFrString( RLE *R, char *s, siz h, siz w );