Определение поворота узора на изображении с низким разрешением - PullRequest
1 голос
/ 05 августа 2020

В настоящее время я работаю над методом отслеживания физических устройств на поверхности с помощью датчика мыши. На поверхности напечатан уникальный точечный узор на основе тора Де-Брюжена (https://en.wikipedia.org/wiki/De_Bruijn_torus). Этот шаблон состоит из уникальных подшаблонов, поэтому положение устройства можно точно определить. Датчик мыши, встроенный в устройство, записывает изображение в оттенках серого размером 36 на 36 пикселей. Размер каждой точки напечатанного рисунка на этом изображении составляет примерно 6 на 6 пикселей.

Device on the dot pattern. Display shows what the sensor sees.

Calculating the position is already possible, but the device has to be aligned to the pattern pretty exactly for it to work. Thus, I'd like to find out the angle of the pattern in the sensor image so I can rotate the image before calculating the position.

Depiction of the problem.

In this image you can see what I have (top row: raw sensor images, 1-3 aligned at 0 degrees, 4-6 rotated) and what I ideally need (bottom two, scaled for better visibility). I'd like to find the border lines of the pattern's dots and use those to find the rotation of the device.

I'm by no means an expert in image processing so I hope you can help me with my problem. I have already tried a lot of different approaches including different thresholding methods, hough lines, upscaling, finding contours and edge detection - each with more or less disappointing results (like 20-30% success rate).

All of my past approaches kind of followed the same recipe:

  • preprocess image (threshold, noise removal)
  • find edges
  • draw lines on edges
  • calculate angle of each found line
  • select most prominent angle

The biggest problem seems to be the very low resolution of the sensor image.

I don't need the exact angle, 5-10 degrees off should be ok. I also know it's impossible to distinguish 0, 90, 180 and 270 degrees, but that's not a problem because I can find out the correct one by trial and error.

Thanks in advance!

Edit: Here are some sensor images in original resolution. The red lines indicate the rotation (something like that is what I want).

The first three images are not rotated so tracking works fine:

enter image description here enter image description here enter image description here

enter image description here enter image description here enter image description here

The next three images are rotated, so I have to find out the angle. They are all rotated by about 30-50 degrees.

enter image description here enter image description here enter image description here

enter image description here enter image description here введите описание изображения здесь

...