def _parse_annotation(self,itemidx,random_trainsize): rootpath, filename = self._ids[itemidx] annpath = self._annopath.format(rootpath, filename) imgpath = self._imgpath.format(rootpath, filename) fname, bboxes, labels = PascalVocXmlParser(annpath, self.labels).parse() img = cv2.imread(imgpath, cv2.IMREAD_COLOR) if self.istrain: img, bboxes = dataAug.random_horizontal_flip(np.copy(img), np.copy(bboxes)) img, bboxes = dataAug.random_crop(np.copy(img), np.copy(bboxes)) img, bboxes = dataAug.random_translate(np.copy(img), np.copy(bboxes)) ori_shape=img.shape[:2] img, bboxes = dataAug.img_preprocess2(np.copy(img), np.copy(bboxes), (random_trainsize, random_trainsize), True) return img,bboxes,labels,imgpath,ori_shape
def _parse_annotation(self, itemidx, random_trainsize): img_info = self.img_infos[itemidx] ann_info = self._load_ann_info(itemidx) ann = self._parse_ann_info(ann_info) bboxes = ann['bboxes'] # [x1,y1,x2,y2] labels = ann['labels'] # load the image. imgpath = osp.join(self.image_dir, img_info['file_name']) img = cv2.imread(imgpath, cv2.IMREAD_COLOR) if self.istrain: img, bboxes = dataAug.random_horizontal_flip( np.copy(img), np.copy(bboxes)) img, bboxes = dataAug.random_crop(np.copy(img), np.copy(bboxes)) img, bboxes = dataAug.random_translate(np.copy(img), np.copy(bboxes)) ori_shape = img.shape[:2] img, bboxes = dataAug.img_preprocess2( np.copy(img), np.copy(bboxes), (random_trainsize, random_trainsize), True) return img, bboxes, labels, imgpath, ori_shape