コード例 #1
0
 def testGetRoiImg_xywh(self):
     Img = np.random.randint(0, 255, (10, 10), dtype=np.uint8)
     Roi_xywh = self.TypeFunc([1, 2, 4, 5])
     Offset_2x1, RoiImg = IPT.getRoiImg(Img,
                                        Roi_xywh,
                                        roiType=IPT.ROI_TYPE_XYWH)
     GTRoiImg = Img[2:7, 1:5]
     GTOffset = np.array([1, 2]).reshape(2, 1)
     np.testing.assert_array_equal(GTRoiImg, RoiImg)
     np.testing.assert_array_equal(GTOffset, Offset_2x1)
     np.testing.assert_array_equal(RoiImg.shape, (5, 4))
コード例 #2
0
 def testNoneImg_xywh(self):
     Roi_xywh = [10, 20, 30, 40]
     with testNumpy.assert_raises(IPT.IPTError):
         IPT.getRoiImg(None, Roi_xywh, IPT.ROI_TYPE_XYWH)
コード例 #3
0
 def testMinusInValid_xywh(self):
     Roi_xywh = [10, 20, -30, -40]
     with testNumpy.assert_raises(IPT.IPTError):
         IPT.getRoiImg(self.Img, Roi_xywh, IPT.ROI_TYPE_XYWH)
コード例 #4
0
 def testMinusInValid_xyxy(self):
     Roi_xyxy = [-10, -20, -30, -40]
     with testNumpy.assert_raises(IPT.IPTError):
         IPT.getRoiImg(self.Img, Roi_xyxy, IPT.ROI_TYPE_XYXY)
コード例 #5
0
 def testMinusValid_xywh(self):
     Roi_xywh = [-10, -20, 30, 40]
     _, RoiImg = IPT.getRoiImg(self.Img, Roi_xywh, IPT.ROI_TYPE_XYWH)
     print RoiImg.shape
     assert RoiImg.shape == (20, 20)
コード例 #6
0
 def testMinusValid_xyxy(self):
     Roi_xyxy = [-10, -20, 30, 40]
     _, RoiImg = IPT.getRoiImg(self.Img, Roi_xyxy, IPT.ROI_TYPE_XYXY)
     assert RoiImg.shape == (40, 30)
コード例 #7
0
 def testZero_xywh(self):
     Roi_xywh = [10, 20, 0, 0]
     _, RoiImg = IPT.getRoiImg(self.Img, Roi_xywh, IPT.ROI_TYPE_XYWH)
     assert RoiImg is not None
     testNumpy.assert_array_equal(RoiImg, np.array([]).reshape(0, 0))