Added to CV_INIT_ALGORITHM a Ptr creation function, for convenience.

Also changed the static functions to inline, to stop GCC complaining
about unused functions.
This commit is contained in:
Roman Donchenko 2013-08-14 12:41:58 +04:00
parent dadee3752c
commit 24dee16b12
5 changed files with 12 additions and 7 deletions

View File

@ -894,7 +894,7 @@ CV_INIT_ALGORITHM(LBPH, "FaceRecognizer.LBPH",
bool initModule_contrib() bool initModule_contrib()
{ {
Ptr<Algorithm> efaces = createEigenfaces_hidden(), ffaces = createFisherfaces_hidden(), lbph = createLBPH_hidden(); Ptr<Algorithm> efaces = createEigenfaces_ptr_hidden(), ffaces = createFisherfaces_ptr_hidden(), lbph = createLBPH_ptr_hidden();
return efaces->info() != 0 && ffaces->info() != 0 && lbph->info() != 0; return efaces->info() != 0 && ffaces->info() != 0 && lbph->info() != 0;
} }

View File

@ -128,12 +128,17 @@ namespace cv
} //namespace cv } //namespace cv
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \ #define CV_INIT_ALGORITHM(classname, algname, memberinit) \
static ::cv::Algorithm* create##classname##_hidden() \ static inline ::cv::Algorithm* create##classname##_hidden() \
{ \ { \
return new classname; \ return new classname; \
} \ } \
\ \
static ::cv::AlgorithmInfo& classname##_info() \ static inline ::cv::Ptr< ::cv::Algorithm> create##classname##_ptr_hidden() \
{ \
return ::cv::makePtr<classname>(); \
} \
\
static inline ::cv::AlgorithmInfo& classname##_info() \
{ \ { \
static ::cv::AlgorithmInfo classname##_info_var(algname, create##classname##_hidden); \ static ::cv::AlgorithmInfo classname##_info_var(algname, create##classname##_hidden); \
return classname##_info_var; \ return classname##_info_var; \

View File

@ -56,7 +56,7 @@ CV_INIT_ALGORITHM(EM, "StatModel.EM",
bool initModule_ml(void) bool initModule_ml(void)
{ {
Ptr<Algorithm> em = createEM_hidden(); Ptr<Algorithm> em = createEM_ptr_hidden();
return em->info() != 0; return em->info() != 0;
} }

View File

@ -67,7 +67,7 @@ CV_INIT_ALGORITHM(SIFT, "Feature2D.SIFT",
bool initModule_nonfree(void) bool initModule_nonfree(void)
{ {
Ptr<Algorithm> sift = createSIFT_hidden(), surf = createSURF_hidden(); Ptr<Algorithm> sift = createSIFT_ptr_hidden(), surf = createSURF_ptr_hidden();
return sift->info() != 0 && surf->info() != 0; return sift->info() != 0 && surf->info() != 0;
} }

View File

@ -58,8 +58,8 @@ CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade",
bool initModule_softcascade(void) bool initModule_softcascade(void)
{ {
Ptr<Algorithm> sc = createSCascade_hidden(); Ptr<Algorithm> sc = createSCascade_ptr_hidden();
Ptr<Algorithm> sc1 = createDetector_hidden(); Ptr<Algorithm> sc1 = createDetector_ptr_hidden();
return (sc1->info() != 0) && (sc->info() != 0); return (sc1->info() != 0) && (sc->info() != 0);
} }