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()

[((249, 278), 'cv2.imshow', 'cv2.imshow', (['"""raw"""', "raw['img']"], {}), "('raw', raw['img'])\n", (259, 278), False, 'import cv2\n'), ((289, 318), 'mmdet.datasets.pipelines.transforms.Pad', 'Pad', ([], {'square': '(True)', 'pad_val': '(255)'}), '(square=True, pad_val=255)\n', (292, 318), False, 'from mmdet.datasets.pipelines.transforms import Pad\n'), ((367, 395), 'cv2.imshow', 'cv2.imshow', (['"""draw"""', "r['img']"], {}), "('draw', r['img'])\n", (377, 395), False, 'import cv2\n'), ((400, 413), 'cv2.waitKey', 'cv2.waitKey', ([], {}), '()\n', (411, 413), False, 'import cv2\n'), ((493, 522), 'cv2.imshow', 'cv2.imshow', (['"""raw"""', "raw['img']"], {}), "('raw', raw['img'])\n", (503, 522), False, 'import cv2\n'), ((533, 562), 'mmdet.datasets.pipelines.transforms.Pad', 'Pad', ([], {'square': '(True)', 'pad_val': '(255)'}), '(square=True, pad_val=255)\n', (536, 562), False, 'from mmdet.datasets.pipelines.transforms import Pad\n'), ((611, 639), 'cv2.imshow', 'cv2.imshow', (['"""draw"""', "r['img']"], {}), "('draw', r['img'])\n", (621, 639), False, 'import cv2\n'), ((644, 657), 'cv2.waitKey', 'cv2.waitKey', ([], {}), '()\n', (655, 657), False, 'import cv2\n'), ((696, 799), 'numpy.array', 'np.array', (['[[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]])\n', (704, 799), True, 'import numpy as np\n'), ((903, 928), 'numpy.array', 'np.array', (['[[0, 0, 10, 9]]'], {}), '([[0, 0, 10, 9]])\n', (911, 928), True, 'import numpy as np\n'), ((974, 993), 'mmdet.datasets.pipelines.transforms.FilterBox', 'FilterBox', (['(10, 10)'], {}), '((10, 10))\n', (983, 993), False, 'from mmdet.datasets.pipelines.transforms import FilterBox\n'), ((199, 238), 'numpy.zeros', 'np.zeros', (['(200, 401, 3)'], {'dtype': 'np.uint8'}), '((200, 401, 3), dtype=np.uint8)\n', (207, 238), True, 'import numpy as np\n'), ((443, 482), 'numpy.zeros', 'np.zeros', (['(402, 401, 3)'], {'dtype': 'np.uint8'}), '((402, 401, 3), dtype=np.uint8)\n', (451, 482), True, 'import numpy as np\n')]