Created
March 8, 2019 00:42
-
-
Save yunqu/408f910b9761b0a1893e9285e0b71e97 to your computer and use it in GitHub Desktop.
Install opencv 3.1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is included from a subdirectory | |
set(PYTHON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../") | |
ocv_add_module(${MODULE_NAME} BINDINGS) | |
ocv_module_include_directories( | |
"${PYTHON_INCLUDE_PATH}" | |
${PYTHON_NUMPY_INCLUDE_DIRS} | |
"${PYTHON_SOURCE_DIR}/src2" | |
) | |
# get list of modules to wrap | |
# message(STATUS "Wrapped in ${MODULE_NAME}:") | |
set(OPENCV_PYTHON_MODULES) | |
foreach(m ${OPENCV_MODULES_BUILD}) | |
if (";${OPENCV_MODULE_${m}_WRAPPERS};" MATCHES ";${MODULE_NAME};" AND HAVE_${m}) | |
list(APPEND OPENCV_PYTHON_MODULES ${m}) | |
# message(STATUS "\t${m}") | |
endif() | |
endforeach() | |
set(opencv_hdrs "") | |
foreach(m ${OPENCV_PYTHON_MODULES}) | |
list(APPEND opencv_hdrs ${OPENCV_MODULE_${m}_HEADERS}) | |
endforeach(m) | |
# header blacklist | |
ocv_list_filterout(opencv_hdrs ".h$") | |
ocv_list_filterout(opencv_hdrs "cuda") | |
ocv_list_filterout(opencv_hdrs "cudev") | |
ocv_list_filterout(opencv_hdrs "/hal/") | |
ocv_list_filterout(opencv_hdrs "detection_based_tracker.hpp") # Conditional compilation | |
set(cv2_generated_hdrs | |
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h" | |
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h" | |
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_types.h" | |
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h" | |
"${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_ns_reg.h") | |
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs}") | |
add_custom_command( | |
OUTPUT ${cv2_generated_hdrs} | |
COMMAND ${PYTHON_EXECUTABLE} "${PYTHON_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" | |
DEPENDS ${PYTHON_SOURCE_DIR}/src2/gen2.py | |
DEPENDS ${PYTHON_SOURCE_DIR}/src2/hdr_parser.py | |
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt | |
DEPENDS ${opencv_hdrs}) | |
ocv_add_library(${the_module} MODULE ${PYTHON_SOURCE_DIR}/src2/cv2.cpp ${cv2_generated_hdrs}) | |
if(PYTHON_DEBUG_LIBRARIES AND NOT PYTHON_LIBRARIES MATCHES "optimized.*debug") | |
ocv_target_link_libraries(${the_module} debug ${PYTHON_DEBUG_LIBRARIES} optimized ${PYTHON_LIBRARIES}) | |
else() | |
if(APPLE) | |
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") | |
else() | |
ocv_target_link_libraries(${the_module} ${PYTHON_LIBRARIES}) | |
endif() | |
endif() | |
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) | |
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('SO'))" | |
RESULT_VARIABLE PYTHON_CVPY_PROCESS | |
OUTPUT_VARIABLE CVPY_SUFFIX | |
OUTPUT_STRIP_TRAILING_WHITESPACE) | |
set_target_properties(${the_module} PROPERTIES | |
LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}/${MODULE_INSTALL_SUBDIR}" | |
PREFIX "" | |
OUTPUT_NAME cv2 | |
SUFFIX ${CVPY_SUFFIX}) | |
if(ENABLE_SOLUTION_FOLDERS) | |
set_target_properties(${the_module} PROPERTIES FOLDER "bindings") | |
endif() | |
if(MSVC) | |
add_definitions(-DCVAPI_EXPORTS) | |
endif() | |
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") | |
endif() | |
if(MSVC AND NOT ENABLE_NOISY_WARNINGS) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100") #unreferenced formal parameter | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4127") #conditional expression is constant | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4505") #unreferenced local function has been removed | |
string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | |
endif() | |
if(MSVC AND NOT BUILD_SHARED_LIBS) | |
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") | |
endif() | |
if(MSVC AND NOT PYTHON_DEBUG_LIBRARIES) | |
set(PYTHON_INSTALL_CONFIGURATIONS CONFIGURATIONS Release) | |
else() | |
set(PYTHON_INSTALL_CONFIGURATIONS "") | |
endif() | |
if(WIN32) | |
set(PYTHON_INSTALL_ARCHIVE "") | |
else() | |
set(PYTHON_INSTALL_ARCHIVE ARCHIVE DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python) | |
endif() | |
if(NOT INSTALL_CREATE_DISTRIB) | |
install(TARGETS ${the_module} OPTIONAL | |
${PYTHON_INSTALL_CONFIGURATIONS} | |
RUNTIME DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python | |
LIBRARY DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python | |
${PYTHON_INSTALL_ARCHIVE} | |
) | |
else() | |
if(DEFINED PYTHON_VERSION_MAJOR) | |
set(__ver "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") | |
else() | |
set(__ver "unknown") | |
endif() | |
install(TARGETS ${the_module} | |
CONFIGURATIONS Release | |
RUNTIME DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python | |
LIBRARY DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python | |
) | |
endif() | |
unset(PYTHON_SRC_DIR) | |
unset(PYTHON_CVPY_PROCESS) | |
unset(CVPY_SUFFIX) | |
unset(PYTHON_INSTALL_CONFIGURATIONS) | |
unset(PYTHON_INSTALL_ARCHIVE) | |
find_package(HDF5) | |
include_directories(${HDF5_INCLUDE_DIRS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*M/////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
// | |
// By downloading, copying, installing or using the software you agree to this license. | |
// If you do not agree to this license, do not download, install, | |
// copy or use the software. | |
// | |
// | |
// License Agreement | |
// For Open Source Computer Vision Library | |
// | |
// Copyright (C) 2013, OpenCV Foundation, all rights reserved. | |
// Third party copyrights are property of their respective owners. | |
// | |
// Redistribution and use in source and binary forms, with or without modification, | |
// are permitted provided that the following conditions are met: | |
// | |
// * Redistribution's of source code must retain the above copyright notice, | |
// this list of conditions and the following disclaimer. | |
// | |
// * Redistribution's in binary form must reproduce the above copyright notice, | |
// this list of conditions and the following disclaimer in the documentation | |
// and/or other materials provided with the distribution. | |
// | |
// * The name of the copyright holders may not be used to endorse or promote products | |
// derived from this software without specific prior written permission. | |
// | |
// This software is provided by the copyright holders and contributors "as is" and | |
// any express or implied warranties, including, but not limited to, the implied | |
// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
// In no event shall the Intel Corporation or contributors be liable for any direct, | |
// indirect, incidental, special, exemplary, or consequential damages | |
// (including, but not limited to, procurement of substitute goods or services; | |
// loss of use, data, or profits; or business interruption) however caused | |
// and on any theory of liability, whether in contract, strict liability, | |
// or tort (including negligence or otherwise) arising in any way out of | |
// the use of this software, even if advised of the possibility of such damage. | |
// | |
//M*/ | |
#include "precomp.hpp" | |
#include "opencv2/tracking/onlineMIL.hpp" | |
#define sign(s) ((s > 0 ) ? 1 : ((s<0) ? -1 : 0)) | |
template<class T> class SortableElementRev | |
{ | |
public: | |
T _val; | |
int _ind; | |
SortableElementRev() : | |
_ind( 0 ) | |
{ | |
} | |
SortableElementRev( T val, int ind ) | |
{ | |
_val = val; | |
_ind = ind; | |
} | |
bool operator<( SortableElementRev<T> &b ) | |
{ | |
return ( _val < b._val ); | |
} | |
; | |
}; | |
static bool CompareSortableElementRev( const SortableElementRev<float>& i, const SortableElementRev<float>& j ) | |
{ | |
return i._val < j._val; | |
} | |
template<class T> void sort_order_des( std::vector<T> &v, std::vector<int> &order ) | |
{ | |
uint n = (uint) v.size(); | |
std::vector<SortableElementRev<T> > v2; | |
v2.resize( n ); | |
order.clear(); | |
order.resize( n ); | |
for ( uint i = 0; i < n; i++ ) | |
{ | |
v2[i]._ind = i; | |
v2[i]._val = v[i]; | |
} | |
//std::sort( v2.begin(), v2.end() ); | |
std::sort( v2.begin(), v2.end(), CompareSortableElementRev ); | |
for ( uint i = 0; i < n; i++ ) | |
{ | |
order[i] = v2[i]._ind; | |
v[i] = v2[i]._val; | |
} | |
} | |
; | |
namespace cv | |
{ | |
//implementations for strong classifier | |
ClfMilBoost::Params::Params() | |
{ | |
_numSel = 50; | |
_numFeat = 250; | |
_lRate = 0.85f; | |
} | |
ClfMilBoost::ClfMilBoost() | |
{ | |
_myParams = ClfMilBoost::Params(); | |
_numsamples = 0; | |
} | |
ClfMilBoost::~ClfMilBoost() | |
{ | |
_selectors.clear(); | |
for ( size_t i = 0; i < _weakclf.size(); i++ ) | |
delete _weakclf.at( i ); | |
} | |
void ClfMilBoost::init( const ClfMilBoost::Params ¶meters ) | |
{ | |
_myParams = parameters; | |
_numsamples = 0; | |
//_ftrs = Ftr::generate( _myParams->_ftrParams, _myParams->_numFeat ); | |
// if( params->_storeFtrHistory ) | |
// Ftr::toViz( _ftrs, "haarftrs" ); | |
_weakclf.resize( _myParams._numFeat ); | |
for ( int k = 0; k < _myParams._numFeat; k++ ) | |
{ | |
_weakclf[k] = new ClfOnlineStump( k ); | |
_weakclf[k]->_lRate = _myParams._lRate; | |
} | |
_counter = 0; | |
} | |
void ClfMilBoost::update( const Mat& posx, const Mat& negx ) | |
{ | |
int numneg = negx.rows; | |
int numpos = posx.rows; | |
// compute ftrs | |
//if( !posx.ftrsComputed() ) | |
// Ftr::compute( posx, _ftrs ); | |
//if( !negx.ftrsComputed() ) | |
// Ftr::compute( negx, _ftrs ); | |
// initialize H | |
static std::vector<float> Hpos, Hneg; | |
Hpos.clear(); | |
Hneg.clear(); | |
Hpos.resize( posx.rows, 0.0f ), Hneg.resize( negx.rows, 0.0f ); | |
_selectors.clear(); | |
std::vector<float> posw( posx.rows ), negw( negx.rows ); | |
std::vector<std::vector<float> > pospred( _weakclf.size() ), negpred( _weakclf.size() ); | |
// train all weak classifiers without weights | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int m = 0; m < _myParams._numFeat; m++ ) | |
{ | |
_weakclf[m]->update( posx, negx ); | |
pospred[m] = _weakclf[m]->classifySetF( posx ); | |
negpred[m] = _weakclf[m]->classifySetF( negx ); | |
} | |
// pick the best features | |
for ( int s = 0; s < _myParams._numSel; s++ ) | |
{ | |
// compute errors/likl for all weak clfs | |
std::vector<float> poslikl( _weakclf.size(), 1.0f ), neglikl( _weakclf.size() ), likl( _weakclf.size() ); | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int w = 0; w < (int) _weakclf.size(); w++ ) | |
{ | |
float lll = 1.0f; | |
for ( int j = 0; j < numpos; j++ ) | |
lll *= ( 1 - sigmoid( Hpos[j] + pospred[w][j] ) ); | |
poslikl[w] = (float) -log( 1 - lll + 1e-5 ); | |
lll = 0.0f; | |
for ( int j = 0; j < numneg; j++ ) | |
lll += (float) -log( 1e-5f + 1 - sigmoid( Hneg[j] + negpred[w][j] ) ); | |
neglikl[w] = lll; | |
likl[w] = poslikl[w] / numpos + neglikl[w] / numneg; | |
} | |
// pick best weak clf | |
std::vector<int> order; | |
sort_order_des( likl, order ); | |
// find best weakclf that isn't already included | |
for ( uint k = 0; k < order.size(); k++ ) | |
if( std::count( _selectors.begin(), _selectors.end(), order[k] ) == 0 ) | |
{ | |
_selectors.push_back( order[k] ); | |
break; | |
} | |
// update H = H + h_m | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int k = 0; k < posx.rows; k++ ) | |
Hpos[k] += pospred[_selectors[s]][k]; | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int k = 0; k < negx.rows; k++ ) | |
Hneg[k] += negpred[_selectors[s]][k]; | |
} | |
//if( _myParams->_storeFtrHistory ) | |
//for ( uint j = 0; j < _selectors.size(); j++ ) | |
// _ftrHist( _selectors[j], _counter ) = 1.0f / ( j + 1 ); | |
_counter++; | |
/* */ | |
return; | |
} | |
std::vector<float> ClfMilBoost::classify( const Mat& x, bool logR ) | |
{ | |
int numsamples = x.rows; | |
std::vector<float> res( numsamples ); | |
std::vector<float> tr; | |
for ( uint w = 0; w < _selectors.size(); w++ ) | |
{ | |
tr = _weakclf[_selectors[w]]->classifySetF( x ); | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int j = 0; j < numsamples; j++ ) | |
{ | |
res[j] += tr[j]; | |
} | |
} | |
// return probabilities or log odds ratio | |
if( !logR ) | |
{ | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int j = 0; j < (int) res.size(); j++ ) | |
{ | |
res[j] = sigmoid( res[j] ); | |
} | |
} | |
return res; | |
} | |
//implementations for weak classifier | |
ClfOnlineStump::ClfOnlineStump() | |
{ | |
_trained = false; | |
_ind = -1; | |
init(); | |
} | |
ClfOnlineStump::ClfOnlineStump( int ind ) | |
{ | |
_trained = false; | |
_ind = ind; | |
init(); | |
} | |
void ClfOnlineStump::init() | |
{ | |
_mu0 = 0; | |
_mu1 = 0; | |
_sig0 = 1; | |
_sig1 = 1; | |
_lRate = 0.85f; | |
_trained = false; | |
} | |
void ClfOnlineStump::update( const Mat& posx, const Mat& negx, const Mat_<float>& /*posw*/, const Mat_<float>& /*negw*/) | |
{ | |
//std::cout << " ClfOnlineStump::update" << _ind << std::endl; | |
float posmu = 0.0, negmu = 0.0; | |
if( posx.cols > 0 ) | |
posmu = float( mean( posx.col( _ind ) )[0] ); | |
if( negx.cols > 0 ) | |
negmu = float( mean( negx.col( _ind ) )[0] ); | |
if( _trained ) | |
{ | |
if( posx.cols > 0 ) | |
{ | |
_mu1 = ( _lRate * _mu1 + ( 1 - _lRate ) * posmu ); | |
cv::Mat diff = posx.col( _ind ) - _mu1; | |
_sig1 = _lRate * _sig1 + ( 1 - _lRate ) * float( mean( diff.mul( diff ) )[0] ); | |
} | |
if( negx.cols > 0 ) | |
{ | |
_mu0 = ( _lRate * _mu0 + ( 1 - _lRate ) * negmu ); | |
cv::Mat diff = negx.col( _ind ) - _mu0; | |
_sig0 = _lRate * _sig0 + ( 1 - _lRate ) * float( mean( diff.mul( diff ) )[0] ); | |
} | |
_q = ( _mu1 - _mu0 ) / 2; | |
_s = sign( _mu1 - _mu0 ); | |
_log_n0 = std::log( float( 1.0f / pow( _sig0, 0.5f ) ) ); | |
_log_n1 = std::log( float( 1.0f / pow( _sig1, 0.5f ) ) ); | |
//_e1 = -1.0f/(2.0f*_sig1+1e-99f); | |
//_e0 = -1.0f/(2.0f*_sig0+1e-99f); | |
_e1 = -1.0f / ( 2.0f * _sig1 + std::numeric_limits<float>::min() ); | |
_e0 = -1.0f / ( 2.0f * _sig0 + std::numeric_limits<float>::min() ); | |
} | |
else | |
{ | |
_trained = true; | |
if( posx.cols > 0 ) | |
{ | |
_mu1 = posmu; | |
cv::Scalar scal_mean, scal_std_dev; | |
cv::meanStdDev( posx.col( _ind ), scal_mean, scal_std_dev ); | |
_sig1 = float( scal_std_dev[0] ) * float( scal_std_dev[0] ) + 1e-9f; | |
} | |
if( negx.cols > 0 ) | |
{ | |
_mu0 = negmu; | |
cv::Scalar scal_mean, scal_std_dev; | |
cv::meanStdDev( negx.col( _ind ), scal_mean, scal_std_dev ); | |
_sig0 = float( scal_std_dev[0] ) * float( scal_std_dev[0] ) + 1e-9f; | |
} | |
_q = ( _mu1 - _mu0 ) / 2; | |
_s = sign( _mu1 - _mu0 ); | |
_log_n0 = std::log( float( 1.0f / pow( _sig0, 0.5f ) ) ); | |
_log_n1 = std::log( float( 1.0f / pow( _sig1, 0.5f ) ) ); | |
//_e1 = -1.0f/(2.0f*_sig1+1e-99f); | |
//_e0 = -1.0f/(2.0f*_sig0+1e-99f); | |
_e1 = -1.0f / ( 2.0f * _sig1 + std::numeric_limits<float>::min() ); | |
_e0 = -1.0f / ( 2.0f * _sig0 + std::numeric_limits<float>::min() ); | |
} | |
} | |
bool ClfOnlineStump::classify( const Mat& x, int i ) | |
{ | |
float xx = x.at<float>( i, _ind ); | |
double log_p0 = ( xx - _mu0 ) * ( xx - _mu0 ) * _e0 + _log_n0; | |
double log_p1 = ( xx - _mu1 ) * ( xx - _mu1 ) * _e1 + _log_n1; | |
return log_p1 > log_p0; | |
} | |
float ClfOnlineStump::classifyF( const Mat& x, int i ) | |
{ | |
float xx = x.at<float>( i, _ind ); | |
double log_p0 = ( xx - _mu0 ) * ( xx - _mu0 ) * _e0 + _log_n0; | |
double log_p1 = ( xx - _mu1 ) * ( xx - _mu1 ) * _e1 + _log_n1; | |
return float( log_p1 - log_p0 ); | |
} | |
inline std::vector<float> ClfOnlineStump::classifySetF( const Mat& x ) | |
{ | |
std::vector<float> res( x.rows ); | |
#ifdef _OPENMP | |
#pragma omp parallel for | |
#endif | |
for ( int k = 0; k < (int) res.size(); k++ ) | |
{ | |
res[k] = classifyF( x, k ); | |
} | |
return res; | |
} | |
} /* namespace cv */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*M/////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
// | |
// By downloading, copying, installing or using the software you agree to this license. | |
// If you do not agree to this license, do not download, install, | |
// copy or use the software. | |
// | |
// | |
// License Agreement | |
// For Open Source Computer Vision Library | |
// | |
// Copyright (C) 2013, OpenCV Foundation, all rights reserved. | |
// Third party copyrights are property of their respective owners. | |
// | |
// Redistribution and use in source and binary forms, with or without modification, | |
// are permitted provided that the following conditions are met: | |
// | |
// * Redistribution's of source code must retain the above copyright notice, | |
// this list of conditions and the following disclaimer. | |
// | |
// * Redistribution's in binary form must reproduce the above copyright notice, | |
// this list of conditions and the following disclaimer in the documentation | |
// and/or other materials provided with the distribution. | |
// | |
// * The name of the copyright holders may not be used to endorse or promote products | |
// derived from this software without specific prior written permission. | |
// | |
// This software is provided by the copyright holders and contributors "as is" and | |
// any express or implied warranties, including, but not limited to, the implied | |
// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
// In no event shall the Intel Corporation or contributors be liable for any direct, | |
// indirect, incidental, special, exemplary, or consequential damages | |
// (including, but not limited to, procurement of substitute goods or services; | |
// loss of use, data, or profits; or business interruption) however caused | |
// and on any theory of liability, whether in contract, strict liability, | |
// or tort (including negligence or otherwise) arising in any way out of | |
// the use of this software, even if advised of the possibility of such damage. | |
// | |
//M*/ | |
#ifndef __OPENCV_ONLINEMIL_HPP__ | |
#define __OPENCV_ONLINEMIL_HPP__ | |
#include "opencv2/core.hpp" | |
#include <limits> | |
namespace cv | |
{ | |
//! @addtogroup tracking | |
//! @{ | |
//TODO based on the original implementation | |
//http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml | |
//#define sign(s) ((s > 0 ) ? 1 : ((s<0) ? -1 : 0)) | |
class ClfOnlineStump; | |
class CV_EXPORTS ClfMilBoost | |
{ | |
public: | |
struct CV_EXPORTS Params | |
{ | |
Params(); | |
int _numSel; | |
int _numFeat; | |
float _lRate; | |
}; | |
ClfMilBoost(); | |
~ClfMilBoost(); | |
void init( const ClfMilBoost::Params ¶meters = ClfMilBoost::Params() ); | |
void update( const Mat& posx, const Mat& negx ); | |
std::vector<float> classify( const Mat& x, bool logR = true ); | |
inline float sigmoid( float x ) | |
{ | |
return 1.0f / ( 1.0f + exp( -x ) ); | |
} | |
private: | |
uint _numsamples; | |
ClfMilBoost::Params _myParams; | |
std::vector<int> _selectors; | |
std::vector<ClfOnlineStump*> _weakclf; | |
uint _counter; | |
}; | |
class ClfOnlineStump | |
{ | |
public: | |
float _mu0, _mu1, _sig0, _sig1; | |
float _q; | |
int _s; | |
float _log_n1, _log_n0; | |
float _e1, _e0; | |
float _lRate; | |
ClfOnlineStump(); | |
ClfOnlineStump( int ind ); | |
void init(); | |
void update( const Mat& posx, const Mat& negx, const cv::Mat_<float> & posw = cv::Mat_<float>(), const cv::Mat_<float> & negw = cv::Mat_<float>() ); | |
bool classify( const Mat& x, int i ); | |
float classifyF( const Mat& x, int i ); | |
std::vector<float> classifySetF( const Mat& x ); | |
private: | |
bool _trained; | |
int _ind; | |
}; | |
//! @} | |
} /* namespace cv */ | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
set -e | |
HOME=/root | |
opencv_version=3.1.0 | |
CURRDIR=$(pwd) | |
cd $HOME | |
# downloading zip | |
wget -O opencv.zip https://github.com/opencv/opencv/archive/${opencv_version}.zip | |
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${opencv_version}.zip | |
unzip opencv.zip | |
unzip opencv_contrib.zip | |
# bug fixes for 3.1.0 | |
cp -f ${CURRDIR}/common.cmake opencv-3.1.0/modules/python/ | |
cp -f ${CURRDIR}/onlineMIL.hpp opencv_contrib-3.1.0/modules/tracking/include/opencv2/tracking/ | |
cp -f ${CURRDIR}/onlineMIL.cpp opencv_contrib-3.1.0/modules/tracking/src/ | |
# build | |
mkdir opencv-${opencv_version}/build | |
cd opencv-${opencv_version}/build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D BUILD_WITH_DEBUG_INFO=OFF \ | |
-D BUILD_DOCS=OFF \ | |
-D BUILD_EXAMPLES=OFF \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_opencv_ts=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D INSTALL_PYTHON_EXAMPLES=OFF \ | |
-D ENABLE_NEON=ON \ | |
-D WITH_LIBV4L=ON \ | |
-D WITH_GSTREAMER=ON \ | |
-D BUILD_opencv_dnn=OFF \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${opencv_version}/modules \ | |
../ | |
make -j4 | |
make install | |
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf | |
ldconfig | |
cd $HOME | |
rm -rf *.zip opencv-${opencv_version} opencv_contrib-${opencv_version} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment