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


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

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


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

示例1: FacesClassifier


//.........这里部分代码省略.........

		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);

		bool quit = false;
		while (!quit) {
			SDL_Event event;
			if (SDL_WaitEvent(&event)) {
				switch (event.type) {
				case SDL_QUIT: quit = true; break;

				case SDL_KEYUP:
					if (event.key.keysym.sym == SDLK_SPACE) {
						camera->capture();

						if (camera->buffer() != NULL) {
							IplImageAdapter::convert_image_bgr(camera->buffer(), image);
							cvResize(image, scaled_image, CV_INTER_LINEAR);
							memcpy(display_buffer, camera->buffer(), camera->buffer_size());

							tt->ping_start(ttc_recognition);
							std::list<ROI> *rois = classifier->classify();
							tt->ping_end(ttc_recognition);

							camera->dispose_buffer();

							bool first = true;
							for (std::list<ROI>::reverse_iterator i = rois->rbegin(); i != rois->rend(); ++i) {
								if (first) {
									drawer->set_color(127, 70, 200);
								}
								drawer->draw_rectangle(2 * i->start.x, 2 * i->start.y, 2 * i->width, 2 * i->height);
								if (first) {
									drawer->set_color(30, 30, 30);
									first = false;
								}
							}

							if (++loop_count % 15 == 0) {
								tt->print_to_stdout();
							}

							display->show(display_buffer);
						}

						SDL_PushEvent(&redraw_event);
					}

					else if (event.key.keysym.sym == SDLK_ESCAPE) {
						quit = true;
					}

					break;

				default: break;
				}
			}
		}

		camera->stop();
		camera->close();
		delete camera;
		delete display;
		delete drawer;
		free(display_buffer);
		cvReleaseImage(&image);
		cvReleaseImage(&scaled_image);
		delete tt;
	}

	else {
		printf("Usage: %s -h <Haar cascade file> -f <Image file as JPEG>\n", argv[0]);
		printf("    or %s -h <Haar cascade file> -c <Camera argument string>\n", argv[0]);
		exit(-1);
	}

	delete argp;
}
开发者ID:fawkesrobotics,项目名称:fawkes,代码行数:101,代码来源:qa_facesclassifier.cpp


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