Welcome to Jetson Orin NANO Developer Kit repository
10.Image edge detection
Image Edge Detection
1. Implementation Principle
Use the cv2.Canny() function to perform edge detection on the image.
2. Implementation Effect
xxxxxxxxxxcd ~/opencv
xxxxxxxxxxpython3 10.image_edge.py
Note: click the image window and press any key to exit.

3. Implementation Code
import cv2def edge_detection(input_path, output_path, threshold1, threshold2):image = cv2.imread(input_path, cv2.IMREAD_GRAYSCALE)if image is None:print("Error: Unable to open image file.")returnedges = cv2.Canny(image, threshold1, threshold2)if cv2.imwrite(output_path, edges):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.")edge_detection('/home/jetson/opencv/images/yahboom_logo.png', \'/home/jetson/opencv/images/yahboom_logo_edge.png', \100, 200)