diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61b8896 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps \ No newline at end of file diff --git a/CMakeFiles/MotionDetection.dir/checkvideo.cpp.o b/CMakeFiles/MotionDetection.dir/checkvideo.cpp.o index 62f7556..6742659 100644 Binary files a/CMakeFiles/MotionDetection.dir/checkvideo.cpp.o and b/CMakeFiles/MotionDetection.dir/checkvideo.cpp.o differ diff --git a/MotionDetection b/MotionDetection index 059b788..9c38387 100644 Binary files a/MotionDetection and b/MotionDetection differ diff --git a/checkvideo.cpp b/checkvideo.cpp index 7c32dd3..97583af 100644 --- a/checkvideo.cpp +++ b/checkvideo.cpp @@ -6,7 +6,7 @@ using namespace std; using namespace cv; uchar **matToArray( cv::Mat array); - +int diffVec(Vec3b & first, Vec3b & second); int main(int argc, char* argv[]) { @@ -17,10 +17,6 @@ int main(int argc, char* argv[]) int childProcesses = procRank -1; - //2D array - used to store ther Mat Object values - uchar **pixels = NULL; - uchar **oldPixels = NULL; - // Create a VideoCapture object and open the input file // If the input is the web camera, pass 0 instead of the video file name VideoCapture cap("teapot.mp4"); @@ -30,8 +26,8 @@ int main(int argc, char* argv[]) cout << "Error opening video stream or file" << endl; return -1; } + Mat oldFrame; - cout << oldFrame << endl; while(1){ Mat frame; @@ -47,16 +43,18 @@ int main(int argc, char* argv[]) continue; } - cv::Mat newMat = cv::Mat(frame.rows, frame.cols, frame.type()); - - oldPixels = matToArray(oldFrame); - pixels = matToArray(frame); + cv::Mat newMat = cv::Mat(frame.rows, frame.cols, frame.type()); // frame.clone(); for(int i=0;i(i, j); + auto currPxl = frame.at(i, j); - if(diff > 10) { + // Summiert die Vekotren nach der euklidischen Norm (Von OpenCV) + int diff = norm(oldPxl - currPxl); + + + if(diff > 20) { Vec3b & color = newMat.at(i,j); // ... do something to the color .... @@ -77,12 +75,11 @@ int main(int argc, char* argv[]) oldFrame = frame; - // Display the resulting frame - imshow( "Frame", newMat ); - imshow( "Hans", frame ); + imshow( "Live", frame ); + imshow( "MotionDetection", newMat ); // Press ESC on keyboard to exit - char c=(char)waitKey(25); + char c=(char)waitKey(10); if(c==27) break; } @@ -99,19 +96,4 @@ int main(int argc, char* argv[]) MPI_Finalize(); return 0; -} - -uchar **matToArray( cv::Mat array) -{ - - uchar **pixels = new uchar *[array.rows]; - - for (int i = 0; i < array.rows; i++) - { - //IMPORTANT!! Channels are BGR - pixels[i] = new uchar[array.cols * array.channels()]; - pixels[i] = array.ptr(i); - } - - return pixels; } \ No newline at end of file