Visualize the OpenCV Canny Edge Detection results from a live camera stream.
In this example, the results of the OpenCV Canny Edge Detection algorithm are visualized. Canny Edge Detection is a popular edge detection algorithm, and can efficiently extract important structural information from visual objects while notably reducing the computational load. The process in this example involves converting the input image to RGB, then to grayscale, and finally applying the Canny Edge Detector for precise edge detection.
The visualization in this example were created with the following Rerun code:
The original image is read and logged in RGB format under the entity "image/rgb".
# Log the original image rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) rr.log("image/rgb", rr.Image(rgb))
The input image is converted from BGR color space to grayscale, and the resulting grayscale image is logged under the entity "image/gray".
# Convert to grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) rr.log("image/gray", rr.Image(gray))
The Canny edge detector is applied to the grayscale image, and the resulting edge-detected image is logged under the entity "image/canny".
# Run the canny edge detector canny = cv2.Canny(gray, 50, 200) rr.log("image/canny", rr.Image(canny))
To run this example, make sure you have the Rerun repository checked out and the latest SDK installed:
# Setup pip install --upgrade rerun-sdk # install the latest Rerun SDK git clone git@github.com:rerun-io/rerun.git # Clone the repository cd rerun git checkout latest # Check out the commit matching the latest SDK release
Install the necessary libraries specified in the requirements file:
pip install -e examples/python/live_camera_edge_detection
To experiment with the provided example, simply execute the main Python script:
python -m live_camera_edge_detection # run the example
If you wish to customize it, explore additional features, or save it use the CLI with the --help
option for guidance:
python -m live_camera_edge_detection --help