Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

fix bug in python/caffe/detector.py: unrounded index value will cause error. #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/caffe/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def crop(self, im, window):
crop: cropped window.
"""
# Crop window from the image.
window = np.round(window).astype(np.int)
crop = im[window[0]:window[2], window[1]:window[3]]

if self.context_pad:
Expand Down Expand Up @@ -207,10 +208,11 @@ def crop(self, im, window):

# collect with context padding and place in input
# with mean padding
box = np.round(box).astype(np.int)
context_crop = im[box[0]:box[2], box[1]:box[3]]
context_crop = caffe.io.resize_image(context_crop, (crop_h, crop_w))
crop = np.ones(self.crop_dims, dtype=np.float32) * self.crop_mean
crop[pad_y:(pad_y + crop_h), pad_x:(pad_x + crop_w)] = context_crop
crop[int(pad_y):int(pad_y + crop_h), int(pad_x):int(pad_x + crop_w)] = context_crop

return crop

Expand Down