From f6034c9ab193897d2b53dca4289e1b8a6fc99a70 Mon Sep 17 00:00:00 2001 From: Andrews Sobral <andrewssobral@gmail.com> Date: Mon, 1 Sep 2014 23:16:20 +0200 Subject: [PATCH] example project for mac users --- example_macosx/CMakeLists.txt | 34 ++++++++++++++++++ example_macosx/FrameDifferenceTest.cpp | 49 ++++++++++++++++++++++++++ example_macosx/README.txt | 9 +++++ example_macosx/config/KEEP_THIS_FOLDER | 1 + package_bgs/sjn/SJN_MultiCueBGS.h | 2 ++ 5 files changed, 95 insertions(+) create mode 100644 example_macosx/CMakeLists.txt create mode 100644 example_macosx/FrameDifferenceTest.cpp create mode 100644 example_macosx/README.txt create mode 100644 example_macosx/config/KEEP_THIS_FOLDER diff --git a/example_macosx/CMakeLists.txt b/example_macosx/CMakeLists.txt new file mode 100644 index 0000000..107303f --- /dev/null +++ b/example_macosx/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) + +project(FrameDifferenceTest) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + +IF(UNIX) + # add some standard warnings + ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas) + + # -ansi does not compile with sjn module + #ADD_DEFINITIONS(-ansi) + + # if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare + #ADD_DEFINITIONS(-Wconversion -Wfloat-equal) +endif(UNIX) + +find_package(OpenCV REQUIRED) + +file(GLOB source FrameDifferenceTest.cpp) + +file(GLOB_RECURSE bgs_src ../package_bgs/*.cpp ../package_bgs/*.c) +file(GLOB_RECURSE bgs_include ../package_bgs/*.h) + +include_directories(${CMAKE_SOURCE_DIR}) + +add_library(bgs SHARED ${bgs_src}) +target_link_libraries(bgs ${OpenCV_LIBS}) +set_property(TARGET bgs PROPERTY PUBLIC_HEADER ${bgs_include}) + +add_executable(FrameDifferenceTest ${source}) +target_link_libraries(FrameDifferenceTest ${OpenCV_LIBS} bgs) + diff --git a/example_macosx/FrameDifferenceTest.cpp b/example_macosx/FrameDifferenceTest.cpp new file mode 100644 index 0000000..56f1e7c --- /dev/null +++ b/example_macosx/FrameDifferenceTest.cpp @@ -0,0 +1,49 @@ +#include <iostream> +#include <cv.h> +#include <highgui.h> + +#include "../package_bgs/FrameDifferenceBGS.h" + +int main(int argc, char **argv) +{ + CvCapture *capture = 0; + capture = cvCaptureFromCAM(0); + + if(!capture){ + std::cerr << "Cannot initialize video!" << std::endl; + return -1; + } + + IBGS *bgs; + bgs = new FrameDifferenceBGS; + + IplImage *frame; + while(1) + { + frame = cvQueryFrame(capture); + if(!frame) break; + + cv::Mat img_input(frame); + cv::imshow("Input", img_input); + + cv::Mat img_mask; + cv::Mat img_bkgmodel; + + // by default, it shows automatically the foreground mask image + bgs->process(img_input, img_mask, img_bkgmodel); + + //if(!img_mask.empty()) + // cv::imshow("Foreground", img_mask); + // do something + + if(cvWaitKey(33) >= 0) + break; + } + + delete bgs; + + cvDestroyAllWindows(); + cvReleaseCapture(&capture); + + return 0; +} diff --git a/example_macosx/README.txt b/example_macosx/README.txt new file mode 100644 index 0000000..5558b71 --- /dev/null +++ b/example_macosx/README.txt @@ -0,0 +1,9 @@ +# +# HOW TO COMPILE ON LINUX +# +# Requirements: +# cmake >= 2.8 +# opencv >= 2.3.1 + +cmake . +make diff --git a/example_macosx/config/KEEP_THIS_FOLDER b/example_macosx/config/KEEP_THIS_FOLDER new file mode 100644 index 0000000..24353bc --- /dev/null +++ b/example_macosx/config/KEEP_THIS_FOLDER @@ -0,0 +1 @@ +bgslibrary uses this folder to store the configuration files \ No newline at end of file diff --git a/package_bgs/sjn/SJN_MultiCueBGS.h b/package_bgs/sjn/SJN_MultiCueBGS.h index e81ab1a..0891c08 100644 --- a/package_bgs/sjn/SJN_MultiCueBGS.h +++ b/package_bgs/sjn/SJN_MultiCueBGS.h @@ -33,7 +33,9 @@ typedef int BOOL; #define TRUE 1 #endif +#if !defined(__APPLE__) #include <malloc.h> +#endif #include "math.h" #include <vector> -- GitLab