def getTestDataByIndex(self, id): # idよりデータ取得 index = self.__testId.index(id) image = self.__testImage[index] annotation = Common.cvtObjects2Points(self.__testAnnotation[index]["annotation"]["object"]) # bing結果の読み込み bingResultsPath = self.__datasetPath + "/" + self.__BING_RESULT_PATH % (self.__bingProjectName, id) bingResults = Common.readCSV(bingResultsPath) bingResults = bingResults[:min(len(bingResults), self.__PROPOSAL_NUMBER)] testData = [] testLabel = [] testPoint = [] for bingResult in bingResults: score, xmin, ymin, xmax, ymax = bingResult score, xmin, ymin, xmax, ymax = int(score), int(xmin), int(ymin), int(xmax), int(ymax) bbPoint = [xmin, ymin, xmax, ymax] bbImage = cv2.resize(image[ymin:ymax,xmin:xmax], (self.__imageSize, self.__imageSize)) if Common.maxInterUnio(bbPoint, annotation) >= 0.5: bbLabel = self.__classConfig["car"] else: bbLabel = self.__classConfig["none"] testData.append(bbImage) testLabel.append(bbLabel) testPoint.append(bbPoint) testData = np.asarray(testData).astype(np.float32).transpose(0,3,1,2) / 255 testLabel = np.asarray(testLabel).astype(np.int32) testPoint= np.asarray(testPoint).astype(np.int32) return testData, testLabel, testPoint, image, annotation