Skip to main content

pyfld

Build Status Coverage Status PyPI version

Python package for detecting line segments from images.

In order to extract line segments, Lee et al. (2014) devised a simple but reliable extractor inspired from Bay et al. (2005). Lee et al. (2014) described it as follows.

Given an image, Canny edges are detected first and the system extracts line segments as follows: At an edge pixel the extractor connects a straight line with a neighboring one, and continues fitting lines and extending to the next edge pixel until it satisfies co-linearity with the current line segment. If the extension meets a high curvature, the extractor returns the current segment only if it is longer than 20 pixels, and repeats the same steps until all the edge pixels are consumed. Then with the segments, the system incrementally merges two segments with length weight if they are overlapped or closely located and the difference of orientations is sufficiently small.

This package is designed to allow fine tuning of parameters based on this approach.

Instration

The currently recommended method of installation is via pip:

pip install pyfld

pyfld can also be installed by cloning the GitHub repository:

git clone https://github.com/tsukada-cs/pyfld
cd pyfld
pip install .

Dependencies

  • numpy >= 1.17.3
  • opencv-coontrib-python >= 2.4

Sample Usage

Standard use case:

import numpy as np
from PIL import Image

from pyfld import FastLineDetector

img = Image.open("sample.png")
img = np.asarray(img.convert("L"))

length_threshold = 10
distance_threshold = 1.41421356
canny_th1 = 50
canny_th2 = 50
canny_aperture_size = 3
do_merge = False

fld = FastLineDetector(length_threshold, distance_threshold, canny_th1, canny_th2, canny_aperture_size, do_merge)
(x1, y1, x2, y2), _ = fld.detect(img)

If the img is already binarized, set canny_aperture_size=0. Then, the Canny method is not used, and line segment detection is performed directly on the input image.

Example of line segment visualization:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.imshow(img, cmap="gray")
ax.plot([x1, x2], [y1, y2], c="r")
plt.show()
FLD_output

Reference

  • J. Han Lee, S. Lee, G. Zhang, J. Lim, W. Kyun Chung, I. Hong Suh. "Outdoor place recognition in urban environments using straight lines." In 2014 IEEE International Conference on Robotics and Automation (ICRA), pp.5550–5557. IEEE, 2014. [Link to PDF]
  • H. Bay, V. Ferraris, and L. Van Gool, “Wide-Baseline Stereo Matching with Line Segments.” In Proc. of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), vol.1, no., pp.329-336, June 2005. [Link to PDF]

Metadata

Release files for pyfld 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfld 0.6.1
File Size Uploaded
pyfld-0.6.1.tar.gz 22.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfld 0.6.1
File Interpreter ABI Platform
pyfld-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.7 kB

Release files / pyfld-0.6.1.tar.gz

Download URL pyfld-0.6.1.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eb3191523d0126c30a67de7e34e7ad6db4243251f8b2967db88f0c22ec2e870e
BLAKE2b-256 checksum
How to use checksums
363c9dbc39ba88ee64ec33bcf6b38775d6869506022a0b9f9701c3e5f1bbae14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release files / pyfld-0.6.1-py3-none-any.whl

Download URL pyfld-0.6.1-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c4d4ec5df3c2d3901a536277be89c2462ca27f722345bfbc76fe2553087eea5
BLAKE2b-256 checksum
How to use checksums
5e367a4a0b540fb83f9b0133ce2403ac91bc155ef90ae7dd49e938d6f3516247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.5.2

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.11

1 release file

0.2.10

1 release file

0.2.8

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page