ROI Tracker
ROI Tracker is a new feature of the Media Vision API since Tizen 7.0 (C# API10). The RoiTracker API allows users to obtain the proper ROI coordinates that users want to track in an image. For example, when an image and ROI coordinates are provided as input to this API, the Media Vision framework will process the given image and ROI coordinates from the decoded image data and will provide ROI coordinates within the given image.
Prerequisites
To enable your application to use the ROI tracker and generation functionality, follow the steps below:
-
Install the NuGet packages for media vision.
-
To use ROI Tracker, include the Tizen.Multimedia and Tizen.Multimedia.Vision namespaces in your application:
C#Copyusing Tizen.Multimedia; using Tizen.Multimedia.Vision;
Prepare a MediaVisionSource
Prepare an input source to track. In this example, we use ImageUtil APIs to get the image buffer:
C#
Copy
MediaVisionSource inputSource = null;
using (JpegDecoder jpegDecoder = new JpegDecoder())
{
jpegDecoder.SetColorSpace(ColorSpace.Rgb888);
var frame = (await jpegDecoder.DecodeAsync("path")).FirstOrDefault();
inputSource = new MediaVisionSource(frame.Buffer, (uint)frame.Size.Width, (uint)frame.Size.Height, ColorSpace.Rgb888);
}
Track ROI area
To track an ROI area, follow the steps below:
-
Prepare a
RoiTracker
configuration:C#Copyvar roiTrackingConfiguration = new RoiTrackingConfiguration(); // If you don't set TrackerType, it will be RoiTrackerType.Balance. roiTrackingConfiguration.TrackerType = RoiTrackerType.Accuracy; // ROI should be set. // If you don't set the ROI property before calling TrackAsync, TrackAsync method will throw ArgumentException. roiTrackingConfiguration.Roi = new Rectangle(10, 10, 100, 100);
-
Track an ROI area:
C#Copyvar result = await RoiTracker.TrackAsync(inputSource, roiTrackingConfiguration); Log.Info("RoiTracker", $"X={result.X}, Y={result.Y}, Width={result.Width}, Height={result.Height}, ");
Note
If you want to change ROI area after calling
TrackAsync
, you should createRoiTrackingConfiguration
again. -
Dispose of
MediaVisionSource
andRoiTrackingConfiguration
instances, after using them:C#CopyinputSource?.Dispose(); roiTrackingConfiguration?.Dispose();
Related information
- Dependencies
- Tizen 7.0 and Higher