added base OpenCV script and documentation

This commit is contained in:
2024-11-25 11:46:24 +01:00
parent 3e202acc8d
commit 508d2ed4e2
5 changed files with 48 additions and 0 deletions

8
docs/code/OpenCV.md Normal file
View File

@@ -0,0 +1,8 @@
# OpenCV
## Installation
### Dependencies
* glew
* opencv

View File

@@ -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

View File

View File

31
src/C++/OpenCV/main.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <opencv4/opencv2/core/core.hpp>
#include <opencv4/opencv2/imgcodecs.hpp>
#include <opencv4/opencv2/highgui/highgui.hpp>
#include "opencv4/opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <string>
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;
}