From 508d2ed4e26f1aad28ea534cab725ca8296b097d Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 25 Nov 2024 11:46:24 +0100 Subject: [PATCH] added base OpenCV script and documentation --- docs/code/OpenCV.md | 8 ++++++++ src/C++/OpenCV/CMakeLists.txt | 9 +++++++++ src/C++/OpenCV/OpenCV.cpp | 0 src/C++/OpenCV/OpenCV.hpp | 0 src/C++/OpenCV/main.cpp | 31 +++++++++++++++++++++++++++++++ 5 files changed, 48 insertions(+) create mode 100644 docs/code/OpenCV.md create mode 100644 src/C++/OpenCV/CMakeLists.txt create mode 100644 src/C++/OpenCV/OpenCV.cpp create mode 100644 src/C++/OpenCV/OpenCV.hpp create mode 100644 src/C++/OpenCV/main.cpp diff --git a/docs/code/OpenCV.md b/docs/code/OpenCV.md new file mode 100644 index 0000000..29bc401 --- /dev/null +++ b/docs/code/OpenCV.md @@ -0,0 +1,8 @@ +# OpenCV + + + +## Installation +### Dependencies +* glew +* opencv \ No newline at end of file diff --git a/src/C++/OpenCV/CMakeLists.txt b/src/C++/OpenCV/CMakeLists.txt new file mode 100644 index 0000000..0cc8e30 --- /dev/null +++ b/src/C++/OpenCV/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8) +project( main ) +find_package( OpenCV REQUIRED ) +include_directories( ${OpenCV_INCLUDE_DIRS} ) +add_executable( main main.cpp ) +target_link_libraries( main ${OpenCV_LIBS} ) + + +#sauce: https://docs.opencv.org/4.x/db/df5/tutorial_linux_gcc_cmake.html \ No newline at end of file diff --git a/src/C++/OpenCV/OpenCV.cpp b/src/C++/OpenCV/OpenCV.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/C++/OpenCV/OpenCV.hpp b/src/C++/OpenCV/OpenCV.hpp new file mode 100644 index 0000000..e69de29 diff --git a/src/C++/OpenCV/main.cpp b/src/C++/OpenCV/main.cpp new file mode 100644 index 0000000..587ca89 --- /dev/null +++ b/src/C++/OpenCV/main.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include "opencv4/opencv2/imgproc/imgproc.hpp" +#include +#include + +using namespace cv; +using namespace std; + + +int main() { + Mat myImage; //Declaring a matrix to load the frames + namedWindow("Video Player"); //Declaring the video to show the video// + VideoCapture cap(0); //Declaring an object to capture stream of frames from default camera// + if (!cap.isOpened()){ //This section prompt an error message if no video stream is found// + cout << "No video stream detected" << endl; + system("pause"); + return-1; + } + while (true){ + cap >> myImage; // + if (myImage.empty()){ //Breaking the loop if no video frame is detected// + break; + } + imshow("Video Player", myImage); //Showing the video// + char c = (char)waitKey(25); //Allowing 25 milliseconds frame processing time and initiating break condition// + } + cap.release(); //Releasing the buffer memory// + return 0; +} \ No newline at end of file