From 2edf68c391e3bcf31dc4e1dd3669de909b9f67fc Mon Sep 17 00:00:00 2001 From: Andrews Cordolino Sobral Date: Tue, 16 Jul 2024 15:31:29 +0200 Subject: [PATCH] Added simple example code in getting started --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 62be835812..0a538cf306 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,33 @@ The library's source code is available under the [MIT license](https://opensourc * [Which algorithms really matter?](https://github.com/andrewssobral/bgslibrary/wiki/Which-algorithms-really-matter%3F) * [Library architecture](https://github.com/andrewssobral/bgslibrary/wiki/Library-architecture) +```cpp +#include +#include +#include +#include + +// Include the OpenCV and BGSLibrary libraries +#include +#include + +int main( int argc, char** argv ) +{ + // Gets the names of the background subtraction algorithms registered in the BGSLibrary factory + auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName(); + + // Displays the number of available background subtraction algorithms in the BGSLibrary + std::cout << "Number of available algorithms: " << algorithmsName.size() << std::endl; + + // Displays the list of available background subtraction algorithms in the BGSLibrary + std::cout << "List of available algorithms:" << std::endl; + std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator(std::cout, "\n")); + + // Returns 0 to indicate that the execution was successful + return 0; +} +``` + ### Installation instructions You can either install BGSLibrary via [pre-built binary package](https://github.com/andrewssobral/bgslibrary/releases) or build it from source