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


C++ ArgumentParser::arg方法代码示例

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


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

示例1: FacesClassifier

int
main(int argc, char **argv)
{
	ArgumentParser *argp = new ArgumentParser(argc, argv, "h:f:c:");

	if (argp->has_arg("h") && argp->has_arg("f"))
	// read image from file
	{
		const char *cascade_file = argp->arg("h");
		const char *image_file   = argp->arg("f");

		JpegReader *   reader = new JpegReader(image_file);
		unsigned char *buffer =
		  malloc_buffer(YUV422_PLANAR, reader->pixel_width(), reader->pixel_height());

		reader->set_buffer(buffer);
		reader->read();

		FacesClassifier *classifier =
		  new FacesClassifier(cascade_file, reader->pixel_width(), reader->pixel_height());

		classifier->set_src_buffer(buffer, reader->pixel_width(), reader->pixel_height());
		std::list<ROI> *rois = classifier->classify();

		FilterROIDraw *roi_draw = new FilterROIDraw();
		for (std::list<ROI>::iterator i = rois->begin(); i != rois->end(); ++i) {
			printf("ROI: start (%u, %u)  extent %u x %u\n",
			       (*i).start.x,
			       (*i).start.y,
			       (*i).width,
			       (*i).height);

			roi_draw->set_dst_buffer(buffer, &(*i));
			roi_draw->apply();
		}

		ImageDisplay *display = new ImageDisplay(reader->pixel_width(), reader->pixel_height());
		display->show(buffer);

		display->loop_until_quit();

		delete display;

		delete rois;
		free(buffer);
		delete reader;
		delete classifier;
	}

	else if (argp->has_arg("h") && argp->has_arg("c"))
	// get images from camera
	{
		const char *cascade_file = argp->arg("h");

		Camera *camera = NULL;
		try {
			camera = CameraFactory::instance(argp->arg("c"));
			camera->open();
			camera->start();
		} catch (Exception &e) {
			printf("Failed to open camera.\n");
			delete camera;
			return (-1);
		}

		printf("successfully opened camera: w=%d h=%d\n",
		       camera->pixel_width(),
		       camera->pixel_height());

		TimeTracker *tt              = new TimeTracker();
		unsigned int ttc_recognition = tt->add_class("Face recognition");
		unsigned int loop_count      = 0;

		IplImage *image =
		  cvCreateImage(cvSize(camera->pixel_width(), camera->pixel_height()), IPL_DEPTH_8U, 3);

		IplImage *scaled_image =
		  cvCreateImage(cvSize(camera->pixel_width() / 2, camera->pixel_height() / 2), IPL_DEPTH_8U, 3);

		FacesClassifier *classifier = new FacesClassifier(cascade_file,
		                                                  camera->pixel_width(),
		                                                  camera->pixel_height(),
		                                                  scaled_image,
		                                                  1.2 /* scale factor */,
		                                                  2 /* min neighbours */,
		                                                  CV_HAAR_DO_CANNY_PRUNING);

		unsigned char *display_buffer = (unsigned char *)malloc(camera->buffer_size());

		ImageDisplay *display =
		  new ImageDisplay(camera->pixel_width(), camera->pixel_height(), "QA Faces Classifier");

		Drawer *drawer = new Drawer();
		drawer->set_buffer(display_buffer, camera->pixel_width(), camera->pixel_height());

		SDL_Event redraw_event;
		redraw_event.type           = SDL_KEYUP;
		redraw_event.key.keysym.sym = SDLK_SPACE;

		SDL_PushEvent(&redraw_event);
//.........这里部分代码省略.........
开发者ID:fawkesrobotics,项目名称:fawkes,代码行数:101,代码来源:qa_facesclassifier.cpp

示例2: ArgumentParser

int
main(int argc, char **argv)
{
  int rv = 0;
  ArgumentParser *argp = new ArgumentParser(argc, argv, "hd:v");

  const vector<const char *> & items = argp->items();
  if ( items.size() == 0 || argp->has_arg("h") ) {
  cout << "Fawkes Interface generator - Usage Instructions" << endl
       << "===============================================================================" << endl
       << "Usage: " << argv[0] << " [-h] [-d dir] [-v] config.xml [config2.xml...]" << endl
       << "where [options] is one or more of:" << endl
       << " -h        These help instructions" << endl
       << " -d dir    Directory where to write generated files" << endl
       << " -v        Verbose console output." << endl
       << endl;
  } else {
    string dir = ".";
    if ( argp->has_arg("d") ) {
      dir = argp->arg("d");
    }

    for ( vector<const char *>::const_iterator i = items.begin(); i != items.end(); ++i) {
      string s = *i;
      string prefix;
      size_t pos;

      if ( ( pos = s.find_last_of (".")) != string::npos ) {
	prefix = s.substr(0, pos);
      } else {
	prefix = s;
      }
      s = prefix;
      if ( ( pos = s.find_last_of ("/")) != string::npos ) {
	prefix = s.substr(pos + 1);
      } else {
	prefix = s;
      }

      if ( ! File::exists( *i ) ) {
	cout << "File " << *i << " does not exist" << endl;
	continue;
      } else if (! File::is_regular( *i ) ) {
	cout << *i << " is not a regular file" << endl;
	continue;
      }

      try {
	InterfaceParser    *iparse = new InterfaceParser(*i);
	iparse->parse();
	if ( argp->has_arg("v") ) {
	  iparse->print();
	}
	
	InterfaceDigest    *idigest = new InterfaceDigest(*i);

	CppInterfaceGenerator *cppigen = new CppInterfaceGenerator(dir,
								   iparse->getInterfaceName(),
								   prefix,
								   iparse->getInterfaceAuthor(),
								   iparse->getInterfaceYear(),
								   iparse->getInterfaceCreationDate(),
								   iparse->getDataComment(),
								   idigest->get_hash(),
								   idigest->get_hash_size(),
								   iparse->getConstants(),
								   iparse->getEnumConstants(),
								   iparse->getDataFields(),
								   iparse->getPseudoMaps(),
								   iparse->getMessages()
								   );

	ToLuaInterfaceGenerator *toluaigen = new ToLuaInterfaceGenerator(dir,
									 iparse->getInterfaceName(),
									 prefix,
									 iparse->getInterfaceAuthor(),
									 iparse->getInterfaceYear(),
									 iparse->getInterfaceCreationDate(),
									 iparse->getDataComment(),
									 idigest->get_hash(),
									 idigest->get_hash_size(),
									 iparse->getConstants(),
									 iparse->getEnumConstants(),
									 iparse->getDataFields(),
									 iparse->getPseudoMaps(),
									 iparse->getMessages()
									 );

	cppigen->generate();
	toluaigen->generate();

	delete cppigen;
	delete toluaigen;

	delete iparse;
	delete idigest;
      } catch (Exception &e) {
	cout << "Generating the interface failed." << endl;
	e.print_trace();
        rv = -1;
//.........这里部分代码省略.........
开发者ID:fuxiang90,项目名称:fawkes,代码行数:101,代码来源:main.cpp


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