Welcome to Jetson AGX Thor repository
11.Add line segments
Add line segments
1. Implementation principle
Use cv2.line() function to draw a short line on the image.
2. Implementation effect
cd ~/opencv
xxxxxxxxxxpython3 11.image_draw_line.py
Note: Select the image and press q to exit the program!

3. Implementation code
ximport cv2def draw_line(input_path, output_path, start_point, end_point, color, thickness):image = cv2.imread(input_path)if image is None:print("Error: Unable to open image file.")returncv2.line(image, start_point, end_point, color, thickness)if cv2.imwrite(output_path, image):print(f"Image saved to {output_path}")cv2.imshow('Image Preview', cv2.imread(output_path))cv2.waitKey(0)cv2.destroyAllWindows()else:print("Error: Unable to save image file.")draw_line('/home/jetson/opencv/images/yahboom_logo.png', \'/home/jetson/opencv/images/yahboom_logo_line.png', \(50, 150), (700, 150), (0, 0, 255), 5)