Skip to content
Snippets Groups Projects
Commit 82cbbe85 authored by am0ebe's avatar am0ebe
Browse files

compiles! [WIP] doesn't run yet

parent 64cbeac7
Branches
No related tags found
No related merge requests found
#camtron
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
project(bgslibrary) project(bgslibrary)
...@@ -25,13 +26,14 @@ endfunction() ...@@ -25,13 +26,14 @@ endfunction()
#endif() #endif()
if(UNIX) if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a")
#set(CMAKE_MACOSX_RPATH 1) #set(CMAKE_MACOSX_RPATH 1)
endif(UNIX) endif(UNIX)
# Avoid cmake warnings about changes in behavior of some Mac OS X path # Avoid cmake warnings about changes in behavior of some Mac OS X path
# variable we don't care about. # variable we dont care about.
if (POLICY CMP0042) if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) cmake_policy(SET CMP0042 NEW)
endif() endif()
...@@ -70,12 +72,13 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) ...@@ -70,12 +72,13 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
if(UNIX) if(UNIX)
# add some standard warnings # 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) # 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)
ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Wno-unknown-pragmas)
# -ansi does not compile with sjn module # -ansi does not compile with sjn module
#ADD_DEFINITIONS(-ansi) #ADD_DEFINITIONS(-ansi)
# if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare # if you like to have warnings about conversions, e.g. double->int or double->float etc., or float compare
#ADD_DEFINITIONS(-Wconversion -Wfloat-equal) #ADD_DEFINITIONS(-Wconversion -Wfloat-equal)
endif(UNIX) endif(UNIX)
...@@ -150,8 +153,8 @@ if(BGS_PYTHON_SUPPORT) ...@@ -150,8 +153,8 @@ if(BGS_PYTHON_SUPPORT)
# find_package(Boost REQUIRED COMPONENTS python3) # find_package(Boost REQUIRED COMPONENTS python3)
#endif() #endif()
# Pybind11's cmake scripts enable link time optimization by default. However, # Pybind11s cmake scripts enable link time optimization by default. However,
# it makes linking take a really long time and doesn't seem to substantively # it makes linking take a really long time and doesnt seem to substantively
# improve runtime performance. So we disable LTO here to make building bgslibrary # improve runtime performance. So we disable LTO here to make building bgslibrary
# faster. # faster.
set(PYBIND11_LTO_CXX_FLAGS "") set(PYBIND11_LTO_CXX_FLAGS "")
......
#examples #camtron examples
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.10)
project(bgslibrary) project(bgslibrary)
...@@ -12,9 +12,9 @@ endif() ...@@ -12,9 +12,9 @@ endif()
message(STATUS "BGSLIBRARY WITH PYTHON SUPPORT: ${BGS_PYTHON_SUPPORT}") message(STATUS "BGSLIBRARY WITH PYTHON SUPPORT: ${BGS_PYTHON_SUPPORT}")
if(UNIX) if(UNIX)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a") #seems to be TOOO modern?? # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++2a")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
endif(UNIX) endif(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
...@@ -45,7 +45,7 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) ...@@ -45,7 +45,7 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
if(UNIX) if(UNIX)
# add some standard warnings # add some standard warnings
#-Woverloaded-virtual #removed temporarily to increase readability of compiler output #-Woverloaded-virtual #removed temporarily to increase readability of compiler output
ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas) ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Wsign-promo -Wno-unused-parameter -pedantic -Wno-unknown-pragmas)
# -ansi does not compile with sjn module # -ansi does not compile with sjn module
#ADD_DEFINITIONS(-ansi) #ADD_DEFINITIONS(-ansi)
...@@ -62,9 +62,9 @@ message(STATUS " version: ${OpenCV_VERSION}") ...@@ -62,9 +62,9 @@ message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if(${OpenCV_VERSION} VERSION_EQUAL 3 OR ${OpenCV_VERSION} VERSION_GREATER 3) # if(${OpenCV_VERSION} VERSION_EQUAL 4 OR ${OpenCV_VERSION} VERSION_GREATER 3)
message(STATUS "WOW! Found OpenCV Version ${OpenCV_VERSION}. SO PROGRESSIVE ;) <-- might not be compatible yet\n") # message(STATUS "WOW! Found OpenCV Version ${OpenCV_VERSION}. SO PROGRESSIVE ;) <-- might not be compatible yet\n")
endif() # endif()
if(${OpenCV_VERSION} VERSION_LESS 2.3.1) if(${OpenCV_VERSION} VERSION_LESS 2.3.1)
message(FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}") message(FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
...@@ -97,64 +97,83 @@ if(BGS_PYTHON_SUPPORT) ...@@ -97,64 +97,83 @@ if(BGS_PYTHON_SUPPORT)
message(STATUS " include path: ${PYTHON_INCLUDE_DIRS}") message(STATUS " include path: ${PYTHON_INCLUDE_DIRS}")
endif() endif()
#file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
file(GLOB main Main.cpp FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp) file(GLOB main ../src/*.cpp) #Main.cpp FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp
# set(src "../src")
# file(GLOB main "${src}/Main.cpp" "${src}/FrameProcessor.cpp" "${src}/PreProcessor.cpp" "${src}/VideoAnalysis.cpp" "${src}/VideoCapture.cpp")
file(GLOB demo Demo.cpp) file(GLOB demo Demo.cpp)
file(GLOB demo2 Demo2.cpp) file(GLOB demo2 Demo2.cpp)
file(GLOB_RECURSE tools_src ../src/tools/*.cpp)
#file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
# list(REMOVE_ITEM sources ${demo} ${demo2}) # list(REMOVE_ITEM sources ${demo} ${demo2})
file(GLOB_RECURSE analysis_src package_analysis/*.cpp)
if(BGS_PYTHON_SUPPORT) if(BGS_PYTHON_SUPPORT)
file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c wrapper_python/*.cpp) file(GLOB_RECURSE bgs_src ../algorithms/*.cpp ../algorithms/*.c wrapper_python/*.cpp)
file(GLOB_RECURSE bgs_include package_bgs/*.h wrapper_python/*.h) file(GLOB_RECURSE bgs_include ../algorithms/*.h wrapper_python/*.h)
include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
else() else()
file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c) # file(GLOB_RECURSE bgs_src ../algorithms/*.cpp ../algorithms/*.c)
file(GLOB_RECURSE bgs_include package_bgs/*.h) # file(GLOB_RECURSE bgs_include ../algorithms/*.h)
#stolen from bgs main cmake
file(GLOB_RECURSE bgs_src ../src/algorithms/*.cpp ../src/algorithms/*.c)
file(GLOB_RECURSE bgs_inc ../src/algorithms/*.h ../src/algorithms/*.hpp)
include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS}) include_directories(${CMAKE_SOURCE_DIR} ${OpenCV_INCLUDE_DIRS} ${LibArchive_INCLUDE_DIRS})
endif() endif()
# GMG is not available in older OpenCV versions # GMG is not available in older OpenCV versions
if(${OpenCV_VERSION} VERSION_LESS 2.4.3) if(${OpenCV_VERSION} VERSION_LESS 2.4.3)
message(WARNING "WTF???????") message(WARNING "WTF???????")
file(GLOB gmg package_bgs/GMG.cpp) file(GLOB gmg ../algorithms/GMG.cpp)
list(REMOVE_ITEM bgs_src ${gmg}) list(REMOVE_ITEM bgs_src ${gmg})
endif() endif()
if(BGS_PYTHON_SUPPORT) if(BGS_PYTHON_SUPPORT)
#add_library(libbgs SHARED ${sources} ${bgs_src} ${analysis_src}) #add_library(libbgs SHARED ${sources} ${bgs_src} ${tools_src})
add_library(libbgs SHARED ${bgs_src} ${analysis_src}) add_library(libbgs SHARED ${bgs_src} ${tools_src})
target_link_libraries(libbgs ${OpenCV_LIBS} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries(libbgs ${OpenCV_LIBS} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
target_compile_definitions(libbgs PRIVATE BGS_PYTHON_SUPPORT=1) target_compile_definitions(libbgs PRIVATE BGS_PYTHON_SUPPORT=1)
else() else()
message(STATUS "HAHA ${bgs_src}\n\n") #add_library(libbgs STATIC ${sources} ${bgs_src} ${tools_src})
#add_library(libbgs STATIC ${sources} ${bgs_src} ${analysis_src}) add_library(libbgs STATIC ${bgs_src} ${tools_src}) # <<<<<< TODO - STATIC,,, .a ??
add_library(libbgs STATIC ${bgs_src} ${analysis_src}) # <<<<<< TODO # target_link_libraries(libbgs ${OpenCV_LIBS})
target_link_libraries(libbgs ${OpenCV_LIBS})
endif()
set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_include})
if(WIN32)
# set_property(TARGET libbgs PROPERTY SUFFIX ".lib")
else()
set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs")
endif() endif()
set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_include}) #macos framework bundle??
set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs") #linux
message("")
message(STATUS "bgs_src: '${bgs_src}'")
message(STATUS "tools_src: '${tools_src}'")
message(STATUS "main: '${main}'")
message(STATUS "demo: '${demo}'")
message(STATUS "demo2: '${demo2}'")
message(STATUS "CMAKE_SOURCE_DIR: '${CMAKE_SOURCE_DIR}'")
message(STATUS "CMAKE_BINARY_DIR: '${CMAKE_BINARY_DIR}'")
message(STATUS "CMAKE_INCLUDE_PATH: '${CMAKE_INCLUDE_PATH}'")
message(STATUS "bgs_include: '${bgs_include}'")
message(STATUS "INCLUDE_DIRECTORIES: '${INCLUDE_DIRECTORIES}'")
add_executable(bgslibrary ${main}) # <<<<<< TODO message("")
add_executable(bgslibrary ${main})
target_link_libraries(bgslibrary ${OpenCV_LIBS} libbgs) target_link_libraries(bgslibrary ${OpenCV_LIBS} libbgs)
# set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs) set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs)
add_executable(bgs_demo ${demo}) add_executable(bgs_demo ${demo}) # <<<<<< TODO
target_link_libraries(bgs_demo ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs) target_link_libraries(bgs_demo ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs)
add_executable(bgs_demo2 ${demo2}) add_executable(bgs_demo2 ${demo2})
target_link_libraries(bgs_demo2 ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs) target_link_libraries(bgs_demo2 ${OpenCV_LIBS} ${LibArchive_LIBRARIES} libbgs)
install(TARGETS libbgs install(TARGETS libbgs bgslibrary
bgslibrary
RUNTIME DESTINATION bin COMPONENT app RUNTIME DESTINATION bin COMPONENT app
LIBRARY DESTINATION lib COMPONENT runtime LIBRARY DESTINATION lib COMPONENT runtime
ARCHIVE DESTINATION lib COMPONENT runtime ARCHIVE DESTINATION lib COMPONENT runtime
PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev PUBLIC_HEADER DESTINATION include/../algorithms COMPONENT dev
FRAMEWORK DESTINATION "/Library/Frameworks" FRAMEWORK DESTINATION "/Library/Frameworks"
) )
#15:34 last sudo
/* /*
./bgs_demo -i test45/ -a 100 -o test45/results ./bgs_demo -i test45/ -a 100 -o test45/results
// -c center?
*/ */
//cpp c //cpp c
...@@ -19,22 +20,16 @@ ...@@ -19,22 +20,16 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
//cpp 11X #include <regex> //cpp 11X
#include <regex>
#define PROCESS_CENTER_VERSION_MAJOR 2 #define PROCESS_CENTER_VERSION_MAJOR 2
#define PROCESS_CENTER_VERSION_MINOR 0 #define PROCESS_CENTER_VERSION_MINOR 0
#define PROCESS_CENTER_VERSION_MINOR_FIXES 1 #define PROCESS_CENTER_VERSION_MINOR_FIXES 1
//opencv #include <opencv2/opencv.hpp> //opencv
#include <opencv2/opencv.hpp> #include "../src/algorithms/algorithms.h" //bgs
//bgslibrary
#include "package_bgs/bgslibrary.h"
//my class
#include "package_bgs/Tapter.h"
#include "package_bgs/ttoolbox.h"
using namespace bgslibrary::algorithms;
using namespace cv; using namespace cv;
using namespace std; using namespace std;
...@@ -55,7 +50,7 @@ int main(int argc, char * argv[]) ...@@ -55,7 +50,7 @@ int main(int argc, char * argv[])
{ {
signal(SIGUSR1, my_handler); signal(SIGUSR1, my_handler);
std::cout << "using processcenter " <<PROCESS_CENTER_VERSION_MAJOR <<"."<< PROCESS_CENTER_VERSION_MINOR<<"."<<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl; std::cout << "using processcenter " << PROCESS_CENTER_VERSION_MAJOR <<"."<< PROCESS_CENTER_VERSION_MINOR<<"."<<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl;
std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl; std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;
//!** parse programm input****************/ //!** parse programm input****************/
if(cmdOptionExists(argv, argv+argc, "-h")) if(cmdOptionExists(argv, argv+argc, "-h"))
...@@ -140,54 +135,23 @@ int main(int argc, char * argv[]) ...@@ -140,54 +135,23 @@ int main(int argc, char * argv[])
exit(1); exit(1);
} }
/*
Codebook is new!
Tapter is TBoy!
List of all algorithms:
(Note that some of these algorithms are available only for a specific version of OpenCV, see algorithms.h)
AdaptiveBackgroundLearning,AdaptiveSelectiveBackgroundLearning,CodeBook,DPAdaptiveMedian,DPEigenbackground,
DPGrimsonGMM,DPMean,DPPratiMediod,DPTexture,DPWrenGA,DPZivkovicAGMM,FrameDifference,FuzzyChoquetIntegral,
FuzzySugenoIntegral,GMG,IndependentMultimodal,KDE,KNN,LBAdaptiveSOM,LBFuzzyAdaptiveSOM,LBFuzzyGaussian,
LBMixtureOfGaussians,LBP_MRF,LBSimpleGaussian,LOBSTER,MixtureOfGaussianV2,MixtureOfGaussianV1,MultiCue,
MultiLayer,PAWCS,PixelBasedAdaptiveSegmenter,SigmaDelta,StaticFrameDifference,SuBSENSE,T2FGMM_UM,T2FGMM_UV,
T2FMRF_UM,T2FMRF_UV,TwoPoints,ViBe,VuMeter,WeightedMovingMean,WeightedMovingVariance
*/
/* Background Subtraction Methods */ /* Background Subtraction Methods */
IBGS *bgs; IBGS *bgs;
//bgs = new FrameDifference;
//bgs = new StaticFrameDifference;
//bgs = new WeightedMovingMean;
//bgs = new WeightedMovingVariance;
//bgs = new MixtureOfGaussianV1; // only on OpenCV 2.x
//bgs = new MixtureOfGaussianV2;
//bgs = new AdaptiveBackgroundLearning;
//bgs = new AdaptiveSelectiveBackgroundLearning;
//bgs = new GMG; // only on OpenCV 2.x
//bgs = new KNN; // only on OpenCV 3.x
//bgs = new DPAdaptiveMedian;
//bgs = new DPGrimsonGMM;
//bgs = new DPZivkovicAGMM;
//bgs = new DPMean;
//bgs = new DPWrenGA;
//bgs = new DPPratiMediod;
//bgs = new DPEigenbackground;
//bgs = new DPTexture;
//bgs = new T2FGMM_UM;
//bgs = new T2FGMM_UV;
//bgs = new T2FMRF_UM;
//bgs = new T2FMRF_UV;
//bgs = new FuzzySugenoIntegral;
//bgs = new FuzzyChoquetIntegral;
//bgs = new MultiLayer;
bgs = new PixelBasedAdaptiveSegmenter; bgs = new PixelBasedAdaptiveSegmenter;
//bgs = new LBSimpleGaussian;
//bgs = new LBFuzzyGaussian;
//bgs = new LBMixtureOfGaussians;
//bgs = new LBAdaptiveSOM;
//bgs = new LBFuzzyAdaptiveSOM;
//bgs = new LBP_MRF;
//bgs = new VuMeter;
//bgs = new KDE;
//bgs = new IndependentMultimodal;
//bgs = new MultiCue;
//bgs = new SigmaDelta;
//bgs = new SuBSENSE;
//bgs = new LOBSTER;
//bgs = new PAWCS;
//bgs = new TwoPoints;
//bgs = new ViBe;
//bgs = new Tapter;
//Tapter *bgs = new Tapter;
//see paper https://dl.acm.org/citation.cfm?id=2321600 //see paper https://dl.acm.org/citation.cfm?id=2321600
//https://ieeexplore.ieee.org/document/4527178/ //https://ieeexplore.ieee.org/document/4527178/
......
...@@ -25,14 +25,10 @@ based on original demo.cpp ...@@ -25,14 +25,10 @@ based on original demo.cpp
#define PROCESS_CENTER_VERSION_MAJOR 0 #define PROCESS_CENTER_VERSION_MAJOR 0
#define PROCESS_CENTER_VERSION_MINOR 2 #define PROCESS_CENTER_VERSION_MINOR 2
//opencv #include <opencv2/opencv.hpp> //opencv
#include <opencv2/opencv.hpp> #include "../src/algorithms/algorithms.h" //bgs
//bgslibrary
#include "package_bgs/bgslibrary.h"
//my class
#include "package_bgs/Tapter.h"
#include "package_bgs/ttoolbox.h"
using namespace bgslibrary::algorithms;
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <opencv2/opencv.hpp>
#include "../src/algorithms/algorithms.h"
using namespace bgslibrary::algorithms;
/* Background Subtraction Methods */
auto algorithmsName = BGS_Factory::Instance()->GetRegisteredAlgorithmsName();
int main(int argc, char** argv)
{
std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl;
std::cout << "Number of available algorithms: " << algorithmsName.size() << std::endl;
std::cout << "List of available algorithms:" << std::endl;
std::copy(algorithmsName.begin(), algorithmsName.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
/*
Codebook is new!
Tapter is TBoy!
List of all algorithms:
(Note that some of these algorithms are available only for a specific version of OpenCV, see algorithms.h)
AdaptiveBackgroundLearning,AdaptiveSelectiveBackgroundLearning,CodeBook,DPAdaptiveMedian,DPEigenbackground,
DPGrimsonGMM,DPMean,DPPratiMediod,DPTexture,DPWrenGA,DPZivkovicAGMM,FrameDifference,FuzzyChoquetIntegral,
FuzzySugenoIntegral,GMG,IndependentMultimodal,KDE,KNN,LBAdaptiveSOM,LBFuzzyAdaptiveSOM,LBFuzzyGaussian,
LBMixtureOfGaussians,LBP_MRF,LBSimpleGaussian,LOBSTER,MixtureOfGaussianV2,MixtureOfGaussianV1,MultiCue,
MultiLayer,PAWCS,PixelBasedAdaptiveSegmenter,SigmaDelta,StaticFrameDifference,SuBSENSE,T2FGMM_UM,T2FGMM_UV,
T2FMRF_UM,T2FMRF_UV,TwoPoints,ViBe,VuMeter,WeightedMovingMean,WeightedMovingVariance
*/
std::string algorithmName = "FrameDifference";
int cameraIndex = 0;
if (argc > 1) algorithmName = argv[1];
if (argc > 2) cameraIndex = std::stoi(argv[2]);
cv::VideoCapture capture;
capture.open(cameraIndex);
if (!capture.isOpened()) {
std::cerr << "Cannot initialize web camera!" << std::endl;
return -1;
}
std::cout << "Running " << algorithmName << std::endl;
auto bgs = BGS_Factory::Instance()->Create(algorithmName);
cv::Mat img_input;
auto key = 0;
std::cout << "Press 's' to stop:" << std::endl;
while (key != 's') {
// Capture frame-by-frame
capture >> img_input;
if (img_input.empty()) break;
// Resize input frame for better visualization
cv::resize(img_input, img_input, cv::Size(380, 240), 0, 0, CV_INTER_LINEAR);
cv::imshow("input", img_input);
cv::Mat img_mask;
cv::Mat img_bkgmodel;
try {
// by default, bgs->process(...) shows automatically the foreground mask image
// or you can disable it by: bgs->setShowOutput(false);
bgs->process(img_input, img_mask, img_bkgmodel);
//if(!img_mask.empty())
// cv::imshow("Foreground", img_mask);
// ....do something else...
}
catch (std::exception& e) {
std::cout << "Exception occurred" << std::endl;
std::cout << e.what() << std::endl;
}
key = cv::waitKey(33);
}
cv::destroyAllWindows();
capture.release();
return 0;
}
/*
This file is part of BGSLibrary.
BGSLibrary is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BGSLibrary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Tapter.h" #include "Tapter.h"
#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
//IPLIMAGE?
// #include <opencv2/core/types_c.h>
// #include <opencv2/core/mat.hpp>
// #include <opencv2/imgproc.hpp>
// #include "lb/BGModelSom.h"
// #include "lb/Types.h"
using namespace bgslibrary::algorithms; using namespace bgslibrary::algorithms;
Tapter::Tapter() : Tapter::Tapter() :
sensitivity(75), trainingSensitivity(245), learningRate(62), trainingLearningRate(255), trainingSteps(55) IBGS(quote(Tapter)),
sensitivity(75),
trainingSensitivity(245),
learningRate(62),
trainingLearningRate(255),
trainingSteps(55)
{ {
std::cout << "Tapter()" << std::endl; // load_config("./config/Tapter.xml")
setup("./config/Tapter.xml"); debug_construction(Tapter);
// frameCounter = 0; initLoadSaveConfig(algorithmName);
// //inputPath = ".";
// //centerFile = ".";
// outputPath = ".";
// flagWrite = -1;
// writeDbgPic = -1;
} }
Tapter::~Tapter() Tapter::~Tapter()
{ {
debug_destruction(Tapter);
delete m_pBGModel; delete m_pBGModel;
std::cout << "~Tapter()" << std::endl;
} }
//void Tapter::setFlagWrite(short flag)
//{
// flagWrite = flag;
//}
//void Tapter::setFlagWriteDBGpic(short flag)
//{
// writeDbgPic = flag;
//}
//void Tapter::setPathOut(std::string outPath)
//{
// outputPath = outPath;
//}
//void Tapter::setLearningRate(int rate)
//{
// learningRate = rate;
//}
//void Tapter::setInitialFrameCounter(int counter)
//{
// frameCounter = counter;
//}
void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel) void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel)
{ {
//! continue the normal //! continue the normal
init(img_input, img_output, img_bgmodel); init(img_input, img_output, img_bgmodel);
IplImage *frame = new IplImage(img_input); IplImage *frame = new cvIplImage(img_input);
// IplImage *frame = new cv::cvarrToMat(img_input);
if (firstTime) // XXX where is this ever set? if (firstTime)
{ {
int w = cvGetSize(frame).width; int w = cvGetSize(frame).width;
int h = cvGetSize(frame).height; int h = cvGetSize(frame).height;
m_pBGModel = new BGModelSom(w, h); m_pBGModel = new lb::BGModelSom(w, h);
m_pBGModel->InitModel(frame); m_pBGModel->InitModel(frame);
m_pBGModel->setBGModelParameter(0, sensitivity);
m_pBGModel->setBGModelParameter(1, trainingSensitivity);
m_pBGModel->setBGModelParameter(2, learningRate);
m_pBGModel->setBGModelParameter(3, trainingLearningRate);
m_pBGModel->setBGModelParameter(5, trainingSteps); //xxx Y 5? what happened to 4?
firstTime = false;
} }
m_pBGModel->setBGModelParameter(0, sensitivity);
m_pBGModel->setBGModelParameter(1, trainingSensitivity);
m_pBGModel->setBGModelParameter(2, learningRate);
m_pBGModel->setBGModelParameter(3, trainingLearningRate);
m_pBGModel->setBGModelParameter(5, trainingSteps); //xxx Y 5? what happened to 4?
m_pBGModel->UpdateModel(frame); m_pBGModel->UpdateModel(frame);
...@@ -104,14 +72,10 @@ void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img ...@@ -104,14 +72,10 @@ void Tapter::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img
img_background.copyTo(img_bgmodel); img_background.copyTo(img_bgmodel);
delete frame; delete frame;
firstTime = false;
} }
void Tapter::save_config(cv::FileStorage &fs) void Tapter::save_config(cv::FileStorage &fs)
{ {
//TODO
// CvFileStorage* fs = cvOpenFileStorage(config_xml.c_str(), nullptr, CV_STORAGE_WRITE);
fs << "sensitivity" << sensitivity; fs << "sensitivity" << sensitivity;
fs << "trainingSensitivity" << trainingSensitivity; fs << "trainingSensitivity" << trainingSensitivity;
fs << "learningRate" << learningRate; fs << "learningRate" << learningRate;
...@@ -122,18 +86,12 @@ void Tapter::save_config(cv::FileStorage &fs) ...@@ -122,18 +86,12 @@ void Tapter::save_config(cv::FileStorage &fs)
void Tapter::load_config(cv::FileStorage &fs) void Tapter::load_config(cv::FileStorage &fs)
{ {
//TODO fs["sensitivity"] >> sensitivity;
//test defaults... fs["trainingSensitivity"] >> trainingSensitivity;
// CvFileStorage* fs = cvOpenFileStorage(config_xml.c_str(), nullptr, CV_STORAGE_READ); fs["learningRate"] >> learningRate;
fs["trainingLearningRate"] >> trainingLearningRate;
fs["sensitivity"] >> sensitivity; //def: 75 fs["trainingSteps"] >> trainingSteps;
fs["trainingSensitivity"] >> trainingSensitivity; //def: 245 fs["showOutput"] >> showOutput;
fs["learningRate"] >> learningRate; //def: 62
fs["trainingLearningRate"] >> trainingLearningRate;//def: 255
fs["trainingSteps"] >> trainingSteps; //def: 55
fs["showOutput"] >> showOutput; //def: true
cvReleaseFileStorage(&fs);
} }
#endif
/*
This file is part of BGSLibrary.
BGSLibrary is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BGSLibrary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once #pragma once
//std lib //std lib
#include <sstream> // #include <sstream>
#include <vector> // #include <vector>
//opencv //opencv
#include "opencv2/opencv.hpp" // #include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp" // #include "opencv2/imgproc/imgproc.hpp"
//bgslib //bgslib
#include "lb/BGModelSom.h"
#include "IBGS.h" #include "IBGS.h"
#include "ttoolbox.h" #include "opencv2/core/version.hpp"
#if CV_MAJOR_VERSION >= 2 && CV_MAJOR_VERSION <= 3
//#define MC_SHOW_STEP_ANALYSE #include "ttoolbox.h"
#include "lb/BGModel.h"
// #include "lb/BGModel.h"
using namespace bgslibrary::algorithms::lb;
// using namespace bgslibrary::algorithms::lb::AdaptiveSOM;
using namespace cv;
using namespace std;
namespace bgslibrary namespace bgslibrary
{ {
...@@ -42,40 +24,17 @@ namespace bgslibrary ...@@ -42,40 +24,17 @@ namespace bgslibrary
class Tapter : public IBGS class Tapter : public IBGS
{ {
private: private:
BGModel* m_pBGModel; lb::BGModel* m_pBGModel; //TODO put in some kind of smartpointer.
int sensitivity; int sensitivity;
int trainingSensitivity; int trainingSensitivity;
int learningRate; int learningRate;
int trainingLearningRate; int trainingLearningRate;
int trainingSteps; int trainingSteps;
// int frameCounter; //
// std::string inputPath;
//// std::string centerFile;
// short flagWrite;
// short writeDbgPic;
// std::string outputPath;
public: public:
Tapter(); Tapter();
~Tapter(); ~Tapter();
void setInitialFrameCounter(int counter);
// void setPaths(std::string inPath,std::string outPath);
// void setPathOut(std::string outPath);
// //! 1 is on
// //! other no write
// void setFlagWrite(short flag);
// //! set learning rate
// void setLearningRate(int rate);
// //! 1 is on
// //! other no write
// void setFlagWriteDBGpic(short flag);
void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel); void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel);
private: private:
...@@ -86,3 +45,5 @@ namespace bgslibrary ...@@ -86,3 +45,5 @@ namespace bgslibrary
bgs_register(Tapter); bgs_register(Tapter);
} }
} }
#endif
...@@ -44,6 +44,9 @@ ...@@ -44,6 +44,9 @@
#include "ViBe.h" #include "ViBe.h"
#include "CodeBook.h" #include "CodeBook.h"
#include "Tapter.h"
#include "ttoolbox.h"
//#include "_template_/MyBGS.h" //#include "_template_/MyBGS.h"
using namespace bgslibrary::algorithms; using namespace bgslibrary::algorithms;
...@@ -41,7 +41,7 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv: ...@@ -41,7 +41,7 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv:
cv::Canny( imgSmoothed, imgCannyEdge, threshholdMin, threshholdMax, apertureSize ); cv::Canny( imgSmoothed, imgCannyEdge, threshholdMin, threshholdMax, apertureSize );
// Find contours, use RETR_EXTERNAL ignore inner child structures, TREE more usefull ? // Find contours, use RETR_EXTERNAL ignore inner child structures, TREE more usefull ?
cv::findContours( imgCannyEdge, contours, hierarchy, cv::RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0) ); cv::findContours( imgCannyEdge, contours, hierarchy, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );
#define MC_SHOW_STEP_ANALYSE #define MC_SHOW_STEP_ANALYSE
#ifdef MC_SHOW_STEP_ANALYSE #ifdef MC_SHOW_STEP_ANALYSE
...@@ -77,7 +77,7 @@ cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r) ...@@ -77,7 +77,7 @@ cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r)
// Draw the mask: white circle on black background // Draw the mask: white circle on black background
cv::Mat1b mask(image.size(), uchar(0)); cv::Mat1b mask(image.size(), uchar(0));
cv::circle(mask, cv::Point(circ[0], circ[1]), circ[2], cv::Scalar(255), CV_FILLED); cv::circle(mask, cv::Point(circ[0], circ[1]), circ[2], cv::Scalar(255), cv::FILLED);
//NO CROP NEEDED //NO CROP NEEDED
...@@ -145,7 +145,6 @@ std::string TToolBox::execCMD(const char* cmd) { ...@@ -145,7 +145,6 @@ std::string TToolBox::execCMD(const char* cmd) {
if (fgets(buffer.data(), 128, pipe.get()) != nullptr) if (fgets(buffer.data(), 128, pipe.get()) != nullptr)
result += buffer.data(); result += buffer.data();
//std::cout<<result<<std::endl; //std::cout<<result<<std::endl;
} }
//std::cout<<"call: " <<result<<std::endl; //std::cout<<"call: " <<result<<std::endl;
return result; return result;
......
...@@ -44,14 +44,14 @@ namespace bgslibrary ...@@ -44,14 +44,14 @@ namespace bgslibrary
private: private:
void _save_config() { void _save_config() {
//std::cout << "_save_config: " << config_file_path << std::endl; std::cout << "_save_config: " << config_file_path << std::endl;
cv::FileStorage fs(config_file_path, cv::FileStorage::WRITE); cv::FileStorage fs(config_file_path, cv::FileStorage::WRITE);
if (_is_valid(fs)) if (_is_valid(fs))
save_config(fs); save_config(fs);
fs.release(); fs.release();
} }
void _load_config() { void _load_config() {
//std::cout << "_load_config: " << config_file_path << std::endl; std::cout << "_load_config: " << config_file_path << std::endl;
cv::FileStorage fs; cv::FileStorage fs;
fs.open(config_file_path, cv::FileStorage::READ); fs.open(config_file_path, cv::FileStorage::READ);
if (_is_valid(fs)) if (_is_valid(fs))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment