| 148 | |
| 149 | |
| 150 | class WarpAffineTransform(Transform): |
| 151 | def __init__(self, mat, dsize, interp=cv2.INTER_LINEAR, |
| 152 | borderMode=cv2.BORDER_CONSTANT, borderValue=0): |
| 153 | super(WarpAffineTransform, self).__init__() |
| 154 | self._init(locals()) |
| 155 | |
| 156 | def apply_image(self, img): |
| 157 | ret = cv2.warpAffine(img, self.mat, self.dsize, |
| 158 | flags=self.interp, |
| 159 | borderMode=self.borderMode, |
| 160 | borderValue=self.borderValue) |
| 161 | if img.ndim == 3 and ret.ndim == 2: |
| 162 | ret = ret[:, :, np.newaxis] |
| 163 | return ret |
| 164 | |
| 165 | def apply_coords(self, coords): |
| 166 | coords = np.concatenate((coords, np.ones((coords.shape[0], 1), dtype='f4')), axis=1) |
| 167 | coords = np.dot(coords, self.mat.T) |
| 168 | return coords |
| 169 | |
| 170 | |
| 171 | class FlipTransform(Transform): |
no outgoing calls
no test coverage detected
searching dependent graphs…