def from_json(cls, data): ''' The function from_json convert Rectangle from json format to Rectangle class object. If json format is not correct it generate exception error. :param data: input Rectangle in json format :return: Rectangle class object ''' validation.validate_geometry_points_fields(data) labeler_login = data.get(LABELER_LOGIN, None) updated_at = data.get(UPDATED_AT, None) created_at = data.get(CREATED_AT, None) sly_id = data.get(ID, None) class_id = data.get(CLASS_ID, None) exterior = data[POINTS][EXTERIOR] if len(exterior) != 2: raise ValueError( '"exterior" field must contain exactly two points to create Rectangle object.' ) [top, bottom] = sorted([exterior[0][1], exterior[1][1]]) [left, right] = sorted([exterior[0][0], exterior[1][0]]) return cls(top=top, left=left, bottom=bottom, right=right, sly_id=sly_id, class_id=class_id, labeler_login=labeler_login, updated_at=updated_at, created_at=created_at)
def from_json(cls, data): validation.validate_geometry_points_fields(data) exterior = data[POINTS][EXTERIOR] if len(exterior) != 1: raise ValueError( '"exterior" field must contain exactly one point to create "PointLocation" object.' ) return cls(row=exterior[0][1], col=exterior[0][0])
def from_json(cls, data): validation.validate_geometry_points_fields(data) exterior = data[POINTS][EXTERIOR] if len(exterior) != 2: raise ValueError( '"exterior" field must contain exactly two points to create Rectangle object.' ) [top, bottom] = sorted([exterior[0][1], exterior[1][1]]) [left, right] = sorted([exterior[0][0], exterior[1][0]]) return cls(top=top, left=left, bottom=bottom, right=right)
def from_json(cls, data): ''' The function from_json convert PointLocation from json format to PointLocation class object. :param data: input PointLocation in json format :return: PointLocation class object ''' validation.validate_geometry_points_fields(data) exterior = data[POINTS][EXTERIOR] if len(exterior) != 1: raise ValueError( '"exterior" field must contain exactly one point to create "PointLocation" object.' ) return cls(row=exterior[0][1], col=exterior[0][0])
def from_json(cls, data): validation.validate_geometry_points_fields(data) labeler_login = data.get(LABELER_LOGIN, None) updated_at = data.get(UPDATED_AT, None) created_at = data.get(CREATED_AT, None) sly_id = data.get(ID, None) class_id = data.get(CLASS_ID, None) return cls(exterior=row_col_list_to_points(data[POINTS][EXTERIOR], flip_row_col_order=True), sly_id=sly_id, class_id=class_id, labeler_login=labeler_login, updated_at=updated_at, created_at=created_at)
def from_json(cls, data): ''' The function from_json convert Poligon from json format to Poligon class object. If json format is not correct it generate exception error. :param data: input Poligon in json format :return: Poligon class object ''' validation.validate_geometry_points_fields(data) labeler_login = data.get(LABELER_LOGIN, None) updated_at = data.get(UPDATED_AT, None) created_at = data.get(CREATED_AT, None) sly_id = data.get(ID, None) class_id = data.get(CLASS_ID, None) return cls(exterior=row_col_list_to_points(data[POINTS][EXTERIOR], flip_row_col_order=True), interior=[row_col_list_to_points(i, flip_row_col_order=True) for i in data[POINTS][INTERIOR]], sly_id=sly_id, class_id=class_id, labeler_login=labeler_login, updated_at=updated_at, created_at=created_at)
def from_json(cls, data): validation.validate_geometry_points_fields(data) labeler_login = data.get(LABELER_LOGIN, None) updated_at = data.get(UPDATED_AT, None) created_at = data.get(CREATED_AT, None) sly_id = data.get(ID, None) class_id = data.get(CLASS_ID, None) exterior = data[POINTS][EXTERIOR] if len(exterior) != 2: raise ValueError( '"exterior" field must contain exactly two points to create Rectangle object.' ) [top, bottom] = sorted([exterior[0][1], exterior[1][1]]) [left, right] = sorted([exterior[0][0], exterior[1][0]]) return cls(top=top, left=left, bottom=bottom, right=right, sly_id=sly_id, class_id=class_id, labeler_login=labeler_login, updated_at=updated_at, created_at=created_at)
def from_json(cls, data): validation.validate_geometry_points_fields(data) return cls(exterior=row_col_list_to_points(data[POINTS][EXTERIOR], flip_row_col_order=True), interior=[row_col_list_to_points(i, flip_row_col_order=True) for i in data[POINTS][INTERIOR]])