在opencv 2.4.2中使用EM

时间:2013-04-03 19:59:18

标签: opencv

我正在寻求帮助。 由于EM类,我无法构建我的项目。我使用opencv 2.4.2

我无法找到问题所在。有人可以建议吗?

cv::TermCriteria Termination;
Termination.type=CV_TERMCRIT_ITER;
Termination.maxCount=num_numIter;
cv::EM model=cv::EM(NClusters,cv::EM::COV_MAT_SPHERICAL,Termination);
model.train(groupped_one_person_features);

在最后一行获取LINK ERR,我不知道如何创建类EM的对象。 NClusters是int,还有什么可能是错的?

我使用过:#include "opencv2/ml/ml.hpp"

此代码会导致以下错误:

  

2错误LNK2019:未解析的外部符号“public:virtual bool   __cdecl cv :: EM :: train(class cv :: _ InputArray const&amp;,class cv :: _ OutputArray const&amp;,class cv :: _ OutputArray const&amp;,class   cv :: _ OutputArray const&amp;)“   (?列车@ EM @ @@ CV @ UEAA_NAEBV_InputArray 2 @ AEBV_OutputArray @ 2 @ 11 @ Z)   在函数“void __cdecl compute_LBPH_patterns_EM(struct   ArrayData *,struct Pattern *,int,int)“   (?compute_LBPH_patterns_EM @@ YAXPEAUArrayData @@ PEAUPattern @@ HH @ Z)D:\ Work \ EBIS2012CPlusPlus \ Imet_v1.0_x64 \ Imet_v1.0_x64 \ compute_patterns.obj   AND错误1错误LNK2019:未解析的外部符号“public:   虚拟__cdecl cv :: EM :: ~EM(void)“(?? 1EM @ cv @@ UEAA @ XZ)在   function“void __cdecl compute_LBPH_patterns_EM(struct ArrayData   *,struct Pattern *,int,int)“(?compute_LBPH_patterns_EM @@ YAXPEAUArrayData @@ PEAUPattern @@ HH @ Z)D:\ Work \ EBIS2012CPlusPlus \ Imet_v1.0_x64 \ Imet_v1.0_x64 \ compute_patterns.obj   AND错误3错误LNK2019:未解析的外部符号“public:   __cdecl cv :: EM :: EM(int,int,class cv :: TermCriteria const&amp;)“(?? 0EM @ cv @@ QEAA @ HHAEBVTermCriteria @ 1 @@ Z)在函数中引用”void   __cdecl compute_LBPH_patterns_EM(struct ArrayData *,struct Pattern *,int,int)“(?compute_LBPH_patterns_EM @@ YAXPEAUArrayData @@ PEAUPattern @@ HH @ Z)D:\ Work \ EBIS2012CPlusPlus \ Imet_v1.0_x64 \ Imet_v1.0_x64 \ compute_patterns.obj < / p>

非常感谢

2 个答案:

答案 0 :(得分:1)

尝试使用这个 -

using namespace cv;
EM em_model;
const TermCriteria term_crit = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 
                                                           100, FLT_EPSILON);
em_model = EM(clustercount, EM::COV_MAT_DIAGONAL, term_crit);
em_model.train(samples, loghood, labels, probs);

答案 1 :(得分:0)

你去吧

#include <opencv2\opencv.hpp>

using namespace cv;             //use the opencv namespace

EM em_model;                    //EM model

int main()
{
    //get samples
    Mat samples;

    //define and crate ternmination critaria
    int type     = TermCriteria::COUNT + TermCriteria::EPS;     
    int maxCount = EM::DEFAULT_MAX_ITERS;
    TermCriteria termCritaria = TermCriteria(type, maxCount, FLT_EPSILON);

    //define EM parameters and instantiate model
    int nclusters      =  EM::DEFAULT_NCLUSTERS;
    int covMatrix_type =  EM::COV_MAT_DEFAULT;
    em_model = EM(nclusters, covMatrix_type, termCritaria);

    //train EM model
    em_model.train(samples);


    return 0;
}