A.Sully
A.Sully

Reputation: 21

Using Location (x/y) to update Region of Interest when tracking a video in Matlab

I'm trying to track a ball in a video in Matlab by using a template and this function from the Image Processing Toolbox:

LOC = step(H,I,T,ROI) computes the [x,y] location of the best template match, LOC, in the specified region of interest, ROI.

I start with a simple ROI that takes over the whole frame and the code successfully tracks the ball but it's very slow because the ROI is still set as the whole image.

Basically, I want to take the x and y coordinates of LOC (the location of the ball) and update the ROI so that it's a square over the LOC, then roll the next frame and look for the ball within the new compact ROI. This will leave a much smaller ROI for the code to look for the ball and hopefully speeds up the code.

How do I extract the x/y coordinates of LOC and use them to create a new ROI within the area?

Upvotes: 2

Views: 683

Answers (1)

GilLevi
GilLevi

Reputation: 2137

From the documentation :

The LOC [x y] coordinates correspond to the center of the template.

Example usage:

% Find the [x y] coordinates of the chip's center
  Loc=step(htm,Igray,T);  

Upvotes: 1

Related Questions