Results 1 to 2 of 2

Thread: Inconsistent output in Warp affine kernel

  1. #1

    Inconsistent output in Warp affine kernel

    Hi
    We are executing warp affine kernel. We the test application is executed multiple times, different output is seen though the input remains the same.
    Please help us in resolving the issue.
    Thank you
    Last edited by manjunatha.hg; 07-19-2018 at 12:27 AM.

  2. #2
    Attachments:

    #include "test_common.h"

    void Usage(unsigned char flag)
    {
    if(flag) {
    printf("Usage: vx_warpAffine_test <width> <height> <target> <interpolation> <borderMode>"
    "<iteration>\n"
    "Target : %d - c-model [openvx default] \n"

    "Interpolation : %d - Nearest Neighbour \n"
    " %d - Bilinear \n"
    "BorderMode : %d - BORDER_UNDEFINED_MODE \n"
    " %d - BORDER_CONSTANT_MODE (val : 10) \n"
    " %d - BORDER_REPLICATE_MODE (val : 10) \n"
    "Iteration : (optional, def :1)No of executions of process graph \n",
    TARGET_OPENVX_CMODEL, INTERPOLATION_NEAREST_NEIGHBOR,
    INTERPOLATION_BILINEAR, BORDER_UNDEFINED_MODE, BORDER_CONSTANT_MODE,
    BORDER_REPLICATE_MODE);
    } else if (flag == 2){
    printf("Requested Invalid target! \n"
    "Target : %d - c-model [openvx default] \n",
    TARGET_OPENVX_CMODEL);
    } else if (flag == 3) {
    printf("Invalid Border Mode! \n"
    "BorderMode : %d - BORDER_UNDEFINED_MODE \n"
    " %d - BORDER_CONSTANT_MODE \n"
    " %d - BORDER_REPLICATE_MODE \n",
    BORDER_UNDEFINED_MODE, BORDER_CONSTANT_MODE, BORDER_REPLICATE_MODE);
    } else {
    printf("Usage: vx_warpAffine_test <width> <height> <target> <mode> <interpolation> "
    "<file name> \n");
    }
    exit(0);

    return ;
    }

    /**
    * vx_warpAffine_test <width> <height> <target> <type> <interpolation> <borderMode>
    * performs affine transformation of input image on the selected target
    * and verifies the output with the default target (C-model).
    */

    int main(int argc, char *argv[]) {
    if (argc < 6) {
    Usage(1);
    }

    // Check command line arguments and initialise variables
    int cnt, misMatch = 0;
    vx_uint32 width = atoi(argv[1]); // image width
    vx_uint32 height = atoi(argv[2]); // image height
    vx_uint32 mode;
    int qctarget = 0;

    // Configure target
    qctarget = atoi(argv[3]);
    if (qctarget >= TARGET_MAX) {
    Usage(2);
    }

    // Configure overflow handling policy as per user parameter
    vx_enum type;
    vx_matrix matrix;
    vx_context context;
    vx_graph refGraph;
    vx_node refNode;
    vx_image src, refDst;
    vx_rectangle_t imgRegion;
    vx_imagepatch_addressing_t imgAddrIn, imgAddrOutRef;
    void *srcBase = NULL, *refBase = NULL;
    vx_map_id mapIdIn = 0;
    vx_map_id mapIdOut[2] = {0};
    vx_size row = 3, col = 2;
    vx_float32 a = 3.0f, b = 2.0f, c = 11.0f;
    vx_float32 d = 1.0f, e = 5.0f, f = 4.0f;
    vx_float32 mat[3][2] = {
    {a, d}, // 'x' coefficients
    {b, e}, // 'y' coefficients
    {c, f}, // 'offsets'
    };

    if (atoi(argv[4]) == 0) {
    type = VX_INTERPOLATION_NEAREST_NEIGHBOR;
    printf("\x1b[33m Test case : Nearest neighbor ");
    } else if (atoi(argv[4]) == 1) {
    type = VX_INTERPOLATION_BILINEAR;
    printf("\x1b[33m Test case : Bilinear ");
    }
    unsigned int numIter = 1;
    if (argc > 6) {
    numIter = atoi(argv[6]);
    }
    unsigned int borderVal = 0;
    vx_border_t border;
    borderVal = atoi(argv[5]);
    //Configure border type
    switch (borderVal) {
    case BORDER_UNDEFINED_MODE: {
    printf("BorderUndefined \x1b[0m\n ");
    border.mode = VX_BORDER_UNDEFINED;
    break;
    }
    case BORDER_CONSTANT_MODE: {
    printf("BorderConstant \x1b[0m\n ");
    border.mode = VX_BORDER_CONSTANT;
    border.constant_value.U8 = 10;
    break;
    }
    case BORDER_REPLICATE_MODE: {
    printf("BorderReplicate \x1b[0m\n");
    border.mode = VX_BORDER_REPLICATE;
    border.constant_value.U8 = 10;
    break;
    }
    default: {
    Usage(3);
    break;
    }
    }

    // Create openvx context
    context = vxCreateContext();
    ERROR_CHECK_OBJECT(context);

    // Create openvx graph objects
    refGraph = vxCreateGraph(context);
    ERROR_CHECK_OBJECT(refGraph);

    // Create Images
    src = vxCreateImage(context, width, height, VX_DF_IMAGE_U;
    refDst = vxCreateImage(context, width, height, VX_DF_IMAGE_U;

    matrix = vxCreateMatrix(context, VX_TYPE_FLOAT32, col, row);
    ERROR_CHECK_OBJECT(matrix);
    ERROR_CHECK_OBJECT(src);
    ERROR_CHECK_OBJECT(refDst);

    // Configure input parameters to create addition node
    imgRegion.start_x = 0;
    imgRegion.start_y = 0;
    imgRegion.end_x = width;
    imgRegion.end_y = height;

    // Map input openvx images to fill data
    ERROR_CHECK_STATUS(vxMapImagePatch(src, &imgRegion, 0, &mapIdIn, &imgAddrIn,
    (void **)&srcBase, VX_READ_AND_WRITE, VX_MEMORY_TYPE_HOST, 0));
    vxCopyMatrix(matrix, mat, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);

    printf("....Random input Mode.....\n");
    // Fill random input data
    for (cnt = 0; cnt < (width * height); cnt++) {
    *((unsigned char*)srcBase + cnt) = rand() & 0xFF;
    }
    printf("*********input***********\n");
    uint8_t *inptr = (uint8_t *)srcBase;
    for(int i = 0; i < height; i++)
    {
    for(int j = 0; j < width; j++)
    {
    printf("%3d ", inptr[i * width + j]);
    }
    printf("\n");
    }

    //Umap source buffer
    ERROR_CHECK_STATUS(vxUnmapImagePatch(src, mapIdIn));

    // Create openvx addition node
    refNode = vxWarpAffineNode(refGraph , src, matrix, type, refDst);

    //Set border attribute for both the nodes
    ERROR_CHECK_STATUS(vxSetNodeAttribute(refNode, VX_NODE_BORDER, &border,
    (vx_size) sizeof(vx_border_t)));

    // Set default target for reference
    printf("%s, %d: selected target: TARGET_OPENVX_CMODEL \n", __func__, __LINE__);
    ERROR_CHECK_STATUS(vxSetNodeTarget(refNode, VX_TARGET_STRING, "khronos.any"));

    // Verify graph before processing
    ERROR_CHECK_STATUS(vxVerifyGraph(refGraph));

    // Enable to profile openvx graph node processing
    context->perf_enabled = vx_true_e;

    // Process graph
    for (unsigned int ind = 0; ind < NUM_ITER_C; ind++) {
    ERROR_CHECK_STATUS(vxProcessGraph(refGraph));
    }

    // Access output openvx images to verify the result
    ERROR_CHECK_STATUS(vxMapImagePatch(refDst, &imgRegion, 0, &mapIdOut[0], &imgAddrOutRef,
    (void **)&refBase, VX_READ_AND_WRITE, VX_MEMORY_TYPE_HOST, 0));

    //printing ouput
    printf("*********reference output***********\n");
    uint8_t *refptr = (uint8_t *)refBase;
    for(int i = 0; i < height; i++)
    {
    for(int j = 0; j < width; j++)
    {
    printf("%3d ", refptr[i * width + j]);
    }
    printf("\n");
    }
    // Unmap and commit image patches after access
    ERROR_CHECK_STATUS(vxUnmapImagePatch(refDst, mapIdOut[0]));
    // Release all allocated resources
    ERROR_CHECK_STATUS(vxReleaseImage(&src));
    ERROR_CHECK_STATUS(vxReleaseMatrix(&matrix));
    ERROR_CHECK_STATUS(vxReleaseImage(&refDst));
    ERROR_CHECK_STATUS(vxReleaseGraph(&refGraph));
    ERROR_CHECK_STATUS(vxReleaseContext(&context));

    return 0;
    }

    - - - Updated - - -

    Logs:
    manjunatha.hg@CPU-306U:~/Documents/openvx_sample/build/Linux/x64/Release/sample/tests$ ./vx_warpAffineStandalone 16 16 0 1 0
    Test case : Bilinear BorderUndefined
    ....Random input Mode.....
    *********input***********
    103 198 105 115 81 255 74 236 41 205 186 171 242 251 227 70
    124 194 84 248 27 232 231 141 118 90 46 99 51 159 201 154
    102 50 13 183 49 88 163 90 37 93 5 23 88 233 94 212
    171 178 205 198 155 180 84 17 14 130 116 65 33 61 220 135
    112 233 62 161 65 225 252 103 62 1 126 151 234 220 107 150
    143 56 92 42 236 176 59 251 50 175 60 84 236 24 219 92
    2 26 254 67 251 250 170 58 251 41 209 230 5 60 124 148
    117 216 190 97 137 249 92 187 168 153 15 149 177 235 241 179
    5 239 247 0 233 161 58 229 202 11 203 208 72 71 100 189
    31 35 30 168 28 123 100 197 20 115 90 197 94 75 121 99
    59 112 100 36 17 158 9 220 170 212 172 242 27 16 175 59
    51 205 227 80 72 71 21 92 187 111 34 25 186 155 125 245
    11 225 26 28 127 35 248 41 248 164 27 19 181 202 78 232
    152 50 56 224 121 77 61 52 188 95 78 119 250 203 108 5
    172 134 33 43 170 26 85 162 190 112 181 115 59 4 92 211
    54 148 179 175 226 240 228 158 79 50 21 73 253 130 78 169
    main, 193: selected target: TARGET_OPENVX_CMODEL
    *********reference output***********
    151 219 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    75 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0
    0 126 65 1 0 0 0 0 24 186 207 203 99 127 0 0
    0 0 0 0 0 0 0 0 17 61 1 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    manjunatha.hg@CPU-306U:~/Documents/openvx_sample/build/Linux/x64/Release/sample/tests$ ./vx_warpAffineStandalone 16 16 0 1 0
    Test case : Bilinear BorderUndefined
    ....Random input Mode.....
    *********input***********
    103 198 105 115 81 255 74 236 41 205 186 171 242 251 227 70
    124 194 84 248 27 232 231 141 118 90 46 99 51 159 201 154
    102 50 13 183 49 88 163 90 37 93 5 23 88 233 94 212
    171 178 205 198 155 180 84 17 14 130 116 65 33 61 220 135
    112 233 62 161 65 225 252 103 62 1 126 151 234 220 107 150
    143 56 92 42 236 176 59 251 50 175 60 84 236 24 219 92
    2 26 254 67 251 250 170 58 251 41 209 230 5 60 124 148
    117 216 190 97 137 249 92 187 168 153 15 149 177 235 241 179
    5 239 247 0 233 161 58 229 202 11 203 208 72 71 100 189
    31 35 30 168 28 123 100 197 20 115 90 197 94 75 121 99
    59 112 100 36 17 158 9 220 170 212 172 242 27 16 175 59
    51 205 227 80 72 71 21 92 187 111 34 25 186 155 125 245
    11 225 26 28 127 35 248 41 248 164 27 19 181 202 78 232
    152 50 56 224 121 77 61 52 188 95 78 119 250 203 108 5
    172 134 33 43 170 26 85 162 190 112 181 115 59 4 92 211
    54 148 179 175 226 240 228 158 79 50 21 73 253 130 78 169
    main, 193: selected target: TARGET_OPENVX_CMODEL
    *********reference output***********
    151 219 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    75 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0
    0 30 173 0 0 0 0 0 24 42 134 159 106 127 0 0
    0 0 0 0 0 0 0 0 17 61 1 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    manjunatha.hg@CPU-306U:~/Documents/openvx_sample/build/Linux/x64/Release/sample/tests$

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