Exemplo n.º 1
0
static vx_status vxCheckBufferKernel(vx_node node, vx_reference *parameters, vx_uint32 num)
{
    vx_status status = VX_SUCCESS;
    if (num == 3)
    {
        vx_scalar buffer = (vx_buffer)parameters[0];
        vx_scalar fill = (vx_scalar)parameters[1];
        vx_scalar errs = (vx_scalar)parameters[2];
        vx_uint8 value = 0u;
        vx_size numUnits = 0ul, unitSize = 0ul, size = 0ul;
        vx_uint32 errors = 0;
        vx_uint8 *ptr = NULL;

        vxQueryBuffer(buffer, VX_BUFFER_ATTRIBUTE_NUMUNITS, &numUnits, sizeof(numUnits));
        vxQueryBuffer(buffer, VX_BUFFER_ATTRIBUTE_UNITSIZE, &unitSize, sizeof(unitSize));
        vxQueryBuffer(buffer, VX_BUFFER_ATTRIBUTE_SIZE, &size, sizeof(size));
        vxAccessScalarValue(fill, (void *)&value);
        status = vxAccessBufferRange(buffer, 0, numUnits, (void **)&ptr);
        if (status == VX_SUCCESS)
        {
            vx_size i = 0;
            for (i = 0ul; i < size; i++)
            {
                if (ptr[i] != value)
                {
                    errors++;
                }
            }
            vxCommitScalarValue(errs, &errors);
            if (errors > 0)
            {
                vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Check buffer %p of "VX_FMT_SIZE" bytes with 0x%02x, found %u errors\n", ptr, size, value, errors);
            }
            status = vxCommitBufferRange(buffer, 0, numUnits, ptr);
            if (status != VX_SUCCESS)
            {
                vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Failed to set buffer range for "VX_FMT_REF"\n", buffer);
            }
        }
        else
        {
            vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Failed to get buffer range for "VX_FMT_REF"\n", buffer);
        }
        if (errors > 0)
        {
            status = VX_FAILURE;
        }
    }
    return status;
}
Exemplo n.º 2
0
vx_status vxMatrixTrace(vx_matrix matrix, vx_scalar trace) {
    vx_size columns = 0u;
    vx_size rows = 0u;
    vx_status status = VX_SUCCESS;
    vx_enum mtype = VX_TYPE_INVALID, stype = VX_TYPE_INVALID;

    status |= vxQueryMatrix(matrix, VX_MATRIX_ATTRIBUTE_COLUMNS, &columns, sizeof(columns));
    status |= vxQueryMatrix(matrix, VX_MATRIX_ATTRIBUTE_ROWS, &rows, sizeof(rows));
    status |= vxQueryMatrix(matrix, VX_MATRIX_ATTRIBUTE_TYPE, &mtype, sizeof(mtype));
    status |= vxQueryScalar(trace, VX_SCALAR_ATTRIBUTE_TYPE, &stype, sizeof(stype));

    if (status != VX_SUCCESS)
        return VX_ERROR_INVALID_REFERENCE;
    if (mtype == VX_TYPE_INVALID || mtype != stype)
        return VX_ERROR_INVALID_TYPE;
    if (columns == 0 || columns != rows)
        return VX_ERROR_INVALID_DIMENSION;

    if (stype == VX_TYPE_INT32) {
        vx_int32 mat[rows][columns];
        vx_int32 t = 0;
        status |= vxAccessScalarValue(trace, NULL);
        status |= vxAccessMatrix(matrix, mat);
        t = vxh_matrix_trace_i32(columns, rows, mat);
        status |= vxCommitMatrix(matrix, NULL);
        status |= vxCommitScalarValue(trace, &t);
    } else if (stype == VX_TYPE_FLOAT32) {
        vx_float32 mat[rows][columns];
        vx_float32 t = 0.0f;
        status |= vxAccessScalarValue(trace, NULL);
        status |= vxAccessMatrix(matrix, mat);
        t = vxh_matrix_trace_f32(columns, rows, mat);
        status |= vxCommitMatrix(matrix, NULL);
        status |= vxCommitScalarValue(trace, &t);
    }
    return status;
}
Exemplo n.º 3
0
VX_API_ENTRY vx_scalar VX_API_CALL vxCreateScalar(vx_context context, vx_enum data_type, void *ptr)
{
    vx_scalar scalar = NULL;

    if (vxIsValidContext(context) == vx_false_e)
        return 0;

    if (!VX_TYPE_IS_SCALAR(data_type))
    {
        VX_PRINT(VX_ZONE_ERROR, "Invalid type to scalar\n");
        vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid type to scalar\n");
        scalar = (vx_scalar)vxGetErrorObject(context, VX_ERROR_INVALID_TYPE);
    }
    else
    {
        scalar = (vx_scalar)vxCreateReference(context, VX_TYPE_SCALAR, VX_EXTERNAL, &context->base);
        if (scalar && scalar->base.type == VX_TYPE_SCALAR)
        {
            scalar->data_type = data_type;
            vxCommitScalarValue(scalar, ptr);
        }
    }
    return (vx_scalar)scalar;
}
Exemplo n.º 4
0
static vx_status vxCheckImageKernel(vx_node node, vx_reference *parameters, vx_uint32 num)
{
    vx_status status = VX_SUCCESS;
    if (num == 3)
    {
        vx_image image = (vx_image)parameters[0];
        vx_scalar fill = (vx_scalar)parameters[1];
        vx_scalar errs = (vx_scalar)parameters[2];
        packed_value_u value;
        vx_uint32 planes = 0u, count = 0u, errors = 0u;
        vx_uint32 x = 0u, y = 0u, p = 0u;
        vx_int32 i = 0;
        vx_imagepatch_addressing_t addr;
        vx_rectangle rect;

        value.dword[0] = 0xDEADBEEF;
        vxAccessScalarValue(fill, &value.dword[0]);
        vxQueryImage(image, VX_IMAGE_ATTRIBUTE_PLANES, &planes, sizeof(planes));
        rect = vxGetValidRegionImage(image);
        for (p = 0u; (p < planes) && (rect); p++)
        {
            void *ptr = NULL;
            status = vxAccessImagePatch(image, rect, p, &addr, &ptr);
            if ((status == VX_SUCCESS) && (ptr))
            {
                for (y = 0; y < addr.dim_y; y+=addr.step_y)
                {
                    for (x = 0; x < addr.dim_x; x+=addr.step_x)
                    {
                        vx_uint8 *pixel = vxFormatImagePatchAddress2d(ptr, x, y, &addr);
                        for (i = 0; i < addr.stride_x; i++)
                        {
                            count++;
                            if (pixel[i] != value.bytes[i])
                            {
                                errors++;
                            }
                        }
                    }
                }
                if (errors > 0)
                {
                    vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Checked %p of %u sub-pixels with 0x%08x with %u errors\n", ptr, count, value.dword, errors);
                }
                vxCommitScalarValue(errs, &errors);
                status = vxCommitImagePatch(image, 0, p, &addr, ptr);
                if (status != VX_SUCCESS)
                {
                    vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Failed to set image patch for "VX_FMT_REF"\n", image);
                }
            }
            else
            {
                vxAddLogEntry(vxGetContext(node), VX_FAILURE, "Failed to get image patch for "VX_FMT_REF"\n", image);
            }
        }
        vxReleaseRectangle(&rect);
        if (errors > 0)
        {
            status = VX_FAILURE;
        }
    }
    return status;
}