27 lines
860 B
C++
27 lines
860 B
C++
#include "yolo_mask_utils.h"
|
|
|
|
#include <cassert>
|
|
|
|
int main() {
|
|
const unsigned char mask[] = {
|
|
0, 0, 0, 0, 99, 99,
|
|
0, 7, 7, 0, 99, 99,
|
|
0, 7, 0, 0, 99, 99,
|
|
0, 7, 7, 7, 99, 99,
|
|
0, 0, 0, 0, 99, 99
|
|
};
|
|
const auto bounds = yolo_find_mask_bounds(mask, 4, 5, 6);
|
|
assert(bounds.x == 1 && bounds.y == 1);
|
|
assert(bounds.width == 3 && bounds.height == 3);
|
|
const auto roi = yolo_copy_binary_mask_roi(mask, 6, bounds);
|
|
assert(roi.size() == 9);
|
|
assert(roi[0] == 255 && roi[1] == 255 && roi[2] == 0);
|
|
assert(roi[3] == 255 && roi[4] == 0 && roi[5] == 0);
|
|
assert(roi[6] == 255 && roi[7] == 255 && roi[8] == 255);
|
|
|
|
const unsigned char empty_mask[8] = {};
|
|
assert(yolo_find_mask_bounds(empty_mask, 4, 2, 4).empty());
|
|
assert(yolo_find_mask_bounds(nullptr, 4, 2, 4).empty());
|
|
return 0;
|
|
}
|