Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

323
Visualizações
Circular objects rotate angle detection

I'm trying to detect angle difference between two circular objects, which be shown as 2 image below.

I'm thinking about rotate one of image with some small angle. Every time one image rotated, SSIM between rotated image and the another image will be calculated. The angle with maximum SSIM will be the angle difference.

But, finding the extremes is never an easy problem. So my question is: Are there another algorithms (opencv) can be used is this case?

IMAGE #1 Master image

IMAGE #2 enter image description here

EDIT:

Thanks @Micka, I just do the same way he suggest and remove black region like @Yves Daoust said to improve processing time. Here is my final result:

ORIGINAL IMAGE image 1 ROTATED + SHIFTED IMAGE image 2

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Here's the same idea but the correlation is done with a convolution (FFT) instead of matchTemplate. FFTs can be faster if there's much data.

Load inputs:

im1 = cv.imread("circle1.jpg", cv.IMREAD_GRAYSCALE)
im2 = cv.imread("circle2.jpg", cv.IMREAD_GRAYSCALE)
height, width = im1.shape

Polar transform (log polar as an exercise to the reader) with some arbitrary parameters that affect "resolution":

maxradius = width // 2

stripwidth = maxradius
stripheight = int(maxradius * 2 * pi) # approximately square at the radius
#stripheight = 360

def polar(im):
    return cv.warpPolar(im, center=(width/2, height/2),
        dsize=(stripwidth, stripheight), maxRadius=maxradius,
        flags=cv.WARP_POLAR_LOG*0 + cv.INTER_LINEAR)

strip1 = polar(im1)
strip2 = polar(im2)

Convolution:

f1 = np.fft.fft2(strip1[::-1, ::-1])
f2 = np.fft.fft2(strip2)
conv = np.fft.ifft2(f1 * f2)

minmaxloc:

conv = np.real(conv) # or np.abs, can't decide
(i,j) = np.unravel_index(conv.argmax(), conv.shape)
i,j = (i+1) % stripheight, (j+1) % stripwidth

and what's that as an angle:

print("degrees:", i / stripheight * 360)
# 42.401091405184175

https://gist.github.com/crackwitz/3da91f43324b0c53504d587a394d4c71

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda