(self, img)
| 62 | self._init(locals()) |
| 63 | |
| 64 | def get_transform(self, img): |
| 65 | center = img.shape[1::-1] * self._rand_range( |
| 66 | self.center_range[0], self.center_range[1], (2,)) |
| 67 | deg = self._rand_range(-self.max_deg, self.max_deg) |
| 68 | if self.step_deg: |
| 69 | deg = deg // self.step_deg * self.step_deg |
| 70 | """ |
| 71 | The correct center is shape*0.5-0.5. This can be verified by: |
| 72 | |
| 73 | SHAPE = 7 |
| 74 | arr = np.random.rand(SHAPE, SHAPE) |
| 75 | orig = arr |
| 76 | c = SHAPE * 0.5 - 0.5 |
| 77 | c = (c, c) |
| 78 | for k in range(4): |
| 79 | mat = cv2.getRotationMatrix2D(c, 90, 1) |
| 80 | arr = cv2.warpAffine(arr, mat, arr.shape) |
| 81 | assert np.all(arr == orig) |
| 82 | """ |
| 83 | mat = cv2.getRotationMatrix2D(tuple(center - 0.5), float(deg), 1) |
| 84 | return WarpAffineTransform( |
| 85 | mat, img.shape[1::-1], interp=self.interp, |
| 86 | borderMode=self.border, borderValue=self.border_value) |
| 87 | |
| 88 | |
| 89 | class RotationAndCropValid(ImageAugmentor): |
nothing calls this directly
no test coverage detected