HoughLinesP

cv::HoughLinesP is an OpenCV function that implements the Probabilistic Hough Transform to detect line segments in an image (unlike the classic HoughLines which finds infinite lines).
Download TouchDesigner version on my Patreon


It directly returns the start and end points of each detected segment (x1,y1,x2,y2), making it much more practical and widely used for real-world applications such as lane detection, document scanning, or contour analysis.
How it works in TouchDesigner
A Script OP takes a TOP texture as input, runs edge detection and cv::HoughLinesP on each frame, and outputs the endpoints of detected segments as structured data. Those coordinates can then be rendered as geometry: every frame of a live video becomes a set of straight strokes that follow the structure of the scene.
Key parameters to tune:
- threshold — minimum number of votes for a candidate line; higher values keep only strong, well-defined lines.
- minLineLength — segments shorter than this are discarded.
- maxLineGap — maximum gap between points allowed to merge them into one segment.
But if you use a proximity node, you can get an interesting effect — nearby endpoints get connected into web-like structures, turning a technical detector into an abstract generative drawing:

Use cases
- Generative abstraction — reducing live video to its linear skeleton, in the tradition of constructivist and suprematist forms.
- Live AV visuals — line structures reacting to camera input in real time.
- Machine vision studies — a visual way to understand how the Hough transform reads an image.
