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