Note
Open main.cpp for the game's source code.
A simple game centered around color detection, where the score is accumulated by hitting a cat with green objects. Press q or Q to exit.
For Windows 10/11 the release .exe works out of the box.
gif of the initial build of cat game
Note
Both the OpenCV build and the release were made for Windows. Linux instructions are provided at the bottom.
The OpenCV build was made for running via MinGW g++. Specifically, I compile the program using:
g++ -o cat_game main.cpp -I"include" -L"include/mingw/lib" -lopencv_core4100 -lopencv_imgproc4100 -lopencv_imgcodecs4100 -lopencv_highgui4100 -lopencv_videoio4100 -mwindowsTo run OpenCV within Visual Studio, the Windows release available at opencv.org is recommended.
The OpenCV build was made via:
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=insert_destination_path -S insert_source_path -B insert_build_pathWithin the build folder:
mingw32-makemingw32-make installHowever, all necessary files to compile and run are included in the source code.
My OpenCV build is likely not suitable for Linux; thus, only the main.cpp and 089.jpg files are necessary.
First, install OpenCV and g++ using:
sudo apt install libopencv-dev build-essentialThen, compile using:
g++ main.cpp -o program `pkg-config --cflags --libs opencv4`