void onDraw(SkCanvas* canvas) override { sk_sp<SkImage> image0(make_image(canvas)); const ImageFilterFactory factories[] = { IFCCast([]{ return SkBlurImageFilter::Make(8, 8, nullptr); }), IFCCast([]{ return SkDilateImageFilter::Make(8, 8, nullptr); }), IFCCast([]{ return SkErodeImageFilter::Make(8, 8, nullptr); }), IFCCast([]{ return SkOffsetImageFilter::Make(8, 8, nullptr); }), }; const SkMatrix matrices[] = { SkMatrix::MakeScale(SK_ScalarHalf, SK_ScalarHalf), SkMatrix::MakeScale(2, 2), SkMatrix::MakeTrans(10, 10) }; const SkScalar spacer = image0->width() * 3.0f / 2; canvas->translate(40, 40); for (auto&& factory : factories) { sk_sp<SkImageFilter> filter(factory()); canvas->save(); show_image(canvas, image0.get(), filter); for (const auto& matrix : matrices) { sk_sp<SkImageFilter> localFilter(filter->makeWithLocalMatrix(matrix)); canvas->translate(spacer, 0); show_image(canvas, image0.get(), std::move(localFilter)); } canvas->restore(); canvas->translate(0, spacer); } }
void test_lsd(char *cfgfile, char *weightfile, char *filename) { network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } set_batch_network(&net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; int i, imlayer = 0; for (i = 0; i < net.n; ++i) { if (net.layers[i].out_c == 3) { imlayer = i; printf("%d\n", i); break; } } while(1){ if(filename){ strncpy(input, filename, 256); }else{ printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input, 0, 0); image resized = resize_min(im, net.w); image crop = crop_image(resized, (resized.w - net.w)/2, (resized.h - net.h)/2, net.w, net.h); //grayscale_image_3c(crop); float *X = crop.data; time=clock(); network_predict(net, X); image out = get_network_image_layer(net, imlayer); //yuv_to_rgb(out); constrain_image(out); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); show_image(out, "out"); show_image(crop, "crop"); save_image(out, "out"); #ifdef OPENCV cvWaitKey(0); #endif free_image(im); free_image(resized); free_image(crop); if (filename) break; } }
void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh) { network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } detection_layer l = net.layers[net.n-1]; set_batch_network(&net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; int j; float nms=.5; box *boxes = calloc(l.side*l.side*l.n, sizeof(box)); float **probs = calloc(l.side*l.side*l.n, sizeof(float *)); for(j = 0; j < l.side*l.side*l.n; ++j) probs[j] = calloc(l.classes, sizeof(float *)); while(1){ if(filename){ strncpy(input, filename, 256); } else { printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input,0,0); image sized = resize_image(im, net.w, net.h); float *X = sized.data; time=clock(); float *predictions = network_predict(net, X); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, probs, boxes, 0); if (nms) do_nms_sort(boxes, probs, l.side*l.side*l.n, l.classes, nms); //draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, voc_labels, 20); draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, 0, 20); show_image(im, "predictions"); save_image(im, "predictions"); show_image(sized, "resized"); free_image(im); free_image(sized); #ifdef OPENCV cvWaitKey(0); cvDestroyAllWindows(); #endif if (filename) break; } }
void test_writing(char *cfgfile, char *weightfile, char *filename) { network * net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(net, weightfile); } set_batch_network(net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; while(1){ if(filename){ strncpy(input, filename, 256); }else{ printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input, 0, 0); resize_network(net, im.w, im.h); printf("%d %d %d\n", im.h, im.w, im.c); float *X = im.data; time=clock(); network_predict(net, X); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); image pred = get_network_image(net); image upsampled = resize_image(pred, im.w, im.h); image thresh = threshold_image(upsampled, .5); pred = thresh; show_image(pred, "prediction"); show_image(im, "orig"); #ifdef OPENCV cvWaitKey(0); cvDestroyAllWindows(); #endif free_image(upsampled); free_image(thresh); free_image(im); if (filename) break; } }
void decode_captcha(char *cfgfile, char *weightfile) { setbuf(stdout, NULL); srand(time(0)); network net = parse_network_cfg(cfgfile); set_batch_network(&net, 1); if(weightfile){ load_weights(&net, weightfile); } char filename[256]; while(1){ printf("Enter filename: "); fgets(filename, 256, stdin); strtok(filename, "\n"); image im = load_image_color(filename, 300, 57); scale_image(im, 1./255.); float *X = im.data; float *predictions = network_predict(net, X); image out = float_to_image(300, 57, 1, predictions); show_image(out, "decoded"); #ifdef OPENCV cvWaitKey(0); #endif free_image(im); } }
void show_images(image *ims, int n, char *window) { image m = collapse_images_vert(ims, n); save_image(m, window); show_image(m, window); free_image(m); }
/** * gtk_image_menu_item_set_image: * @image_menu_item: a #GtkImageMenuItem. * @image: (allow-none): a widget to set as the image for the menu item. * * Sets the image of @image_menu_item to the given widget. * Note that it depends on the show-menu-images setting whether * the image will be displayed or not. * * Deprecated: 3.10 */ void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item, GtkWidget *image) { GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); priv = image_menu_item->priv; if (image == priv->image) return; if (priv->image) gtk_container_remove (GTK_CONTAINER (image_menu_item), priv->image); priv->image = image; if (image == NULL) return; gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item)); g_object_set (image, "visible", show_image (image_menu_item), "no-show-all", TRUE, NULL); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); g_object_notify (G_OBJECT (image_menu_item), "image"); }
IplImage *cmp_two_image(IplImage *src1, IplImage *src2) { float **des1, **des2; int npts1, npts2; int ndes; t_point *pts1, *pts2; // IplImage *img1 = harris(src1, 0.01, &des1, &npts1, &ndes, &pts1); // IplImage *img2 = harris(src2, 0.01, &des2, &npts2, &ndes, &pts2); IplImage *print = stack_imgs(src1, src2); harris_center(src1, 0.01); harris_center(src2, 0.01); return NULL; /*print des of img1 and img2*/ #ifdef PRINT for (int i = 0; i < npts1; i++) { for (int j = 0; j < ndes; j++) { cout << des1[i][j] << " "; } cout << endl; } cout << "\n"; for (int i = 0; i < npts2; i++) { for (int j = 0; j < ndes; j++) { cout << des2[i][j] << " "; } cout << endl; } cout << "\n"; #endif int mark = 0; float mdist = 10000; for (int i = 0; i < npts1; i++) { mdist = 10000; for (int j = 0; j < npts2; j++) { float dist = 0; for (int k = 0; k < ndes; k++) { dist += ABS(des1[i][k] - des2[j][k]); } #ifdef PRINT cout << dist << " " << i << " " << j << endl; #endif if (dist < mdist) { mdist = dist; mark = j; } } if (mdist < 0.02) { cvLine(print, cvPoint(pts1[i].x, pts1[i].y), cvPoint(pts2[mark].x + src1->width, pts2[mark].y), cvScalar(0, 255, 0), 1); } } show_image(print, "match"); }
int main(int argc, char **argv) { if(wiringPiSetup() == -1) { printf("wiringPiSetup() failed\n"); return EXIT_FAILURE; } // 540kHz speed - recomended by ST7920 spec //if ((lcd_fd = wiringPiSPISetupMode(0, 540000, 0x07)) < 0) { if ((lcd_fd = wiringPiSPISetup(0, 540000)) < 0) { printf("Can't open the SPI bus\n"); return EXIT_FAILURE; } char mode = 0x07; ioctl(lcd_fd, SPI_IOC_WR_MODE, &mode); init_gpio(); reset_lcd(); init_lcd(); set_extended_mode(0, 0, 0); set_extended_mode(0, 1, 1); clear_lcd(); show_image(raspberry_pix); return EXIT_SUCCESS; }
CvPoint get_center(IplImage *img) { int origW = img->width; int origH = img->height; ellipseW = origW / factor; ellipseH = origH / factor; mask = new unsigned char[ellipseH * ellipseW]; init_mask(ellipseW, ellipseH); //num = ellipseH * ellipseW; int half_w = ellipseW / 2; int half_h = ellipseH / 2; int ctrX, ctrY; float maxComplax; for (int y = half_h; y < origH - half_h; y++) { for (int x = half_w; x < origW - half_w; x++) { // cvSetImageROI(img, cvEllipse( float complaxVal = get_complax(img, x, y, ellipseW, ellipseH); // printf("%f %d %d\n", complaxVal, x, y); if (complaxVal > maxComplax) { maxComplax = complaxVal; ctrX = x; ctrY = y; } } } cvCircle(img, cvPoint(ctrX, ctrY), half_h, cvScalar(0, 255, 9)); printf("%d %d\n", ctrX, ctrY); show_image(img, "center"); return cvPoint(ctrX, ctrY); }
/** * need comment here */ static int show_images_and_delay(BmpBlockHeader *bmph, int local, int index) { int i; ScreenLayout *screen; ImageInfo *image; screen = (ScreenLayout *)(bmph + 1); screen += local * bmph->number_of_screenlayouts; screen += index; for (i = 0; i < MAX_IMAGE_IN_LAYOUT && screen->images[i].image_info_offset; i++) { image = (ImageInfo *)((uint8_t *)bmph + screen->images[i].image_info_offset); if (show_image(image, screen->images[i].x, screen->images[i].y)) goto bad; } VbExSleepMs(1000); return 0; bad: VbExDebug("Failed to display image, screen=%lu, image=%d!\n", index, i); return 1; }
void draw_coco(image im, float *pred, int side, char *label) { int classes = 1; int elems = 4+classes; int j; int r, c; for(r = 0; r < side; ++r){ for(c = 0; c < side; ++c){ j = (r*side + c) * elems; int class = max_index(pred+j, classes); if (pred[j+class] > 0.2){ int width = pred[j+class]*5 + 1; printf("%f %s\n", pred[j+class], "object"); //coco_classes[class-1]); float red = get_color(0,class,classes); float green = get_color(1,class,classes); float blue = get_color(2,class,classes); j += classes; box predict = {pred[j+0], pred[j+1], pred[j+2], pred[j+3]}; predict.x = (predict.x+c)/side; predict.y = (predict.y+r)/side; draw_bbox(im, predict, width, red, green, blue); } } } show_image(im, label); }
// the main device method virtual void run() { if(!opened) { scene->addItem(item); // lock the image viewer img_view_mutex.lock(); // update the pixmap and unlock the image viewer show_image(); // open a window to show the QGraphicsScene view->show(); // set the flag to true opened = true; } else { if (img_view_mutex.try_lock()) { // a new thread! std::thread show_image_thread(&ImageViewerDevice::show_image, this); // leave it alone show_image_thread.detach(); } } }
/** * gtk_image_menu_item_set_always_show_image: * @image_menu_item: a #GtkImageMenuItem * @always_show: %TRUE if the menuitem should always show the image * * If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images * setting and always show the image, if available. * * Use this property if the menuitem would be useless or hard to use * without the image. * * Since: 2.16 * * Deprecated: 3.10 */ void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item, gboolean always_show) { GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); priv = image_menu_item->priv; if (priv->always_show_image != always_show) { priv->always_show_image = always_show; if (priv->image) { if (show_image (image_menu_item)) gtk_widget_show (priv->image); else gtk_widget_hide (priv->image); } g_object_notify (G_OBJECT (image_menu_item), "always-show-image"); } }
MainWindow::MainWindow() { img_label = new QLabel("",0); setCentralWidget(img_label); createActions(); createMenus(); createToolBar(); powertfDlg = 0; edgedetectDlg = 0; houghDlg = 0; morphDlg = 0; blurDlg = 0; histeqDlg = 0; facedetectDlg = 0; cam_on = false; cam_save = false; capture = 0; setWindowIcon(QIcon(":/images/title.png")); img = imread("images/Home.png", 1); img.copyTo(cur_img); show_image(); }
void Darknet::yoloImage(const QString &filename, float thresh) { const Mat ori = OpenCV::loadImage(getAbs(filename), -1); Mat img; cv::resize(ori, img, cv::Size(priv->net.w, priv->net.h)); image im = toDarkImage(img); //image im = load_image_color((char *)qPrintable(getAbs(filename)), 0, 0); //image sized = resize_image(im, priv->net.w, priv->net.h); //float *X = sized.data; float *X = im.data; float *predictions = network_predict(priv->net, X); float nms=.5; const detection_layer l = priv->l; convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, priv->probs, priv->boxes, 0); if (nms) do_nms_sort(priv->boxes, priv->probs, l.side*l.side*l.n, l.classes, nms); draw_detections(im, l.side*l.side*l.n, thresh, priv->boxes, priv->probs, voc_names, 0, 20); show_image(im, "predictions"); save_image(im, "predictions"); //show_image(sized, "resized"); free_image(im); //free_image(sized); }
void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh) { int show_flag = 1; list *options = read_data_cfg(datacfg); char *name_list = option_find_str(options, "names", "data/names.list"); char **names = get_labels(name_list); image **alphabet = load_alphabet(); network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } set_batch_network(&net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; int j; float nms=.4; while(1){ if(filename){ strncpy(input, filename, 256); } else { printf("Enter Image Path: "); fflush(stdout); input = fgets(input, 256, stdin); if(!input) return; strtok(input, "\n"); } image im = load_image_color(input,0,0); image sized = resize_image(im, net.w, net.h); layer l = net.layers[net.n-1]; box *boxes = calloc(l.w*l.h*l.n, sizeof(box)); float **probs = calloc(l.w*l.h*l.n, sizeof(float *)); for(j = 0; j < l.w*l.h*l.n; ++j) probs[j] = calloc(l.classes + 1, sizeof(float *)); float *X = sized.data; time=clock(); network_predict(net, X); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); get_region_boxes(l, 1, 1, thresh, probs, boxes, 0, 0, hier_thresh); if (l.softmax_tree && nms) do_nms_obj(boxes, probs, l.w*l.h*l.n, l.classes, nms); else if (nms) do_nms_sort(boxes, probs, l.w*l.h*l.n, l.classes, nms); draw_detections(im, l.w*l.h*l.n, thresh, boxes, probs, names, alphabet, l.classes, show_flag); save_image(im, "predictions"); show_image(im, "predictions"); free_image(im); free_image(sized); free(boxes); free_ptrs((void **)probs, l.w*l.h*l.n); #ifdef OPENCV cvWaitKey(0); cvDestroyAllWindows(); #endif if (filename) break; } }
void MainWindow::open() { QString filename = QFileDialog::getOpenFileName(0, "Open File", "", "*.jpg *.png *.bmp", 0); if (!filename.isEmpty()) { loadFile(filename); show_image(); } }
void sceneShow::show_scene(int n) { if (n < 0) { return; } if (scene_list.size() <= n) { std::cout << "ERROR: Scene List[" << n << "] invalid. List size is " << image_scenes.size() << "." << std::endl; return; } CURRENT_FILE_FORMAT::file_scene_list scene = scene_list.at(n); input.clean(); for (int i=0; i<SCENE_OBJECTS_N; i++) { input.read_input(); int scene_seek_n = scene.objects[i].seek_n; //std::cout << ">> sceneShow::show_scene - i: " << i << ", scene_seek_n: " << scene_seek_n << std::endl; if (_interrupt_scene == true || input.p1_input[BTN_START] == 1) { scene_seek_n = -1; break; } if (scene_seek_n != -1) { int scene_type = scene.objects[i].type; //std::cout << "### scene_type[" << scene_type << "]" << std::endl; if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_TEXT) { show_text(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_AREA) { clear_area(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_SCREEN) { graphLib.clear_area(0 ,0, RES_W, RES_H, 0, 0, 0); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_IMAGE) { show_image(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_VIEWPOINT) { show_viewpoint(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_MUSIC) { play_music(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_SFX) { play_sfx(scene_seek_n); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_ANIMATION) { show_animation(scene_seek_n, scene.objects[i].repeat_value, scene.objects[i].repeat_type); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_STOP_MUSIC) { soundManager.stop_music(); } else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SUBSCENE) { show_scene(scene_seek_n); } else { std::cout << ">> sceneShow::show_scene - unknown scene_type[" << scene_type << "]" << std::endl; } std::cout << "show_scene::DELAY[" << i << "][" << scene.objects[i].delay_after << "]" << std::endl; if (input.waitScapeTime(scene.objects[i].delay_after) == 1) { _interrupt_scene = true; } } else { break; } } std::cout << "show_scene::DONE" << std::endl; }
void inter_dcgan(char *cfgfile, char *weightfile) { network *net = load_network(cfgfile, weightfile, 0); set_batch_network(net, 1); srand(2222222); clock_t time; char buff[256]; char *input = buff; int i, imlayer = 0; for (i = 0; i < net->n; ++i) { if (net->layers[i].out_c == 3) { imlayer = i; printf("%d\n", i); break; } } image start = random_unit_vector_image(net->w, net->h, net->c); image end = random_unit_vector_image(net->w, net->h, net->c); image im = make_image(net->w, net->h, net->c); image orig = copy_image(start); int c = 0; int count = 0; int max_count = 15; while(1){ ++c; if(count == max_count){ count = 0; free_image(start); start = end; end = random_unit_vector_image(net->w, net->h, net->c); if(c > 300){ end = orig; } if(c>300 + max_count) return; } ++count; slerp(start.data, end.data, (float)count / max_count, im.w*im.h*im.c, im.data); float *X = im.data; time=clock(); network_predict(net, X); image out = get_network_image_layer(net, imlayer); //yuv_to_rgb(out); normalize_image(out); printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time)); //char buff[256]; sprintf(buff, "out%05d", c); save_image(out, "out"); save_image(out, buff); show_image(out, "out", 0); } }
void getNewCard(){ count = count%13 +1; int ran = rand()%4; int pick = rand()%14+1; ran = 13*ran + pick -1; show_image(*(poker+ran),(*(poker_place+(count%4))).x,(*(poker_place+(count%4))).y); //show_image(*(countingNum+ran),*(counting_place+(count%2)).x,*(poker_place+(count%2)).y); temp_ShowCounting(count); }
void ShowHelp(void) { clearScreen(); Image *help = read_image("help.pixel","help.color"); show_image(help,100,10); drawCmdWindow(); /* update window immediately */ Sleep(500); // <--- Sleep()單位是ms, sleep()單位是s }
int main(int argc, char **argv) { static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"device", required_argument, 0, 'd'}, {"alpha", no_argument, 0, 'a'}, {"stretch", no_argument, 0, 'f'}, {"colorstrech", no_argument, 0, 'k'}, {"enlarge", no_argument, 0, 'e'}, {"ignore-aspect", no_argument, 0, 'r'}, {0, 0, 0, 0} }; int c; char *devicename=NULL; while((c = getopt_long_only(argc, argv, "hd:afks:er", long_options, NULL)) != EOF) { switch(c) { case 'd': devicename = optarg; break; case 'c': opt_dont_clear = 1; break; case 'a': opt_alpha = 1; break; case 'h': help(argv[0]); return(0); case 'f': opt_stretch = 1; break; case 'k': opt_stretch = 2; break; case 'e': opt_enlarge = 1; break; case 'r': opt_ignore_aspect = 1; break; } } signal(SIGHUP, sighandler); signal(SIGINT, sighandler); signal(SIGQUIT, sighandler); signal(SIGSEGV, sighandler); signal(SIGTERM, sighandler); signal(SIGABRT, sighandler); show_image(devicename); return(0); }
int main(int argc, char * argv[]) { // Pass command line arguments to rclcpp. rclcpp::init(argc, argv); // Initialize default demo parameters size_t depth = 10; rmw_qos_reliability_policy_t reliability_policy = RMW_QOS_POLICY_RELIABILITY_RELIABLE; rmw_qos_history_policy_t history_policy = RMW_QOS_POLICY_HISTORY_KEEP_ALL; bool show_camera = true; // Configure demo parameters with command line options. if (!parse_command_options(argc, argv, &depth, &reliability_policy, &history_policy, &show_camera)) { return 0; } if (show_camera) { // Initialize an OpenCV named window called "showimage". cvNamedWindow("showimage", CV_WINDOW_AUTOSIZE); } // Initialize a ROS node. auto node = rclcpp::node::Node::make_shared("showimage"); // Set quality of service profile based on command line options. rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_default; // The history policy determines how messages are saved until the message is taken by the reader. // KEEP_ALL saves all messages until they are taken. // KEEP_LAST enforces a limit on the number of messages that are saved, specified by the "depth" // parameter. custom_qos_profile.history = history_policy; // Depth represents how many messages to store in history when the history policy is KEEP_LAST. custom_qos_profile.depth = depth; // The reliability policy can be reliable, meaning that the underlying transport layer will try // ensure that every message gets received in order, or best effort, meaning that the transport // makes no guarantees about the order or reliability of delivery. custom_qos_profile.reliability = reliability_policy; auto callback = [show_camera](const sensor_msgs::msg::Image::SharedPtr msg) { show_image(msg, show_camera); }; // Initialize a subscriber that will receive the ROS Image message to be displayed. auto sub = node->create_subscription<sensor_msgs::msg::Image>( "image", callback, custom_qos_profile); rclcpp::spin(node); return 0; }
static void show_image_change_notify (GtkImageMenuItem *image_menu_item) { if (image_menu_item->image) { if (show_image (image_menu_item)) gtk_widget_show (image_menu_item->image); else gtk_widget_hide (image_menu_item->image); } }
void show_image_layers(image p, char *name) { int i; char buff[256]; for(i = 0; i < p.c; ++i){ sprintf(buff, "%s - Layer %d", name, i); image layer = get_image_layer(p, i); show_image(layer, buff); free_image(layer); } }
void Loser() { loseTimes++; int count=1; Image *loser; int ran,i; srand( time(NULL) ); ran=rand()%2; while(count<=6) { clearScreen(); switch(count) { case 1: loser= read_image("Loser1.pixel","Loser1.color"); break; case 2: loser= read_image("Loser2.pixel","Loser2.color"); break; case 3: loser= read_image("Loser3.pixel","Loser3.color"); break; case 4: loser= read_image("Loser4.pixel","Loser4.color"); break; case 5: loser= read_image("Loser5.pixel","Loser5.color"); break; case 6: loser= read_image("Loser6.pixel","Loser6.color"); default: break; } count++; show_image(loser,120,35); drawCmdWindow(); /* update window immediately */ for(i=0; i<1; i++) { playAudio(&audioLose[ran]); //Sleep(100); } Sleep(300); } destroy_image(loser); showTable(); }
static void gtk_image_menu_item_map (GtkWidget *widget) { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget); GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->map (widget); if (image_menu_item->image) g_object_set (image_menu_item->image, "visible", show_image (image_menu_item), NULL); }
void test_resize(char *filename) { image im = load_image(filename, 0,0, 3); image gray = grayscale_image(im); image sat2 = copy_image(im); saturate_image(sat2, 2); image sat5 = copy_image(im); saturate_image(sat5, .5); image exp2 = copy_image(im); exposure_image(exp2, 2); image exp5 = copy_image(im); exposure_image(exp5, .5); show_image(im, "Original"); show_image(gray, "Gray"); show_image(sat2, "Saturation-2"); show_image(sat5, "Saturation-.5"); show_image(exp2, "Exposure-2"); show_image(exp5, "Exposure-.5"); #ifdef OPENCV cvWaitKey(0); #endif }
void demo_regressor(char *datacfg, char *cfgfile, char *weightfile, int cam_index, const char *filename) { #ifdef OPENCV printf("Regressor Demo\n"); network net = parse_network_cfg(cfgfile); if(weightfile){ load_weights(&net, weightfile); } set_batch_network(&net, 1); srand(2222222); CvCapture * cap; if(filename){ cap = cvCaptureFromFile(filename); }else{ cap = cvCaptureFromCAM(cam_index); } if(!cap) error("Couldn't connect to webcam.\n"); cvNamedWindow("Regressor", CV_WINDOW_NORMAL); cvResizeWindow("Regressor", 512, 512); float fps = 0; while(1){ struct timeval tval_before, tval_after, tval_result; gettimeofday(&tval_before, NULL); image in = get_image_from_stream(cap); image in_s = letterbox_image(in, net.w, net.h); show_image(in, "Regressor"); float *predictions = network_predict(net, in_s.data); printf("\033[2J"); printf("\033[1;1H"); printf("\nFPS:%.0f\n",fps); printf("People: %f\n", predictions[0]); free_image(in_s); free_image(in); cvWaitKey(10); gettimeofday(&tval_after, NULL); timersub(&tval_after, &tval_before, &tval_result); float curr = 1000000.f/((long int)tval_result.tv_usec); fps = .9*fps + .1*curr; } #endif }