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


C++ Drawer::set_buffer方法代码示例

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


在下文中一共展示了Drawer::set_buffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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