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


C++ resize_image函数代码示例

本文整理汇总了C++中resize_image函数的典型用法代码示例。如果您正苦于以下问题:C++ resize_image函数的具体用法?C++ resize_image怎么用?C++ resize_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: retrieve_name

void WadImageCache::cache_image(WadImageDescriptor& desc, int width, int height, SDL_Surface *image)
{
	std::string name = retrieve_name(desc, width, height, true);
	if (!name.empty())
	{
		autosave_cache();
		return;
	}
	
	SDL_Surface *resized_image = NULL;
	if (image)
	{
		resized_image = resize_image(image, width, height);
	}
	else
	{
		image = image_from_desc(desc);
		if (image)
		{
			resized_image = resize_image(image, width, height);
			SDL_FreeSurface(image);
		}
	}
	if (!resized_image)
		return;
	
	name = add_to_cache(cache_key_t(desc, width, height), resized_image);
	SDL_FreeSurface(resized_image);
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:29,代码来源:WadImageCache.cpp

示例2: draw_label

void draw_label(image a, int r, int c, image label, image prob_label, const float *rgb)
{
    float ratio = (float) label.w / label.h;
    int h = label.h;
    int w = ratio * h;
    image rl = resize_image(label, w, h);
    if (r - h >= 0) r = r - h;
    float ratiop = (float) prob_label.w / prob_label.h;
    int hp = prob_label.h;
    int wp = ratiop * hp;
    image rpl = resize_image(prob_label, wp, hp);

    int i, j, k;
    for(j = 0; j < h && j + r < a.h; ++j){
        for(i = 0; i < w && i + c < a.w; ++i){
            for(k = 0; k < label.c; ++k){
                float val = get_pixel(rl, i, j, k);
                set_pixel(a, i+c+50, j+r, k, rgb[k] * val);
            }
        }
    }
    for(j = 0; j < hp && j + r < a.h; ++j){
        for(i = 0; i < wp && i + c < a.w; ++i){
            for(k = 0; k < prob_label.c; ++k){
                float val = get_pixel(rpl, i, j, k);
                set_pixel(a, i+c, j+r, k, rgb[k] * val);
            }
        }
    }
    free_image(rl);
    free_image(rpl);
}
开发者ID:jjmata,项目名称:cvjena-darknet,代码行数:32,代码来源:image.c

示例3: retrieve_image

SDL_Surface *WadImageCache::get_image(WadImageDescriptor& desc, int width, int height, SDL_Surface *image)
{
	SDL_Surface *surface = retrieve_image(desc, width, height);
	if (surface)
		return surface;

	if (image)
	{
		surface = resize_image(image, width, height);
	}
	else
	{
		image = image_from_desc(desc);
		if (image)
		{
			surface = resize_image(image, width, height);
			SDL_FreeSurface(image);
		}
	}

	if (surface)
	{
		add_to_cache(cache_key_t(desc, width, height), surface);
	}
	return surface;
}
开发者ID:blezek,项目名称:marathon-ios,代码行数:26,代码来源:WadImageCache.cpp

示例4: create_ios_launch_images

static bool create_ios_launch_images(const char *dir, export_config *conf) {
    size_t len;
    stbi_uc *img_data;
    int width, height;
    if (conf->launch_image == NULL) {
        width = 1024;
        height = 1024;
        len = width * height * 4;
        img_data = (stbi_uc*)malloc(len);
        memset(img_data, 255, len);
    } else {
        void *data = am_read_file(conf->launch_image, &len);
        int components = 4;
        stbi_set_flip_vertically_on_load(0);
        img_data =
            stbi_load_from_memory((stbi_uc const *)data, len, &width, &height, &components, 4);
        free(data);
        if (img_data == NULL) return false;
    }
    if (!resize_image(img_data, width, height, dir,    "Default.png", 320, 480)
        || !resize_image(img_data, width, height, dir, "[email protected]", 640, 960)
        || !resize_image(img_data, width, height, dir, "[email protected]", 640, 1136)
        || !resize_image(img_data, width, height, dir, "[email protected]", 750, 1334)
        || !resize_image(img_data, width, height, dir, "[email protected]", 1242, 2208)
        || !resize_image(img_data, width, height, dir, "[email protected]~ipad.png", 2048, 1536)
        || !resize_image(img_data, width, height, dir, "Default-Landscape~ipad.png", 1024, 768)
        || !resize_image(img_data, width, height, dir, "[email protected]~ipad.png", 1536, 2048)
        || !resize_image(img_data, width, height, dir, "Default-Portrait~ipad.png", 768, 1024)
        ) return false;
    free(img_data);
    return true;
}
开发者ID:AntonioModer,项目名称:amulet,代码行数:32,代码来源:am_export.cpp

示例5: yoloPredict

/*
 * do prediction
  *@param[in]: yoloctx, context
  *@param[in]: filename, input picture
  *@param[in]: thresh, threshold for probability x confidence level
  *@param[out]: predictions, store detected objects
*/
void yoloPredict(context_param_yolo_t *yoloctx, char *filename, float thresh, yoloPredictions *predictions)
{
	printf("YOLO predict\n");
	int	nwidth	= yoloctx->_nwidth;
	int nheight = yoloctx->_nheight;
	int side	= yoloctx->_grid.grids;
	int classes = yoloctx->_grid.classes;
	int bbs		= yoloctx->_grid.bbs;
	int sqrt	= yoloctx->_sqrt;
	float nms		= yoloctx->_nms;

	image im	= load_image_color(filename, 0, 0);
	image sized = resize_image(im, nwidth, nheight);
	
	resetData(yoloctx);

	float *x = sized.data;
	float *fpredictions = network_predict(yoloctx->_net, x);

	float	**probs = yoloctx->_grid.probs;
	box		*boxes = yoloctx->_grid.boxes;

	convertDetections(fpredictions, classes, bbs, sqrt, side, 1, 1, thresh, probs, boxes, 0); 
	if (nms) do_nms_sort(boxes, probs, side*side*bbs, classes, nms);
	convertResults(im.w, im.h, side*side*bbs, thresh, boxes, probs, class_names, 20, predictions);
	
	//free(predictions);
	free_image(sized);
	free_image(im);
}
开发者ID:lxgyChen,项目名称:darknet,代码行数:37,代码来源:yolo_.c

示例6: yolo_net_predict

void yolo_net_predict(network *pNet, char *imgfilename, char * resfile, float thresh){
  detection_layer l = pNet->layers[pNet->n-1];
  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 *));

  image im = load_image_color(imgfilename,0,0);
  image resized = resize_image(im, pNet->w, pNet->h);
  float *X = resized.data;
  time=clock();
  float *predictions = network_predict(*pNet, X);
  free_image(im);
  printf("%s: Predicted in %f seconds.\n", imgfilename, sec(clock()-time));

  FILE *ofp = fopen(resfile, "w");
  if (ofp == NULL) {fprintf(stderr, "Can't open output file %s!\n",resfile); exit(1);}

  //convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, demo_thresh, probs, boxes, 0);

  convert_print_yolo_detections(ofp, 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);

  fclose(ofp);

}
开发者ID:forest-jiang,项目名称:Real-time-image-classification,代码行数:30,代码来源:yolo.c

