0

I've been working with Open-CV for a few weeks now. I'm trying to figure out how to rotate the perspective of this image so the black strap is perfectly straight up and down. I'm also trying to remove the white background from image, so the black strap is the only thing remaining. (The white holes can stay)

Black Strap

I modified my image in paint.net to show you what I want the image to eventually look like.

Vertical Strap

I have multiple similar images with straps that have slightly different angles. I am looking for an algorithm that will rotate and crop my images no matter the angle.The majority of the code examples I find online are written in python and I would prefer to continue to use c++. Any help of any kind to help me get started would be greatly appreciated. Thanks.

Extra Strap Examples: Strap 2 Strap 3

Hole Detection

  • do you know the reference positions of those small circles? You could try to adapt my algorithm from here: https://stackoverflow.com/questions/20642641/opencv-templates-in-2d-point-data-set/20975486#20975486 – Micka Mar 19 '20 at 22:29
  • Yes, I am using a c++ function that circles all 9 holes and also the center of each hole. I am trying to transform my image to avoid needing to know the angle of the strap or the angle from my top to bottom hole. – Michael Mar 20 '20 at 13:17
  • but do the holes have a fixed/known pattern with low tolerance? So if you know the hole positions in the image and the template holes, you could use those holes for computing the transformation. – Micka Mar 20 '20 at 13:24
  • I updated my question with 2 extra strap examples and I shared a photo to show what my hole detection looks like. The holes are used as a way to identify what strap you are looking at. The top and bottom holes are not included in the ID and are consistently located at the same location on each strap. (Very low tolerance) A camera takes these photos and converts them to a buffer image. When the camera grabs the image the strap will always be at an inconsistent angle. The center of the holes is the only coordinates that really matter. I was hoping to transform, followed by hole detection. – Michael Mar 20 '20 at 14:32

0 Answers0