How to detect and calculate the angle of an object inside a python image?

Asked

Viewed 61 times

0

I’m trying to write a code that detects lines and calculates an angle within a binary image (not necessarily this one, but always a similar spray). I read a few things about Hough Transform and even Scalar Product, but I can’t apply them.

inserir a descrição da imagem aqui

For now I have this code only:

import cv2 
import numpy as np  
import math
import matplotlib.pyplot as plt

img_grey = cv2.imread('sprayang.jpg', cv2.IMREAD_GRAYSCALE)
img = cv2.GaussianBlur (img_grey, (5,5), 0)

th = 0
max_val = 255

    ret, o1 = cv2.threshold(img, th, max_val, cv2.THRESH_BINARY + cv2.THRESH_OTSU )

That gives me that image: inserir a descrição da imagem aqui

Using the Imagej angle tool, in this image, I read 90°.

  • what is the doubt?

  • Precise, in python, to detect an opening angle in an image (a spray, like the one in the example) and calculate it.

  • Imagej angle tool does not serve?

  • Yes, Flavio. But I would like to create something to detect and calculate the angle without the need to create the manual stitches to identify the lines. Basically open the file, run and result in °.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.