vendredi 21 juin 2024

Hough Transformation

The Hough Transformation is a great way to detect lines in an image. You will find here https://www.keymolen.com/2013/05/hough-transformation-c-implementation.html a very nice explanation of the method. Thanks to Bruno Keymolen for sharing his C++ code. With Red language we have two ways for using the Hough transformation. First is to call OpenCV method as illustrated in %OpenCV3-red/samples_gui.red/hough samples. 

A second way is to use the code in %RedCV/samples/image_detectors. hough1.red and hough2.red illustrate the implementation in RedCV. Hough1 only uses a Canny filter for edges detection. Hough2 includes a series of edges filters to creates a BW image with lines and points representing the edges. The program gives the number of detected lines, here 9, which are visualised in the original image.


As usual, this kind of algorithm requires a fine tuning of parameters that must be adapted to your needs. Enjoy 😀







mardi 18 juin 2024

OpenCV3-red

A few days ago, I went back to the OpenCV3-red code I wrote more than 10 years ago at the start of Red's development. A pleasant surprise: the code is still operational. The only thing I had to change was the definition of a pointer: 

#define p-buffer!   [struct! [buffer [c-string!]] which conflicted with the structure defined in call.reds: 

p-buffer!: alias struct! [ ;-- Data buffer struct, pointer and bytes count

count [integer!]

buffer [byte-ptr!]

]

 

Then you can carry on playing with this code, which gives access to over 600 OpenCV functions!

The code is here: https://github.com/ldci/OpenCV3-red