Skip to content

Commit b73abfa

Browse files
committed
use .shape instead len to get the dimension of ndarray
1 parent 0f8ace7 commit b73abfa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pose/utils/transforms.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ def crop(img, center, scale, res, rot=0):
162162
new_img = np.zeros(new_shape)
163163

164164
# Range to fill new array
165-
new_x = max(0, -ul[0]), min(br[0], len(img[0])) - ul[0]
166-
new_y = max(0, -ul[1]), min(br[1], len(img)) - ul[1]
165+
new_x = max(0, -ul[0]), min(br[0], img.shape[1]) - ul[0]
166+
new_y = max(0, -ul[1]), min(br[1], img.shape[0]) - ul[1]
167167
# Range to sample from original image
168-
old_x = max(0, ul[0]), min(len(img[0]), br[0])
169-
old_y = max(0, ul[1]), min(len(img), br[1])
168+
old_x = max(0, ul[0]), min(img.shape[1], br[0])
169+
old_y = max(0, ul[1]), min(img.shape[0], br[1])
170170
new_img[new_y[0]:new_y[1], new_x[0]:new_x[1]] = img[old_y[0]:old_y[1], old_x[0]:old_x[1]]
171171

172172
if not rot == 0:

0 commit comments

Comments
 (0)