import torch
from mmdet.datasets.pipelines.transforms import Pad
from mmdet.datasets.pipelines.transforms import FilterBox
import numpy as np
import cv2


def test_pad():
    raw = dict(
        img=np.zeros((200, 401, 3), dtype=np.uint8)
    )
    cv2.imshow('raw', raw['img'])
    pad = Pad(square=True, pad_val=255)
    r = pad(raw)
    print(r['img'].shape)

    cv2.imshow('draw', r['img'])
    cv2.waitKey()

    raw = dict(
        img=np.zeros((402, 401, 3), dtype=np.uint8)
    )
    cv2.imshow('raw', raw['img'])
    pad = Pad(square=True, pad_val=255)
    r = pad(raw)
    print(r['img'].shape)

    cv2.imshow('draw', r['img'])
    cv2.waitKey()


def test_filter_box():
    bboxes = np.array([[0, 0, 10, 10],
                       [10, 10, 20, 20],
                       [10, 10, 19, 20],
                       [10, 10, 20, 19],
                       [10, 10, 19, 19]])
    gt_bboxes = np.array([[0, 0, 10, 9]])
    result = dict(gt_bboxes=bboxes)
    fb = FilterBox((10, 10))
    fb(result)


if __name__ == '__main__':
    # test_pad()
    test_filter_box()

[((12, 4, 12, 33), 'cv2.imshow', 'cv2.imshow', ({(12, 15, 12, 20): '"""raw"""', (12, 22, 12, 32): "raw['img']"}, {}), "('raw', raw['img'])", False, 'import cv2\n'), ((13, 10, 13, 39), 'mmdet.datasets.pipelines.transforms.Pad', 'Pad', (), '', False, 'from mmdet.datasets.pipelines.transforms import Pad\n'), ((17, 4, 17, 32), 'cv2.imshow', 'cv2.imshow', ({(17, 15, 17, 21): '"""draw"""', (17, 23, 17, 31): "r['img']"}, {}), "('draw', r['img'])", False, 'import cv2\n'), ((18, 4, 18, 17), 'cv2.waitKey', 'cv2.waitKey', ({}, {}), '()', False, 'import cv2\n'), ((23, 4, 23, 33), 'cv2.imshow', 'cv2.imshow', ({(23, 15, 23, 20): '"""raw"""', (23, 22, 23, 32): "raw['img']"}, {}), "('raw', raw['img'])", False, 'import cv2\n'), ((24, 10, 24, 39), 'mmdet.datasets.pipelines.transforms.Pad', 'Pad', (), '', False, 'from mmdet.datasets.pipelines.transforms import Pad\n'), ((28, 4, 28, 32), 'cv2.imshow', 'cv2.imshow', ({(28, 15, 28, 21): '"""draw"""', (28, 23, 28, 31): "r['img']"}, {}), "('draw', r['img'])", False, 'import cv2\n'), ((29, 4, 29, 17), 'cv2.waitKey', 'cv2.waitKey', ({}, {}), '()', False, 'import cv2\n'), ((33, 13, 37, 41), 'numpy.array', 'np.array', ({(33, 22, 37, 40): '[[0, 0, 10, 10], [10, 10, 20, 20], [10, 10, 19, 20], [10, 10, 20, 19], [10,\n    10, 19, 19]]'}, {}), '([[0, 0, 10, 10], [10, 10, 20, 20], [10, 10, 19, 20], [10, 10, 20, \n    19], [10, 10, 19, 19]])', True, 'import numpy as np\n'), ((38, 16, 38, 41), 'numpy.array', 'np.array', ({(38, 25, 38, 40): '[[0, 0, 10, 9]]'}, {}), '([[0, 0, 10, 9]])', True, 'import numpy as np\n'), ((40, 9, 40, 28), 'mmdet.datasets.pipelines.transforms.FilterBox', 'FilterBox', ({(40, 19, 40, 27): '(10, 10)'}, {}), '((10, 10))', False, 'from mmdet.datasets.pipelines.transforms import FilterBox\n'), ((10, 12, 10, 51), 'numpy.zeros', 'np.zeros', (), '', True, 'import numpy as np\n'), ((21, 12, 21, 51), 'numpy.zeros', 'np.zeros', (), '', True, 'import numpy as np\n')]