A Hough Transform Toolbox Based on Virtual Grids
Project description
HoughVG : Hough transform on Virtual Grids: Hough transform toolbox for straight-lines detection and fingerprints recognition
HoughVG is a Virtual Grid-Based Hough transform toolbox for straight-lines detection and fingerprints recognition. It brings together several innovative variants of the Virtual Grid-Based Hough transform, including the rectangular, triangular, hexagonal and octagonal Hough transforms for straight-line detection, as well as the generalized Hough transform using virtual rectangular grid, specially adapted for fingerprint recognition.
This version of HoughVG is implemented in C++ and exposed to Python using nanobind.
At this stage, fingerprint recognition and parallel processing are not yet available in this release. These features will be added in a future version.
Installation From PyPI
Install the package with pip:
python -m pip install houghvg
Usage
Straight-lines detection
import time
import cv2
import houghvg
import numpy as np
PI = np.pi
IMAGE_PATH = "univ.PNG"
THRESHOLD = 31
def draw_hough_lines(image, lines, color):
output = image.copy()
if lines is None:
return output
for line in lines:
rho = float(line[0])
theta = float(line[1])
cos_theta = np.cos(theta)
sin_theta = np.sin(theta)
pt1 = (
int(round(rho * cos_theta + 1000 * (-sin_theta))),
int(round(rho * sin_theta + 1000 * cos_theta)),
)
pt2 = (
int(round(rho * cos_theta - 1000 * (-sin_theta))),
int(round(rho * sin_theta - 1000 * cos_theta)),
)
cv2.line(output, pt1, pt2, color, 2, cv2.LINE_AA)
return output
def main():
image = cv2.imread(str(IMAGE_PATH), cv2.IMREAD_COLOR)
if image is None:
raise RuntimeError(f"Impossible de charger {IMAGE_PATH}")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 200)
t0 = time.perf_counter()
houghvg_lines = houghvg.HoughLines(
edges,
grid_type=houghvg.GridType.OCTOGONAL,
rho=1.0,
theta=PI / 180.0,
threshold=THRESHOLD,
cell_width_base=4.0,
cell_height=5.0,
gamma=2.0,
rate=0.4,
use_parallel=False,
return_numpy=True,
)
img_houghvg_lines = draw_hough_lines(image, houghvg_lines[:, :2], (0, 255, 0))
cv2.imshow("HoughVG : Detected lines", img_houghvg_lines)
print("Appuie sur une touche dans une fenetre OpenCV pour fermer.")
cv2.waitKey(0)
cv2.destroyAllWindows()
Features
- Rectangular, triangular, hexagonal, and octagonal virtual grids.
- Python bindings built with nanobind.
- Optional NumPy return mode:
return_numpy=Truereturns anNx3float32array containing[rho, theta, votes]. - Example script comparing
houghvg.HoughLinesandcv2.HoughLinesvisually and temporally.
Requirements
This package contains a native C++ extension. The current Windows build links against OpenCV 4.9
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 houghvg-0.2.0.tar.gz.
File metadata
- Download URL: houghvg-0.2.0.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88c738b55cbaa8b90d9ced8c99e06098e1f23730a6f93aa2cabbdcbf8504dca1
|
|
| MD5 |
584487fa3150c0c57af7ff76c84db385
|
|
| BLAKE2b-256 |
e3016d3e3f1bb215025cb4c68af40c961c3a59c93ac284b030eb706cd2cec582
|
File details
Details for the file houghvg-0.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: houghvg-0.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 23.9 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05023fefaf25e75241a22a2e4d128a91198abd9709cb7d398bb7c3232232d652
|
|
| MD5 |
1b10cb705c8314b13e671f64ac29cce7
|
|
| BLAKE2b-256 |
fc3049d7404fa648d74a47717db451b6878736ccd8827ce5036dff8b3e178c86
|