示例7: cvCreateImage

void CAntimonyDlg::showImage(IplImage *image, UINT ID)    // ID 是Picture Control控件的ID号
{
	CvSize ImgSize;
	IplImage *theimg;
	ImgSize.width = picrect.Width();
	ImgSize.height = picrect.Height();
	theimg = cvCreateImage(ImgSize, IPL_DEPTH_8U, 3);
	IplImage *image2 = image;
	resize_image(image2, theimg);

	CDC *pDC = GetDlgItem(ID)->GetDC();
	HDC hDC = pDC->GetSafeHdc();

	int rw = picrect.right - picrect.left;
	int rh = picrect.bottom - picrect.top;
	int iw = theimg->width;
	int ih = theimg->height;
	int tx = (int)(rw - iw) / 2;
	int ty = (int)(rh - ih) / 2;
	SetRect(picrect, tx, ty, tx + iw, ty + ih);
	CvvImage cimg;
	cimg.CopyOf(theimg); // 复制图片
	cimg.DrawToHDC(hDC, &picrect); // 将图片绘制到显示控件的指定区域内
	ReleaseDC(pDC);
}
开发者ID:Spritutu,项目名称:MonitorSYS,代码行数:25,代码来源:AntimonyDlg.cpp

示例8: test_detector

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;
    }
}
开发者ID:apollos,项目名称:eyes,代码行数:59,代码来源:detector.c

示例9: get_image_from_stream

void *fetch_in_thread(void *ptr)
{
    in = get_image_from_stream(cap);
    if(!in.data){
        error("Stream closed.");
    }
    in_s = resize_image(in, net.w, net.h);
    return 0;
}
开发者ID:isuker,项目名称:darknet,代码行数:9,代码来源:demo.c

