Direct Step Edge Detection
Project description
Direct Step Edge Follower
DSEF Package
The Direct Step Edge Follower (DSEF) is a edge-following algorithm designed for high-precision edge detection with low computational cost. It employs stepwise directional refinement and kernel-based statistical testing to enhance accuracy, particularly in challenging lighting conditions.
Citation
To cite DSEF in your research, please cite as:
@article{Sivertsen2025DSEF,
author = {Agnar Sivertsen and Fabio A. A. Andrade and Marcos Moura and Carlos A. M. Correia and Mariane R. Petraglia},
title = {Direct Step Edge Follower: a novel edge follower algorithm applied to solar panels inspections with Unmanned Aerial Vehicles},
journal = {Preprint},
year = {2025},
month = {April},
url = {https://www.researchgate.net/publication/390370984_Direct_Step_Edge_Follower_a_novel_edge_follower_algorithm_applied_to_solar_panels_inspections_with_Unmanned_Aerial_Vehicles}
}
How to use
Simple Implementation of DSEF Code to search for the closest line in an example image. Full example can be seen here.
Imports
import sys
import os
import cv2
import matplotlib.pyplot as plt
import dsef
Load Image
image_path = 'imgs/input_image.jpg'
if not os.path.isfile(image_path):
raise FileNotFoundError(f"Image '{image_path}' not found.")
img = cv2.imread(image_path)
# Convert the image from BGR (OpenCV default) to RGB (matplotlib default)
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Plot the image using matplotlib
plt.imshow(img_rgb)
plt.axis('off') # Hide the axes
plt.show()
Initiate DSEF Class
initial_direction_deg = 270 # The initial direction in degrees
dir_span = 90 # The span of directions for search
start_pix = (0+200, 0+200) # Starting pixel (x, y)
end_pix = (1920, 1080) # Ending pixel (x, y)
speed = "medium" # Speed of the algorithm, "high", "medium", or "low"
debug = True
dsef_ = dsef.Dsef(initial_direction_deg, dir_span, start_pix, end_pix, speed, debug)
Edge Search
The dots in the image below represents the steps of the algorithm
## Perform edge search
edge_found, img = dsef_.edge_search(img)
if edge_found:
print(f"Edge found: {edge_found}")
# Convert the image from BGR (OpenCV default) to RGB (matplotlib default)
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Plot the image using matplotlib
plt.imshow(img_rgb)
plt.axis('off') # Hide the axes
plt.show()
[DEBUG] Overriding d_theta to: 4.0
[DEBUG] Distance between start and end: 1932.0455481173315
[DEBUG] Search step: 32.200759135288855
[DEBUG] Follower step: 22.029071700822982
[DEBUG] Edge found. Breaking EdgeSearch.
Edge found: True
Edge Follow
The dots parallel to the edge of the rectangle shows the following path of DSEF algorithm
found_edge_line = None
if edge_found:
# if the search found an edge, follow it
found_edge_line, image = dsef_.edge_follow(img)
print(f"Found edge line [(x1,y1),(x2,y2)]: {found_edge_line}")
# Convert the image from BGR (OpenCV default) to RGB (matplotlib default)
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# Plot the image using matplotlib
plt.imshow(img_rgb)
plt.axis('off') # Hide the axes
plt.show()
[DEBUG] Distance between start and end: 1932.0455481173315
[DEBUG] Search step: 32.200759135288855
[DEBUG] Follower step: 22.029071700822982
[DEBUG] EdgeFollow message: CANCEL. WE LOST THE EDGE
Found edge line [(x1,y1),(x2,y2)]: [(522, 380), (-17152.38437246058, 3496.470832276853)]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsef-0.2.0.tar.gz.
File metadata
- Download URL: dsef-0.2.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
273166458bc6b2560c808cda8f631fa4796f24ca567197158a8fbf6361492f7a
|
|
| MD5 |
01d2ba6c7fe0e2c865e8237d2883fb66
|
|
| BLAKE2b-256 |
38e84d9c3c0a0dd5a642e9dc90761bb039493c2c1f4fa9bb21a98e1d69e27f48
|
File details
Details for the file dsef-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dsef-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d862b3dfdd773bc267116b1004971a7a9a75ab738d45886baff49ba80900d76d
|
|
| MD5 |
3fdd4fc2b734bdf41657262e665a6484
|
|
| BLAKE2b-256 |
a4b2b9f2e064ab2a3a98f3dbc7f3ea10b3e94740ff866a911b1429664210a9cc
|