Skip to main content

pyfld

Project description

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]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfld-0.4.6.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

pyfld-0.4.6-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file pyfld-0.4.6.tar.gz.

File metadata

  • Download URL: pyfld-0.4.6.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for pyfld-0.4.6.tar.gz
Algorithm Hash digest
SHA256 383d8636c9d1a96dfb5c178cde2f5119d4a4ab91980d6f2a9b1f4db668228b78
MD5 6a463f9d788cd1a1e7aa337147eeda46
BLAKE2b-256 fbc6b4011b3d326e06b6e40920a16737b76ad9581a77e105ae15efa1cf611dca

See more details on using hashes here.

File details

Details for the file pyfld-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: pyfld-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for pyfld-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e19c6fd41f71ab6990e5426a5add9c4b496791fd7b80a6573ec1ca10786cff9a
MD5 708db77750842e3219008fb54e5c7861
BLAKE2b-256 8d52d8fbdac2b4e150f1e7db85791b85f8e7aa9f3f411d97944e327a56820a39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page