class VariableHousingCam3CropCRectangleTopSide: BBOX_LIST = [ BoundingBox(x_st=386, x_ed=386 + 461, y_st=182, y_ed=182 + 492), BoundingBox(x_st=1561, x_ed=1561 + 461, y_st=182, y_ed=182 + 492) ] BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1205, 1062) BOUNDARY_CIRCLE_RAD = 757 FLIP_INDEX = 0
class VariableHousingCam3CropCRectangleWithRing: BBOX_LIST = [ BoundingBox(x_st=1842, x_ed=1842 + 476, y_st=824, y_ed=824 + 476), BoundingBox(x_st=1049, x_ed=1049 + 476, y_st=1707, y_ed=1707 + 476), BoundingBox(x_st=79, x_ed=79 + 476, y_st=831, y_ed=831 + 476) ] ANGLE_LIST = [0, 90, 180] BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1205, 1062) BOUNDARY_CIRCLE_RAD = 757
class VariableHousingCam1CropDOuterRectangleWithRing: BBOX_LIST = [ BoundingBox(x_st=1822, x_ed=1822 + 500, y_st=780, y_ed=780 + 500), BoundingBox(x_st=850, x_ed=850 + 500, y_st=1646, y_ed=1646 + 500), BoundingBox(x_st=72, x_ed=72 + 500, y_st=766, y_ed=766 + 500) ] ANGLE_LIST = [0, 90, 180] BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1250, 987) BOUNDARY_CIRCLE_RAD = 710
class VariableHousingCam1CropDOuterRectangleTop: ENTIRE_X_ST = 598 ENTIRE_X_ED = 598 + 1184 ENTIRE_Y_ST = 132 ENTIRE_Y_ED = 132 + 368 BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1250, 987) BOUNDARY_CIRCLE_RAD = 710 FLIP_INDEX = 0 __HALF_X = (ENTIRE_X_ST + ENTIRE_X_ED) // 2 BBOX_LIST = [ BoundingBox(x_st=ENTIRE_X_ST, x_ed=__HALF_X, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED), BoundingBox(x_st=__HALF_X, x_ed=ENTIRE_X_ED, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED) ]
def __getitem__(self, idx): eop_data = EOPData(serial_number=self.serial_number_list[idx], image_path=self.image_path_list[idx], is_NG=self.is_NG_list[idx], cam=self.cam_list[idx], defect_list=None) defect_list = list() # 만약 결함이 있으면 defect 추가 if eop_data.is_NG: for defect_category, x_st, x_ed, y_st, y_ed, ratio in \ zip(self.defect_category_lists[idx], self.x_st_lists[idx], self.x_ed_lists[idx], self.y_st_lists[idx], self.y_ed_lists[idx], self.ratio_lists[idx]): defect_abst_bbox = BoundingBox(x_st=x_st, x_ed=x_ed, y_st=y_st, y_ed=y_ed) defect_abst_bbox.calculate_with_ratio(ratio) defect = Defect(abst_bbox=defect_abst_bbox, category=defect_category, location_img=eop_data.img_object) defect_list.append(defect) eop_data.defect_list = defect_list return eop_data
def __init__(self, img_object: EOPImage, center_coord: Coordinate, rad: int): super(CircleCropHelper, self).__init__(img_object) self.center_coord = center_coord self.rad = rad self.circle_abst_bbox = BoundingBox(x_st=center_coord.x - rad, x_ed=center_coord.x + rad, y_st=center_coord.y - rad, y_ed=center_coord.y + rad)
class VariableHousingCam2CropCRectangleMiddle: ENTIRE_X_ST = 402 + 740 ENTIRE_X_ED = 2658 ENTIRE_Y_ST = 404 ENTIRE_Y_ED = 126 + 926 FLIP_INDEX = 0 __HALF_X = (ENTIRE_X_ST + ENTIRE_X_ED) // 2 BBOX_LIST = [ BoundingBox(x_st=ENTIRE_X_ST, x_ed=__HALF_X, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED), BoundingBox(x_st=__HALF_X, x_ed=ENTIRE_X_ED, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED) ]
class VariableHousingCam3CropCRectangleTopMiddle: ENTIRE_X_ST = 837 ENTIRE_X_ED = 837 + 736 ENTIRE_Y_ST = 304 ENTIRE_Y_ED = 304 + 95 __HALF_X = (ENTIRE_X_ST + ENTIRE_X_ED) // 2 BBOX_LIST = [ BoundingBox(x_st=ENTIRE_X_ST, x_ed=__HALF_X, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED), BoundingBox(x_st=__HALF_X, x_ed=ENTIRE_X_ED, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED) ] BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1205, 1062) BOUNDARY_CIRCLE_RAD = 757 FLIP_INDEX = 0
class VariableHousingCam3CropCRectangleTop: ENTIRE_X_ST = 386 ENTIRE_X_ED = 1561 + 461 ENTIRE_Y_ST = 182 ENTIRE_Y_ED = 182 + 492 __HALF_X = (ENTIRE_X_ST + ENTIRE_X_ED) // 2 BBOX_LIST = [ BoundingBox(x_st=ENTIRE_X_ST, x_ed=__HALF_X, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED), BoundingBox(x_st=__HALF_X, x_ed=ENTIRE_X_ED, y_st=ENTIRE_Y_ST, y_ed=ENTIRE_Y_ED) ] BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1205, 1062) BOUNDARY_CIRCLE_RAD = 757 FLIP_INDEX = 0
def crop_ring(self, center_coord: Coordinate): center_x = center_coord.x center_y = center_coord.y crop_abst_bbox = BoundingBox(x_st=center_x - self.big_rad, x_ed=center_x + self.big_rad, y_st=center_y - self.big_rad, y_ed=center_y + self.big_rad) if self.mask is None: self.mask = self.get_ring_mask(big_rad=self.big_rad, small_rad=self.small_rad) self.cropped_img_object = EOPImage( img=self.img_object.img[crop_abst_bbox.y_st:crop_abst_bbox.y_ed, crop_abst_bbox.x_st:crop_abst_bbox.x_ed] * self.mask, abst_bbox=crop_abst_bbox) # image object 에 child 로 저장 self.img_object.add_child(self.cropped_img_object) return self.cropped_img_object
def _crop_down_part(self, img_object: EOPImage): rectangle_crop_helper = RectangleCropHelper(img_object=img_object) # Crop crop_bbox = BoundingBox( x_st=self.first_crop_x_st, x_ed=self.crop_x_ed, y_st=self.crop_y_ed, y_ed=img_object.abst_bbox.y_ed ) rectangle_crop_helper.crop_rectangle(bbox=crop_bbox) cropped_img_object = rectangle_crop_helper.cropped_img_object # Checking defect for defect in self.defect_list: defect: Defect # 해당 bbox 에 defect 가 있을 때 if defect.is_defect_in_bounding_box(bbox=crop_bbox): rectangle_crop_helper.relocate_defect( img_object=cropped_img_object, defect=defect ) return cropped_img_object
class VariableHousingCam3CropCRectangleRightDown: BBOX = BoundingBox(x_st=1525, x_ed=1525 + 435, y_st=1520, y_ed=1520 + 513) BOUNDARY_CIRCLE_CENTER_COORD = Coordinate(1205, 1062) BOUNDARY_CIRCLE_RAD = 757
class VariableHousingCam3Grid17: LEFT_UP_COORDINATE = Coordinate(x=1455, y=1517) BBOX_LIST = [ BoundingBox(x_st=1455, x_ed=1455 + 512, y_st=1517, y_ed=1517 + 512) ]
class VariableHousingCam3Grid16: LEFT_UP_COORDINATE = Coordinate(x=997, y=1649) BBOX_LIST = [ BoundingBox(x_st=997, x_ed=997 + 512, y_st=1649, y_ed=1649 + 512) ]
class VariableHousingCam3Grid14: LEFT_UP_COORDINATE = Coordinate(x=1806, y=1038) BBOX_LIST = [ BoundingBox(x_st=1806, x_ed=1806 + 512, y_st=1038, y_ed=1038 + 512) ]
class VariableHousingCam1Grid13: LEFT_UP_COORDINATE = Coordinate(x=1791, y=949) BBOX_LIST = [ BoundingBox(x_st=1791, x_ed=1791 + 512, y_st=949, y_ed=949 + 512) ]
class VariableHousingCam1Grid11: LEFT_UP_COORDINATE = Coordinate(x=27, y=993) BBOX_LIST = [ BoundingBox(x_st=27, x_ed=27 + 512, y_st=993, y_ed=993 + 512) ]
class VariableHousingCam1Grid6: LEFT_UP_COORDINATE = Coordinate(x=1459, y=644) BBOX_LIST = [ BoundingBox(x_st=1459, x_ed=1459 + 512, y_st=644, y_ed=644 + 512) ]
class VariableHousingCam1Grid2: LEFT_UP_COORDINATE = Coordinate(x=965, y=150) BBOX_LIST = [ BoundingBox(x_st=965, x_ed=965 + 512, y_st=150, y_ed=150 + 512) ]
class VariableHousingCam2Grid1: BBOX_LIST = [ BoundingBox(x_st=382, x_ed=383 + 512, y_st=116, y_ed=116 + 512) ] LEFT_UP_COORDINATE = Coordinate(x=BBOX_LIST[0].x_st, y=BBOX_LIST[0].y_st)
class VariableHousingCam1GridEntire: BBOX_LIST = [ # Square 1st BoundingBox(x_st=471, x_ed=471 + 512, y_st=150, y_ed=150 + 512), BoundingBox(x_st=965, x_ed=965 + 512, y_st=150, y_ed=150 + 512), BoundingBox(x_st=1459, x_ed=1459 + 512, y_st=150, y_ed=150 + 512), # Square 2nd BoundingBox(x_st=471, x_ed=471 + 512, y_st=644, y_ed=644 + 512), BoundingBox(x_st=965, x_ed=965 + 512, y_st=644, y_ed=644 + 512), BoundingBox(x_st=1459, x_ed=1459 + 512, y_st=644, y_ed=644 + 512), # Square 3rd BoundingBox(x_st=471, x_ed=471 + 512, y_st=1138, y_ed=1138 + 512), BoundingBox(x_st=965, x_ed=965 + 512, y_st=1138, y_ed=1138 + 512), BoundingBox(x_st=1459, x_ed=1459 + 512, y_st=1138, y_ed=1138 + 512), # Left BoundingBox(x_st=27, x_ed=27 + 512, y_st=577, y_ed=577 + 512), BoundingBox(x_st=27, x_ed=27 + 512, y_st=993, y_ed=993 + 512), # # Right BoundingBox(x_st=1791, x_ed=1791 + 512, y_st=547, y_ed=547 + 512), BoundingBox(x_st=1791, x_ed=1791 + 512, y_st=949, y_ed=949 + 512), # # Down BoundingBox(x_st=641, x_ed=641 + 512, y_st=1629, y_ed=1629 + 512), BoundingBox(x_st=1125, x_ed=1125 + 512, y_st=1629, y_ed=1629 + 512), ]
class VariableHousingCam3GridEntire: BBOX_LIST = [ # 1st layer BoundingBox(x_st=354, x_ed=354 + 512, y_st=178, y_ed=178 + 512), BoundingBox(x_st=673, x_ed=673 + 512, y_st=293, y_ed=293 + 512), BoundingBox(x_st=1140, x_ed=1140 + 512, y_st=293, y_ed=293 + 512), BoundingBox(x_st=1526, x_ed=1526 + 512, y_st=178, y_ed=178 + 512), # 2nd layer BoundingBox(x_st=116, x_ed=116 + 512, y_st=614, y_ed=614 + 512), BoundingBox(x_st=574, x_ed=574 + 512, y_st=614, y_ed=614 + 512), BoundingBox(x_st=965, x_ed=965 + 512, y_st=753, y_ed=753 + 512), BoundingBox(x_st=1345, x_ed=1345 + 512, y_st=614, y_ed=614 + 512), BoundingBox(x_st=1806, x_ed=1806 + 512, y_st=614, y_ed=614 + 512), # 3rd layer BoundingBox(x_st=116, x_ed=116 + 512, y_st=1038, y_ed=1038 + 512), BoundingBox(x_st=574, x_ed=574 + 512, y_st=1038, y_ed=1038 + 512), BoundingBox(x_st=965, x_ed=965 + 512, y_st=1190, y_ed=1190 + 512), BoundingBox(x_st=1345, x_ed=1345 + 512, y_st=1038, y_ed=1038 + 512), BoundingBox(x_st=1806, x_ed=1806 + 512, y_st=1038, y_ed=1038 + 512), # 4th layer BoundingBox(x_st=541, x_ed=541 + 512, y_st=1517, y_ed=1517 + 512), BoundingBox(x_st=997, x_ed=997 + 512, y_st=1649, y_ed=1649 + 512), BoundingBox(x_st=1455, x_ed=1455 + 512, y_st=1517, y_ed=1517 + 512) ]
class VariableHousingCam1Grid5: LEFT_UP_COORDINATE = Coordinate(x=965, y=644) BBOX_LIST = [ BoundingBox(x_st=965, x_ed=965 + 512, y_st=644, y_ed=644 + 512) ]
class VariableHousingCam3Grid1: LEFT_UP_COORDINATE = Coordinate(x=354, y=178) BBOX_LIST = [ BoundingBox(x_st=354, x_ed=354 + 512, y_st=178, y_ed=178 + 512) ]
class VariableHousingCam1Grid9: LEFT_UP_COORDINATE = Coordinate(x=1459, y=1138) BBOX_LIST = [ BoundingBox(x_st=1459, x_ed=1459 + 512, y_st=1138, y_ed=1138 + 512) ]
class VariableHousingCam3Grid3: LEFT_UP_COORDINATE = Coordinate(x=1140, y=293) BBOX_LIST = [ BoundingBox(x_st=1140, x_ed=1140 + 512, y_st=293, y_ed=293 + 512) ]
class VariableHousingCam1Grid12: LEFT_UP_COORDINATE = Coordinate(x=1791, y=547) BBOX_LIST = [ BoundingBox(x_st=1791, x_ed=1791 + 512, y_st=547, y_ed=547 + 512) ]
class VariableHousingCam3Grid7: LEFT_UP_COORDINATE = Coordinate(x=965, y=753) BBOX_LIST = [ BoundingBox(x_st=965, x_ed=965 + 512, y_st=753, y_ed=753 + 512) ]
class VariableHousingCam1Grid15: LEFT_UP_COORDINATE = Coordinate(x=1125, y=1629) BBOX_LIST = [ BoundingBox(x_st=1125, x_ed=1125 + 512, y_st=1629, y_ed=1629 + 512) ]
class VariableHousingCam3Grid9: LEFT_UP_COORDINATE = Coordinate(x=1806, y=614) BBOX_LIST = [ BoundingBox(x_st=1806, x_ed=1806 + 512, y_st=614, y_ed=614 + 512) ]