Table of Contents

Class VideoFingerprintDB

Namespace
VisioForge.VideoFingerPrinting.MongoDB
Assembly
VisioForge.VideoFingerPrinting.MongoDB.dll

Provides MongoDB-based storage and retrieval for video fingerprint data.

public class VideoFingerprintDB

Inheritance

Inherited Members

Remarks

This class manages video fingerprints using MongoDB with GridFS for binary storage. It provides functionality to load, save, query, and manage video fingerprint collections stored in a MongoDB database. Fingerprints can be loaded from the database or from filesystem folders containing .vsigx files.

Constructors

VideoFingerprintDB(string)

Initializes a new instance of the VisioForge.VideoFingerPrinting.MongoDB.VideoFingerprintDB class with default connection settings.

public VideoFingerprintDB(string dbname)

Parameters

dbname string

The name of the MongoDB database to use for fingerprint storage.

Remarks

This constructor creates a MongoDB client with default settings connecting to the local MongoDB instance.

VideoFingerprintDB(string, string)

Initializes a new instance of the VisioForge.VideoFingerPrinting.MongoDB.VideoFingerprintDB class with a custom connection string.

public VideoFingerprintDB(string dbname, string connectionString)

Parameters

dbname string

The name of the MongoDB database to use for fingerprint storage.

connectionString string

The MongoDB connection string specifying server address, credentials, and other options.

Remarks

This constructor allows connecting to MongoDB using a custom connection string, enabling connection to remote servers or with specific authentication settings.

VideoFingerprintDB(string, MongoClientSettings)

Initializes a new instance of the VisioForge.VideoFingerPrinting.MongoDB.VideoFingerprintDB class with custom MongoDB client settings.

public VideoFingerprintDB(string dbname, MongoClientSettings settings)

Parameters

dbname string

The name of the MongoDB database to use for fingerprint storage.

settings MongoClientSettings

The MongoDB.Driver.MongoClientSettings object containing advanced connection configuration.

Remarks

This constructor provides the most flexibility for configuring MongoDB connections, allowing fine-grained control over connection pooling, SSL/TLS, timeouts, and other advanced options.

Properties

Items

Gets the collection of loaded video fingerprints.

public List<VFPFingerPrint> Items { get; }

Property Value

List<VFPFingerPrint>

Methods

LoadFromDB()

Loads all video fingerprints from the MongoDB database into the VisioForge.VideoFingerPrinting.MongoDB.VideoFingerprintDB.Items collection.

public bool LoadFromDB()

Returns

bool

True if fingerprints were successfully loaded; false if an error occurred during loading.

Remarks

This method queries all fingerprint files stored in GridFS, deserializes them, and populates the Items collection. Any existing items in the collection are cleared before loading. Files are sorted by upload date in descending order.

LoadFromFolder(string)

Loads video fingerprints from .vsigx files in the specified folder and its subfolders.

public bool LoadFromFolder(string folder)

Parameters

folder string

The path to the folder containing fingerprint files (.vsigx extension).

Returns

bool

False in all cases (appears to be a bug in the original implementation).

Remarks

This method recursively searches the specified folder for .vsigx fingerprint files, loads each fingerprint, and adds it to the Items collection. Note: The return value does not accurately reflect success/failure status.

MaxAdDuration()

Calculates the maximum duration among all loaded fingerprints.

public long MaxAdDuration()

Returns

long

The duration in seconds of the longest fingerprint in the Items collection, or 0 if no items exist.

Remarks

This method iterates through all loaded fingerprints and returns the maximum duration value, which can be useful for buffer sizing or processing time estimation.

RemoveAll()

Removes all fingerprints from the MongoDB database.

public void RemoveAll()

Remarks

This method deletes all fingerprint files stored in GridFS that were uploaded after January 1, 2000. Use with caution as this operation cannot be undone. Note: This method does not clear the Items collection; call VisioForge.VideoFingerPrinting.MongoDB.VideoFingerprintDB.Items.Clear() if needed.

RemoveByID(string, bool)

Removes a fingerprint by its unique identifier from both the Items collection and optionally from the database.

public void RemoveByID(string id, bool fromDB = true)

Parameters

id string

The string representation of the fingerprint ID to remove (case-insensitive).

fromDB bool

If true, also removes the fingerprint from the MongoDB database; if false, only removes from the Items collection.

Remarks

This method searches the Items collection for a fingerprint with the matching ID. When found, it removes the item from the collection and optionally from the database. The search is case-insensitive.

RemoveByName(string, bool)

Removes a fingerprint by its original filename from both the Items collection and optionally from the database.

public void RemoveByName(string name, bool fromDB = true)

Parameters

name string

The original filename of the fingerprint to remove (case-insensitive).

fromDB bool

If true, also removes the fingerprint from the MongoDB database; if false, only removes from the Items collection.

Remarks

This method searches the Items collection for a fingerprint with the matching original filename. When found, it removes the item from the collection and optionally from the database. The search is case-insensitive.

SearchFingerprintsInFolder(string)

Searches for video fingerprint files (.vsigx) in the specified folder and all subfolders.

public static IEnumerable<string> SearchFingerprintsInFolder(string folder)

Parameters

folder string

The path to the folder to search. The folder will be created if it doesn't exist.

Returns

IEnumerable<string>

An enumerable collection of full file paths to all .vsigx fingerprint files found.

Remarks

This static method performs a recursive search for files with the .vsigx extension. If the specified folder doesn't exist, it will be created automatically.

Upload(VFPFingerPrint)

Uploads a video fingerprint to the MongoDB database using GridFS storage.

public void Upload(VFPFingerPrint fingerprint)

Parameters

fingerprint VFPFingerPrint

The VisioForge.Core.VideoFingerPrinting.VFPFingerPrint object to upload to the database.

Remarks

This method serializes the fingerprint and stores it in GridFS with the fingerprint's ID as the filename. If a fingerprint with the same ID already exists, it will not be automatically overwritten; use remove methods first if replacement is needed.