TestVideos Class |
Namespace: Accord.DataSets
The TestVideos type exposes the following members.
Name | Description | |
---|---|---|
TestVideos |
Downloads and prepares the test videos dataset.
|
Name | Description | |
---|---|---|
Item |
Downloads the example video with the specified name and returns the file path where it has been saved.
| |
VideoNames |
Gets all the video names that can be passed to
the GetVideo(String) method.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetVideo |
Downloads the example video with the specified name and returns the file path where it has been saved.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
This dataset contains sample videos from https://pixabay.com available under a CC0 Creative Commons (a.k.a. public domain), meaning no they are free for commercial use and no attribution is required.
Using this class, you can retrieve any of the following test videos:
References:
// Let's test the tracker using a sample video from // the collection of test videos in the framework: TestVideos ds = new TestVideos(basePath); string fileName = ds["walking.mp4"]; // Now, let's open the video using FFMPEG: var video = new VideoFileReader(); video.Open(fileName); // And then check the contents of one of the frames: Bitmap frame = video.ReadVideoFrame(frameIndex: 150); frame.Save(Path.Combine(basePath, "walking_frame.png")); // Let's register a template for the bike rider in gray shirt Rectangle roi = new Rectangle(x: 70, y: 105, width: 28, height: 54); // initialization var tracker = new MatchingTracker() { SearchWindow = roi, Threshold = 0.0, // never reset the tracker in case it gets lost RegistrationThreshold = 0.95 // re-register the template if we are 95% // confident that the tracked object is indeed the object we want to follow }; // Creating bitmaps and locking them is an expensive // operation. Instead, let's allocate once and reuse BitmapData bitmapData = frame.LockBits(ImageLockMode.ReadWrite); UnmanagedImage unmanagedImage = new UnmanagedImage(bitmapData); // We will create two color markers: one to show the location of the // tracked object (red) and another one to show the regions of the image // that the tracker is looking at (white). RectanglesMarker objectMarker = new RectanglesMarker(Color.Red); RectanglesMarker windowMarker = new RectanglesMarker(Color.White); // Now, for each frame of the video for (int frameIndex = 0; frameIndex < video.FrameCount; frameIndex++) { // Read the current frame into the bitmap data video.ReadVideoFrame(frameIndex, bitmapData); if (frameIndex > 150) // wait until the bike rider enters the scene { // Feed the frame to the tracker tracker.ProcessFrame(unmanagedImage); // Mark the location of the tracker object in red color objectMarker.SingleRectangle = tracker.TrackingObject.Rectangle; objectMarker.ApplyInPlace(unmanagedImage); // overwrite the frame windowMarker.SingleRectangle = tracker.SearchWindow; windowMarker.ApplyInPlace(unmanagedImage); // overwrite the frame } // Save it to disk frame.Save(Path.Combine(basePath, "frame_{0}.png".Format(frameIndex))); } frame.UnlockBits(bitmapData);