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


C++ FileStorage::getFirstTopLevelNode方法代码示例

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


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

示例1: prepareData

int CV_DetectorTest::prepareData( FileStorage& _fs )
{
    if( !_fs.isOpened() )
        test_case_count = -1;
    else
    {
        FileNode fn = _fs.getFirstTopLevelNode();

        fn[DIST_E] >> eps.dist;
        fn[S_E] >> eps.s;
        fn[NO_PAIR_E] >> eps.noPair;
//        fn[TOTAL_NO_PAIR_E] >> eps.totalNoPair;

        // read detectors
        if( fn[DETECTOR_NAMES].size() != 0 )
        {
            FileNodeIterator it = fn[DETECTOR_NAMES].begin();
            for( ; it != fn[DETECTOR_NAMES].end(); )
            {
                String _name;
                it >> _name;
                detectorNames.push_back(_name);
                readDetector(fn[DETECTORS][_name]);
            }
        }
        test_case_count = (int)detectorNames.size();

        // read images filenames and images
        string dataPath = ts->get_data_path();
        if( fn[IMAGE_FILENAMES].size() != 0 )
        {
            for( FileNodeIterator it = fn[IMAGE_FILENAMES].begin(); it != fn[IMAGE_FILENAMES].end(); )
            {
                String filename;
                it >> filename;
                imageFilenames.push_back(filename);
                Mat img = imread( dataPath+filename, 1 );
                images.push_back( img );
            }
        }
    }
开发者ID:DXM123,项目名称:opencv,代码行数:41,代码来源:test_cascadeandhog.cpp

示例2: main

//对起始帧初始化,然后逐帧处理
int main(int argc, char * argv[]){
  VideoCapture capture;
  capture.open(0);

 //OpenCV的C++接口中,用于保存图像的imwrite只能保存整数数据,且需作为图像格式。
 //而浮点数据或XML\YAML文件在OpenCV中的数据结构为FileStorage  
  FileStorage fs;
  //Read options
  read_options(argc,argv,capture,fs);//分析命令行参数  
  //Init camera
  if (!capture.isOpened())
  {
	cout << "capture device failed to open!" << endl;
    return 1;
  }
  //Register mouse callback to draw the bounding box
  cvNamedWindow("TLD",CV_WINDOW_AUTOSIZE);

  /*
   * void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param=NULL );
   * window_name  窗口的名字。 
   * on_mouse 指定窗口里每次鼠标事件发生的时候,被调用的函数指针。这个函数的原型应该为 
   * void Foo(int event, int x, int y, int flags, void* param);
  */
  cvSetMouseCallback( "TLD", mouseHandler, NULL );//鼠标选中初始目标的bounding box
  //TLD framework
  TLD tld; 
  //Read parameters file
  tld.read(fs.getFirstTopLevelNode());
  Mat frame;
  Mat last_gray;
  Mat first;
  if (fromfile){
	  //若是读取文件
      capture >> frame;//读取当前帧
      cvtColor(frame, last_gray, CV_RGB2GRAY);//转换为灰度图像
      frame.copyTo(first);//拷贝做第一帧
  }else{
开发者ID:FlyTerry,项目名称:OpenTLD,代码行数:39,代码来源:run_tld.cpp

示例3: main

int main(int argc, char * argv[])
{
    VideoCapture capture;
    if(argc>1)
    {
        capture.open(argv[1][0]-'0');
    }
    else
    {
        capture.open(0);
    }

    FileStorage fs;
    fs.open("parameters.yml", FileStorage::READ);

    if(!capture.isOpened())
    {
        cout<<"Cam Invalid"<<endl;
        return -1;
    }


    //serial initialize
    #ifdef SERIAL_PORT
    Serial serial;
    unsigned char sendBuff[10];
    if(serial.init()!=-1)
    {
        cout<<"serial init success"<<endl;
    }
    else
    {
        cout<<"serial init failed,please check the interface"<<endl;
        return -1;
    }
    #endif

    //set capture size
    capture.set(CV_CAP_PROP_FRAME_WIDTH,340);
    capture.set(CV_CAP_PROP_FRAME_HEIGHT,240);

    namedWindow("Intelisu",CV_WINDOW_NORMAL);//CV_WINDOW_AUTOSIZE
    setMouseCallback( "Intelisu", mouseHandler, NULL );

    TLD tld;
    tld.read(fs.getFirstTopLevelNode());
    Mat frame;
    Mat last_gray;
    Mat first;
    capture>>frame;//test image acquirement;
    cout<<frame.size()<<endl;
    //aquire the object patch
//    while(!gotBB)
//    {
//        if (!fromfile){
//            capture >> frame;
//        }
//        else
//            first.copyTo(frame);
//        cvtColor(frame, last_gray, CV_RGB2GRAY);
//        drawBox(frame,box);
//        putText(frame,"Wating for the object...",Point(20,20),FONT_HERSHEY_SIMPLEX,0.6,10,2);
//        //Mat scaleImage;
//        //resize(frame,scaleImage,Size(2*round(frame.cols),2*round(frame.rows)));
//        imshow("Intelisu", frame);
//        if (cvWaitKey(33) == 'q')
//            return 0;
//    }

    //motion track
    myupdate_mhi myupdate1;
    Rect result;
    Mat motion=Mat::zeros(frame.rows,frame.cols, CV_8UC1);
    for(;;)
    {
            capture>>frame;
            IplImage pframe(frame);
            IplImage pmotion(motion);

            myupdate1.init( &pframe, &pmotion, 60 );
            if(myupdate1.update_mhi(result)==0)
			{
				cout<<"x:"<<result.x+result.width/2<<"    "<<"y:"<<result.y+result.height/2<<endl;
				rectangle(frame,result, Scalar(255,0,0));
				break;
			}
			//resize(frame,frame,Size(3*round(frame.cols),3*round(frame.rows)));

            static unsigned char safeCount=0;
            putText(frame,"Environment Safe",Point(20,20),FONT_HERSHEY_SIMPLEX,0.7,CV_RGB(0,safeCount,0),2);
            safeCount+=16;

			imshow("Intelisu",frame);

			waitKey(10);

    }
    cvtColor(frame, last_gray, CV_RGB2GRAY);
    //waitKey(-1);

//.........这里部分代码省略.........
开发者ID:githubmsj1,项目名称:VisionTrack,代码行数:101,代码来源:intelisu.cpp

示例4: main

int main(int argc, char * argv[]){
	cvReleaseHaarClassifierCascade(&cascade);
	cascade = (CvHaarClassifierCascade*)cvLoad(cascade_name, 0, 0, 0);
	storage = cvCreateMemStorage(0);
	//NSST init
	HBManager nManager;
	nManager.initHB();
	//create a videoInput object
	videoInput VI;

	//Prints out a list of available devices and returns num of devices found
	int numDevices = VI.listDevices();

	int device = 0;  //this could be any deviceID that shows up in listDevices

	VideoCapture capture;
	FileStorage fs;
	//Read options
	read_options(argc, argv, capture, fs);
	int width, height;
	unsigned char * framePixels = NULL;
	//Init camera
	if (!fromfile) {
		if (!VI.setupDevice(device, 320, 240)) {
			cout << "capture device failed to open!" << endl;
			return 1;
		}
		//As requested width and height can not always be accomodated
		//make sure to check the size once the device is setup

		width = VI.getWidth(device);
		height = VI.getHeight(device);
		int size = VI.getSize(device);

		framePixels = new unsigned char[size];
	}
	else if (!capture.isOpened()) {
		cout << "capture device failed to open!" << endl;
		return 1;
	}
	//Register mouse callback to draw the bounding box
	namedWindow("FG Mask MOG 2");
	cvNamedWindow("TLD", CV_WINDOW_AUTOSIZE);
	cvSetMouseCallback("TLD", mouseHandler, NULL);
	//MOG2
	BackgroundSubtractor *pMOG2 = new BackgroundSubtractorMOG2();
	Mat fgMaskMOG2;
	vector<vector<Point>> contours;
	vector<Vec4i> hierarchy;
	Rect r;
	int centerP = 2;
	//HOG
	Mat ROI;
	//cv::HOGDescriptor hog; // 采用默认参数
	//hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());  // 采用已经训练好的行人检测分类器
	std::vector<cv::Rect> regions;
	//TLD framework
	TLD tld;
	//Read parameters file
	tld.read(fs.getFirstTopLevelNode());
	Mat frame;
	Mat last_gray;
	Mat first;
	Size size;
	if (fromfile){
		capture >> frame;
		cvtColor(frame, last_gray, CV_RGB2GRAY);
		frame.copyTo(first);
	}
	else {
		while (!VI.isFrameNew(device));
开发者ID:wangzi6147,项目名称:TLD_Rebuild,代码行数:71,代码来源:run_tld.cpp

示例5: main

int main(int argc, char * argv[]){
    VideoCapture capture;
    FileStorage fs;
    FileStorage detector_file;
    bool fromfile=false;
    //Read options
    CommandLineParser parser(argc, argv, keys);
    int init_frame = parser.get<int>("i");
    string param_file = parser.get<string>("p");
    string video = parser.get<string>("s");
    string init_bb  = parser.get<string>("b");
    
    fs.open(param_file, FileStorage::READ);
    if (video != "null"){
        fromfile=true;
        capture.open(video);
    }else{
        fromfile=false;
        capture.open(0);
    }
    if (init_bb !="null"){
        readBB(init_bb.c_str());
        gotBB =true;
    }
    
    //Init camera
    if (!capture.isOpened()){
        cout << "capture device failed to open!" << endl;
        return 1;
    }
    //Register mouse callback to draw the bounding box
    cvNamedWindow("Tracker",CV_WINDOW_AUTOSIZE);
    cvNamedWindow("Features",CV_WINDOW_AUTOSIZE);
    cvSetMouseCallback( "Tracker", mouseHandler, NULL );
    
    FILE  *bb_file = fopen("bounding_boxes.txt","w");
    
    Mat frame;
    Mat last_gray;
    Mat first;
    if (fromfile){
        capture.set(CV_CAP_PROP_POS_FRAMES,init_frame);
        capture.read(frame);
        last_gray.create(frame.rows,frame.cols,CV_8U);
        cvtColor(frame, last_gray, CV_BGR2GRAY);
        frame.copyTo(first);
    }

    ///Initialization
GETBOUNDINGBOX:
    while(!gotBB){
        if (!fromfile) capture.read(frame);
        else first.copyTo(frame);
        cvtColor(frame, last_gray, CV_BGR2GRAY);
        drawBox(frame,box);
        imshow("Tracker", frame);
        if (cvWaitKey(30) == 'q')
            return 0;
    }
    if (min(box.width,box.height)<(int)fs.getFirstTopLevelNode()["min_win"]){
        cout << "Bounding box too small, try again." << endl;
        gotBB = false;
        goto GETBOUNDINGBOX;
    }
    drawBox(frame,box);
    imshow("Tracker", frame);
    //Remove callback
    cvSetMouseCallback( "Tracker", NULL, NULL );
    printf("Initial Bounding Box = x:%d y:%d h:%d w:%d\n",box.x,box.y,box.width,box.height);
    //Output file
    fprintf(bb_file,"%d,%d,%d,%d,%f\n",box.x,box.y,box.br().x,box.br().y,1.0);
    
INIT:
    // Framework
    Alien tracker(fs.getFirstTopLevelNode());
    tracker.init(last_gray,box);
    
    cvWaitKey();
    ///Run-time
    Mat current_gray;
    RotatedRect pbox;
    bool status=true;
    int frames = 1;
    int detections = 1;
    float conf;
    while(capture.read(frame)){
        cvtColor(frame, current_gray, CV_BGR2GRAY);
        cout << endl;
        //Process Frame
        double t=(double)getTickCount();
        conf = tracker.processFrame(last_gray,current_gray,pbox,status);
        t = ((double)getTickCount() - t)*1000/getTickFrequency();
        //Draw Box
        if (status){
            drawBox(frame,pbox);
            fprintf(bb_file,"%f,%f,%f,%f,%f,%f,%f\n",pbox.center.x, pbox.center.y, pbox.size.height,pbox.size.width, pbox.angle,conf,t);
            detections++;
        }
        else{
            fprintf(bb_file,"NaN,NaN,NaN,NaN,%f,%f\n",conf,t);
//.........这里部分代码省略.........
开发者ID:Edgarreyna,项目名称:openAlien,代码行数:101,代码来源:main.cpp

示例6: main


//.........这里部分代码省略.........
			//int tp=strs.size();
			char *p[10];
			char **test3;//搞不太懂这里啊。。。
			for(int i=0;i<10;i++)
				p[i]=test2[i];
			test3=p; 	

			read_options(10,test3,capture,fs);

//			video = string(argv[1]);//目标视频//实验中输入参数就是这三行
//			capture.open(video);
//			readBB(argv[2]);//目标框


			// read_options(argc,argv,capture,fs);
			if(startFrame>0)//说明按下了r键,要我们重新手动选择框框
			{				
				box = Rect( 0, 0, 0, 0 );
				gotBB=false;
			}
			//   read_options(argc,argv,capture,fs);
			//Init camera
			if (!capture.isOpened()&&!isImage)//打不开视频而且不是图像序列
			{
				cout << "capture device failed to open!" << endl;
				return 1;
			}
			//Register mouse callback to draw the bounding box
			cvNamedWindow("TLD",CV_WINDOW_AUTOSIZE);
			cvSetMouseCallback("TLD", mouseHandler, NULL);
			//TLD framework
			TLD tld;
			//Read parameters file
			tld.read(fs.getFirstTopLevelNode());
//			tld.patch_size=atoi(argv[3]);
//			tld.min_win=atoi(argv[4]);	
			Mat frame;
			Mat last_gray;
			Mat first;
			if(fromCa)
			fromfile=false;
			fromCa=false;
			if (fromfile){
				if(!isImage){
					//	capture >> frame;
					totalFrameNumber = capture.get(CV_CAP_PROP_FRAME_COUNT);  
					cout<<"整个视频共"<<totalFrameNumber<<"帧"<<endl;
					//	capture.set( CV_CAP_PROP_POS_FRAMES,0); 似乎没有用
					for(int i=0;i<=startFrame;i++){
						capture.read(frame);}
					cvtColor(frame, last_gray, CV_RGB2GRAY);
					frame.copyTo(first);
				}
				else{
					totalFrameNumber = listCount;  
					cout<<"整个图像序列共"<<listCount<<"帧"<<endl;
					//	capture.set( CV_CAP_PROP_POS_FRAMES,0); 似乎没有用
					frame=imread(imageList[startFrame+2]);
					cvtColor(frame, last_gray, CV_RGB2GRAY);
					frame.copyTo(first);
				}

			}else{
				capture.set(CV_CAP_PROP_FRAME_WIDTH,340);
				capture.set(CV_CAP_PROP_FRAME_HEIGHT,240);
			}
开发者ID:ILoveFree2,项目名称:TLD-GPU-zlingh,代码行数:67,代码来源:run_tld.cpp


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