🐛 Add support for additional detection function versions in horizontal line alignment. Implement version checks for functions 3 and 4, and handle errors for unspecified detection versions. Improve code clarity and maintainability.
This commit is contained in:
		
							parent
							
								
									e427be6cb9
								
							
						
					
					
						commit
						8ef996ee94
					
				@ -144,6 +144,23 @@ def align_to_horizontal_line(ctrl, msg, observe=False, max_attempts=3, detect_fu
 | 
			
		||||
                delay=1000 if observe else 0,
 | 
			
		||||
                save_log=True
 | 
			
		||||
            )
 | 
			
		||||
        elif detect_func_version == 3:
 | 
			
		||||
            edge_point_after, edge_info_after = detect_horizontal_track_edge_v3(
 | 
			
		||||
                ctrl.image_processor.get_current_image(), 
 | 
			
		||||
                observe=observe, 
 | 
			
		||||
                delay=1000 if observe else 0,
 | 
			
		||||
                save_log=True
 | 
			
		||||
            )
 | 
			
		||||
        elif detect_func_version == 4:
 | 
			
		||||
            edge_point_after, edge_info_after = detect_furthest_horizontal_intersection(
 | 
			
		||||
                ctrl.image_processor.get_current_image(), 
 | 
			
		||||
                observe=observe, 
 | 
			
		||||
                delay=1000 if observe else 0,
 | 
			
		||||
                save_log=True
 | 
			
		||||
            )
 | 
			
		||||
        else:
 | 
			
		||||
            error("未指定检测版本,请检查参数", "失败")
 | 
			
		||||
            return False
 | 
			
		||||
        
 | 
			
		||||
        if edge_info_after and "slope" in edge_info_after:
 | 
			
		||||
            current_slope = edge_info_after["slope"]
 | 
			
		||||
@ -187,6 +204,7 @@ def align_to_horizontal_line(ctrl, msg, observe=False, max_attempts=3, detect_fu
 | 
			
		||||
    
 | 
			
		||||
    return aligned
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def calculate_distance_to_line(edge_info, camera_height, camera_tilt_angle_deg=0, observe=False):
 | 
			
		||||
    """
 | 
			
		||||
    根据相机参数和图像中横线位置计算相机到横线的实际距离
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user