示例10: resize_image

float *network_predict_image(network *net, image im)
{
    //image imr = letterbox_image(im, net->w, net->h);
    image imr = resize_image(im, net->w, net->h);
    set_batch_network(net, 1);
    float *p = network_predict(*net, imr.data);
    free_image(imr);
    return p;
}
开发者ID:Nuzhny007,项目名称:Multitarget-tracker,代码行数:9,代码来源:network.c

示例11: test_yolo

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;
    }
}
开发者ID:simonfojtu,项目名称:darknet,代码行数:51,代码来源:yolo.c

示例12: load_image

image load_image(char *filename, int w, int h, int c)
{
#ifdef OPENCV
    image out = load_image_cv(filename, c);
#else
    image out = load_image_stb(filename, c);
#endif

    if((h && w) && (h != out.h || w != out.w)){
        image resized = resize_image(out, w, h);
        free_image(out);
        out = resized;
    }
    return out;
}
开发者ID:renmengye,项目名称:darknet,代码行数:15,代码来源:image.c

示例13: test_writing

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;
    }
}
开发者ID:kunle12,项目名称:darknet,代码行数:48,代码来源:writing.c

示例14: test_resize

void test_resize(char *filename)
{
    image im = load_image(filename, 0,0, 3);
    float mag = mag_array(im.data, im.w*im.h*im.c);
    printf("L2 Norm: %f\n", mag);
    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);

    #ifdef GPU
    image r = resize_image(im, im.w, im.h);
    image black = make_image(im.w*2 + 3, im.h*2 + 3, 9);
    image black2 = make_image(im.w, im.h, 3);

    float *r_gpu = cuda_make_array(r.data, r.w*r.h*r.c);
    float *black_gpu = cuda_make_array(black.data, black.w*black.h*black.c);
    float *black2_gpu = cuda_make_array(black2.data, black2.w*black2.h*black2.c);
    shortcut_gpu(3, r.w, r.h, 1, r_gpu, black.w, black.h, 3, black_gpu);
    //flip_image(r);
    //shortcut_gpu(3, r.w, r.h, 1, r.data, black.w, black.h, 3, black.data);

    shortcut_gpu(3, black.w, black.h, 3, black_gpu, black2.w, black2.h, 1, black2_gpu);
    cuda_pull_array(black_gpu, black.data, black.w*black.h*black.c);
    cuda_pull_array(black2_gpu, black2.data, black2.w*black2.h*black2.c);
    show_image_layers(black, "Black");
    show_image(black2, "Recreate");
    #endif

    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
}
开发者ID:jjmata,项目名称:cvjena-darknet,代码行数:48,代码来源:image.c

示例15: get_gray

float *get_image_dct( const IplImage *src, const int nSub, int &featLen ) {
    IplImage *img = get_gray( src ); 
    IplImage *subImage = resize_image( img, nSub ); 
    IplImage *dctImage = cvCloneImage( subImage );

    cvDCT( subImage, dctImage, CV_DXT_FORWARD );
//  print_32f_image( dctImage );

//  float *data = ( float * )( dctImage->imageData );
//  qsort( data + 1, nSub * nSub - 1, sizeof( float ), cmp );
//  print_32f_image( dctImage );
    
    int subDct = 6;
    featLen = subDct * subDct - 1;
    int index = 0;
    float *feature = new float[ featLen ];
    /*copy only 35 points of dcts*/
    for ( int y = 0; y < subDct; y++ ) {
        for ( int x = 0; x < subDct; x++ ) {
            if ( x == 0 && y == 0 ) 
                continue;
            feature[ index++ ] = pixval32f( dctImage, x, y );
        }
    }

    /*print the feature without sort*/
//  print_dct_feature( feature, subDct );

    qsort( feature, featLen, sizeof( float ), cmp );
    //sort( feature, feature + featLen );
    /*print the feature after sort*/
    //print_dct_feature( feature, subDct );
    for ( int i = 0; i < featLen; i++ ) {
        printf( "%.3f\t", feature[ i ] );
    }
    std::cout << endl;

    show_image( img, "gray" );

    cvReleaseImage( &img );
    cvReleaseImage( &subImage );
    cvReleaseImage( &dctImage );

    return feature;
}
开发者ID:cherip,项目名称:dct,代码行数:45,代码来源:dct.cpp


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