Results 1 to 3 of 3

Thread: OpenVX scale does not work

  1. #1
    Newbie
    Join Date
    Sep 2017
    Posts
    2

    OpenVX scale does not work

    Hello,
    I'm trying to scale a grayscale image on my NVIDIA Jetson TX2 GPU, however if I use the pyramid function I always get a blank gray image (a value of 204 at all pixels) and if I use the scale function my program crashes.
    What am I doing wrong? Here is my code (I need to write it in C but if you have an answer only in C++ it is also welcomed):

    void resize_frame(char *input_file, char *output_file, float scaleRatio)
    {
    IplImage *img = cvLoadImage(input_file,1);
    IplImage *img2 = cvCreateImage(cvSize(img->width,img->height), IPL_DEPTH_8U, 1);
    cvCvtColor(img,img2,7);

    vx_context vxContext = vxCreateContext();
    void *ptr = &(img2->imageData[0]);
    vx_imagepatch_addressing_t addr;
    addr.dim_x = img2->width;
    addr.dim_y = img2->height;
    addr.stride_x = sizeof(vx_uint;
    addr.stride_y = addr.stride_x * addr.dim_x;
    addr.step_x = 1;
    addr.step_y = 1;
    vx_image vxImg = vxCreateImageFromHandle(vxContext,VX_DF_IMAGE_U8,& addr,ptr,VX_IMPORT_TYPE_HOST);

    int outW = (int)(img2->width * scaleRatio);
    int outH = (int)(img2->height * scaleRatio);

    if(1)
    {
    vx_pyramid pyr = vxCreatePyramid(vxContext, 2, scaleRatio, img2->width, img2->height, VX_DF_IMAGE_U;
    vx_image vxOutImg = vxGetPyramidLevel(pyr,1);
    }
    else
    {
    vx_image vxOutImg = vxCreateImage(vxContext,outW,outH,VX_DF_IMAGE_U;
    vxuScaleImage(vxContext,vxImg,vxOutImg,VX_INTERPOL ATION_TYPE_BILINEAR);
    }

    IplImage *outImg = cvCreateImage(cvSize(outW,outH), IPL_DEPTH_8U, 1);
    void *ptr1= NULL;
    vx_imagepatch_addressing_t addr1;
    vx_rectangle_t rect1 = {0u,0u,outW,outH};
    vxAccessImagePatch(vxOutImg, &rect1, 0, &addr1, &ptr1 ,VX_READ_ONLY);

    outImg->imageData = ptr1;
    cvSaveImage(output_file,outImg,0);
    vxReleaseImage(vxImg);
    vxReleaseImage(vxOutImg);
    cvReleaseImage(&img);
    cvReleaseImage(&img2);
    cvReleaseImage(&outImg);
    }

    Thank you,
    Haggai

  2. #2
    Newbie
    Join Date
    Sep 2017
    Posts
    2
    Quote Originally Posted by haggaia View Post
    ... if I use the pyramid function I always get a blank gray image (a value of 204 at all pixels) ...
    Looks like the pyramid was created without any operation to compute into the pyramid object.

  3. #3
    Newbie
    Join Date
    Sep 2017
    Posts
    2
    Quote Originally Posted by radha.giduthuri View Post
    Looks like the pyramid was created without any operation to compute into the pyramid object.
    Thanks for the answer and sorry if I make such simple mistakes, I'm totally new to openVX. But why does it crash if I use the vxuScaleImage function?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean