对于一些特殊场景和仪表数量较少时比较适合。
一 找出目标区
通过labelme 将仪表范围框出来,并进行转换:
data = json.load(open(mask_path, encoding='utf-8'))
shapes = data['shapes']target_label = '1'for shape in shapes:label = shape['label']if label == target_label:points = [[float(x[0]), float(x[1])] for x in shape['points']]points = np.float32(sort_points(points))elif label == '2':aim_points = [[float(x[0]), float(x[1])] for x in shape['points']]aim_points = np.float32(sort_points(aim_points))elif label == '3':angle_points = [[float(round(x[0])), float(round(x[1]))] for x in shape['points']]angle_points = np.float32(angle_points)
二 角度转换
2.1 points 排序
def sort_points_angle(points, meter_number, frame):"""根据角度排序"""meter_number = [0, 0.5, 1, 1.5]# print('points:', points)center_point = find_center_point(points)# print('center point:', center_point)other_points = [point for point in points if not np.all(point =&#