1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
import cv2
import unittest
from dyda_utils import tools
from dyda_utils import tinycv
from dyda_utils import lab_tools
from dyda_utils import dict_comparator
from dyda.components.box_processor import ResizeBoxProcessor
input_data = {
"size": {"width": 1920, "height": 1080},
"annotations": [
{
"type": "detection",
"id": 1,
"label": "person",
"track_id": 11,
"top": 306,
"bottom": 391,
"left": 635,
"right": 673,
"confidence": -1
}
]
}
resize_info = {
'ori_size': {
'height': 1080,
'width': 1920
},
'new_size': {
'height': 360,
'width': 640
}
}
ref_data = {
"size": {"width": 640, "height": 360},
"annotations": [
{
"type": "detection",
"id": 1,
"label": "person",
"track_id": 11,
"top": 102,
"bottom": 130,
"left": 211,
"right": 224,
"confidence": -1
}
]
}
class TestResizeBoxProcessor(unittest.TestCase):
""" Test simple case. """
def test_main_process(self):
""" Main process of unit test. """
# initialization
comp = ResizeBoxProcessor()
# run component
comp.reset()
comp.input_data = [resize_info, input_data]
comp.run()
## compare output_data with reference
tar_data = comp.results
report = dict_comparator.get_diff(ref_data, tar_data)
self.assertEqual(report['extra_field'], [])
self.assertEqual(report['missing_field'], [])
self.assertEqual(report['mismatch_val'], [])
if __name__ == '__main__':
unittest.main()
|