Skip to content
Snippets Groups Projects
Commit f6034c9a authored by Andrews Sobral's avatar Andrews Sobral
Browse files

example project for mac users

parent be9118e2
No related branches found
No related tags found
No related merge requests found
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)
#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;
}
#
# HOW TO COMPILE ON LINUX
#
# Requirements:
# cmake >= 2.8
# opencv >= 2.3.1
cmake .
make
bgslibrary uses this folder to store the configuration files
\ No newline at end of file
......@@ -33,7 +33,9 @@ typedef int BOOL;
#define TRUE 1
#endif
#if !defined(__APPLE__)
#include <malloc.h>
#endif
#include "math.h"
#include <vector>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment