当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::train方法代码示例

本文整理汇总了C++中cv::Ptr::train方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::train方法的具体用法?C++ Ptr::train怎么用?C++ Ptr::train使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv::Ptr的用法示例。


在下文中一共展示了Ptr::train方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: train

    void train( std::vector<cv::Mat> &images, std::vector<int> &labels )
    {

//        //turn all images to grey and same size
//        for( cv::Mat image : images )
//        {
//            cv::cvtColor(image, image, CV_BGR2GRAY);
//            cv::resize(image, image, cv::Size(500, 500));
//
//            cv::imshow("face", image);
//            cv::waitKey();
//        }


        eigenfaceRecognizor->train(images, labels);
        fisherfaceRecognizor->train(images, labels);
        LBPHRecognizor->train(images, labels);
    }
开发者ID:MingyaoChen,项目名称:face-detection,代码行数:18,代码来源:FaceRecognition.cpp

示例2: getAssetPath

void TellThatToMyCamera_v1_0App::setup()
{
    mExpressionsCascade.load(getAssetPath("haarcascade_frontalface_alt.xml").string());
    mPath= getAssetPath("ppdtest.csv").string();
    
	mCapture = Capture( 640, 480 );                 // Camera settings
	mCapture.start();
    
    read_csv(mPath, mDBimgFaces, mDBLabels);        // Read DB of faces for FaceRec algorithm
    mFisherFaceRec->train(mDBimgFaces, mDBLabels);  // Train the Fisher Face Recognizer algorithm
}
开发者ID:ppdany,项目名称:ICP_TellThatToMyCamera,代码行数:11,代码来源:TellThatToMyCamera_v1_0App.cpp

示例3: loadKNNDataAndTrainKNN

bool loadKNNDataAndTrainKNN(void) {

    // read in training classifications ///////////////////////////////////////////////////

    cv::Mat matClassificationInts;              // we will read the classification numbers into this variable as though it is a vector

    cv::FileStorage fsClassifications("classifications.xml", cv::FileStorage::READ);        // open the classifications file

    if (fsClassifications.isOpened() == false) {                                                        // if the file was not opened successfully
        std::cout << "error, unable to open training classifications file, exiting program\n\n";        // show error message
        return(false);                                                                                  // and exit program
    }

    fsClassifications["classifications"] >> matClassificationInts;          // read classifications section into Mat classifications variable
    fsClassifications.release();                                            // close the classifications file

    // read in training images ////////////////////////////////////////////////////////////

    cv::Mat matTrainingImagesAsFlattenedFloats;         // we will read multiple images into this single image variable as though it is a vector

    cv::FileStorage fsTrainingImages("images.xml", cv::FileStorage::READ);              // open the training images file

    if (fsTrainingImages.isOpened() == false) {                                                 // if the file was not opened successfully
        std::cout << "error, unable to open training images file, exiting program\n\n";         // show error message
        return(false);                                                                          // and exit program
    }

    fsTrainingImages["images"] >> matTrainingImagesAsFlattenedFloats;           // read images section into Mat training images variable
    fsTrainingImages.release();                                                 // close the traning images file

    // train //////////////////////////////////////////////////////////////////////////////

            // finally we get to the call to train, note that both parameters have to be of type Mat (a single Mat)
            // even though in reality they are multiple images / numbers
    kNearest->setDefaultK(1);

    kNearest->train(matTrainingImagesAsFlattenedFloats, cv::ml::ROW_SAMPLE, matClassificationInts);

    return true;
}
开发者ID:Boduke217,项目名称:OpenCV_3_License_Plate_Recognition_Cpp,代码行数:40,代码来源:DetectChars.cpp

示例4: setup

void ICPApp::setup()
{
    mExpressionsCascade.load(getAssetPath("haarcascade_frontalface_alt.xml").string());
    mPath= getAssetPath("ppdtest.csv").string();
    
	mCapture = Capture( 640, 480 );                 // Camera settings
	mCapture.start();
    
    read_csv(mPath, mDBimgFaces, mDBLabels);        // Read DB of faces for FaceRec algorithm
    mFisherFaceRec->train(mDBimgFaces, mDBLabels);  // Train the Fisher Face Recognizer algorithm
    
    // FOR TESTING PURPOSES
    //    mSurf=(loadImage("/Users/PpD/Desktop/EcA - Pp DanY/MSc ICP/Semester 2/ICP 3/Faces DB Original/hugh_laurie_extra1.jpg"));
    //  mTexture = gl::Texture(mCinderDBimgFaces);
    //  mTexture = gl::Texture( fromOcv( input ) );
    //  cv::Mat output;
    //  mTexture = gl::Texture( fromOcv( loadImage("/Users/PpD/Desktop/emotionsrec2/data/emotions/0neutral/amy_adams_neutral.jpg") ) );    
    //  mDBLabelsTEST.push_back(0);
    //  mDBLabelsTEST.push_back(1);
    //  mFisherFaceRec->train(mDBimgFaces, mDBLabelsTEST);
    //  mFisherFaceRec->train(mDBimgFaces, mDBLabels);
}
开发者ID:ppdany,项目名称:ICP_TellThatToMyCamera,代码行数:22,代码来源:ICPApp.cpp

示例5: trainModel

/*
* Train any given model if it is not already trained
*/
void ModelTrainer::trainModel(cv::Ptr<cv::ml::StatModel> model) {
	if (model && !model->isTrained()) {
		cv::Ptr<cv::ml::TrainData> trainData = loadTrainingData();
		model->train(trainData);
	}
}
开发者ID:mcd8604,项目名称:ASAP,代码行数:9,代码来源:ModelTrainer.cpp


注:本文中的cv::Ptr::train方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。