Hi there,

i am trying to find a way to calculate the angle of vertical lines against horizontal lines on a cloth.

this is the best image i think without any filter:

and this the final image with some mean adaptive threshold:

and then calculate the angle:

do you have any idea where to start?

best regards…

and here is the best with different setup of lighting:

and then some filtering:

to calculate the angle…:

which is the best ?

We did something similar, create a vector from a known point. Then it is quite simple to calculate the angle using the .math features.

The difficulty is trying to find the crossing point, because if you have that you would be able to create 2 vectors with the find lines? Or something similar?

in fact i want to measure the angle of vertical lines only . horizontal lines will be 0 degrees all the time.

The job is to find the vertical lines with find lines tool and measure that angle regarding the y axis. Completely vertical line will be 0 degrees . so must get negative and positive values if lines are slightly left or right of the y -axis.

Thinking that i dont have good lines to make this work properly thought.

And unfortunately cant take better pictures.

Do you think that is this possible with these images?

think that the second setup is better for this…

think getting closer regarding the image.

But still cannot measure the tilt of the vertical lines…

i drawn a cross with lines so to be able to see better the tilt too…

and the below image is from diferent cloth with almost 0degrees tilt on the vertical lines

cant resolve the issue i have with the find lines tool.

it keeps finding unnecessary lines.

In picture below i have set the tool to a region in the center only.

the only way i can keep the lines i want is too filter out lines depending on the angle.do you think that is possible to find the correct lines and then meausure its angle?

the image below shows what i want to do but in this image i filtered out the lines that aren’t the right angle…

then i want to get the mean angle of the found lines. Is there any possibility for this to work?

the colors in the image is a colorize filter so to see the found lines better. i use global shutter module for this project…

it seems that cant find lines at all with segments tool.

If i try find_line_segments to original image can find lines but almost everywhere.

But if i try to use it in the filtered image not even a single line…

Do i miss something?

The tool has only 2 parameters of filtering…

do i have tro think a different approach of inspection?

I guess find_lines() is then the best for this.

Turn off all the joining features and you should get the results you want.

cant figured this out unfortunately.

is there any feature of pattern matching so to teach a pattern and then get its rotation?

So, for find_lines… have you printed out the magnitude for the lines and tried displaying only the highest magnitude ones?

I think you almost have the solution with find_lines(). You just need to filter by their strength.

yeap,

thought that this will be an easy one but get find a way to make it work proper.

i used a clear image to get this working but still nothing…

i am trying to do some filtering with all the find lines output …

```
min_degree = 0
max_degree = 180
min_length = 50
max_length = 5000
min_magnitude = 100
max_magnitude = 50000
```

```
line_list = img.find_lines(x_stride=1,y_stride=2,threshold = 500, theta_margin = 25, rho_margin = 25)
for l in line_list:
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
if (min_length <= l.length()) and (l.length() <= max_length):
if (min_magnitude <= l.magnitude()) and (l.length() <= max_magnitude):
img.draw_line(l.line(), color = 100)
```

today i have better results now with segments:

```
min_degree = 0
max_degree = 180
min_length = 10
max_length = 5000
min_magnitude = 10
max_magnitude = 50000
```

```
line_list = img.find_line_segments(roi=(roi1),merge_distance = 2, max_theta_diff = 2)
for l in line_list:
if (min_degree <= l.theta()) and (l.theta() <= max_degree):
if (min_length <= l.length()) and (l.length() <= max_length):
if (min_magnitude <= l.magnitude()) and (l.length() <= max_magnitude):
img.draw_line(l.line(), color = 50)
```

how to store all the found lines and get the mean angle?

the list contains all the lines that have export the tool.

So i must store the found lines under the img.draw_line(l.line(), color = 50) line.

Then take the mean theta() value of them .

This is just pure Python programming.

1 Like