sdunnim
sdunnim

Reputation: 221

Detecting shape location and heading with opencv

Background

I'm working on a cheap & simple method for tracking robots in their environment, avoiding gps, encoders, etc. There will be multiple robots aiming to reach a target area (see basic example below), and the computer should be feeding them data on their location, heading and target. example

Approach

I've decided to use a camera looking top-down onto the test area, coupled with coloured shapes (e.g. arrowhead) on top of the robots, and use OpenCV to detect their position and orientation in successive frames from the video.

Ideally there would be a fairly continuous stream of location and orientation data for each robot, however I've worked with OpenCV before and realise it can take time. An update rate around (or better than) 1Hz would be acceptable (i.e. lower frame rate/not using all frames).

I've used OpenCV before to SIFT filter frames from a video, and detect features to create a mosaiced image from the frames. However I'm finding it difficult to adapt my current knowledge to this specific problem, and online research has not really helped with an easy way to detect orientation.

Question

What is the easiest method that can detect a shape's location and orientation in an image quickly?

Upvotes: 0

Views: 716

Answers (1)

Yunus Temurlenk
Yunus Temurlenk

Reputation: 4342

You can simply use minAreaRect. You can take this example as reference. By doing this, you will get fitted rectangles for your each object and then you can use the mid points of the rectangle edges to get the angle.

Note: There will be two angles for each fitted rectangle so you should create an algorithm to choose the correct one for your situation.

Upvotes: 1

Related Questions