コード例 #1
0
ファイル: vx_array.c プロジェクト: ChiahungTai/clairvoyance
VX_API_ENTRY vx_array VX_API_CALL vxCreateVirtualArray(vx_graph graph, vx_enum item_type, vx_size capacity)
{
    vx_array arr = NULL;

    if (vxIsValidSpecificReference(&graph->base, VX_TYPE_GRAPH) == vx_true_e)
    {
        if (((vxIsValidArrayItemType(graph->base.context, item_type) == vx_true_e) || item_type == VX_TYPE_INVALID))
        {
            arr = (vx_array)vxCreateArrayInt(graph->base.context, item_type, capacity, vx_true_e, VX_TYPE_ARRAY);

            if (arr && arr->base.type == VX_TYPE_ARRAY)
            {
                arr->base.scope = (vx_reference_t *)graph;
            }
            else
            {
                arr = (vx_array)vxGetErrorObject(graph->base.context, VX_ERROR_NO_MEMORY);
            }
        }
        else
        {
            arr = (vx_array)vxGetErrorObject(graph->base.context, VX_ERROR_INVALID_PARAMETERS);
        }
    }

    return arr;
}
コード例 #2
0
ファイル: vx_pyramid.c プロジェクト: flowyard/FlowVX
static vx_pyramid vxCreatePyramidInt(vx_context context,
                                      vx_size levels,
                                      vx_float32 scale,
                                      vx_uint32 width,
                                      vx_uint32 height,
                                      vx_df_image format,
                                      vx_bool is_virtual)
{
    vx_pyramid pyramid = NULL;

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

    if ((scale != VX_SCALE_PYRAMID_HALF) &&
        (scale != VX_SCALE_PYRAMID_ORB))
    {
        VX_PRINT(VX_ZONE_ERROR, "Invalid scale %lf for pyramid!\n",scale);
        vxAddLogEntry((vx_reference)context, VX_ERROR_INVALID_PARAMETERS, "Invalid scale %lf for pyramid!\n",scale);
        pyramid = (vx_pyramid_t *)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
    }
    else if (levels == 0 || levels > 8)
    {
        VX_PRINT(VX_ZONE_ERROR, "Invalid number of levels for pyramid!\n", levels);
        vxAddLogEntry((vx_reference)context, VX_ERROR_INVALID_PARAMETERS, "Invalid number of levels for pyramid!\n", levels);
        pyramid = (vx_pyramid_t *)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
    }
    else
    {
        pyramid = (vx_pyramid)vxCreateReference(context, VX_TYPE_PYRAMID, VX_EXTERNAL, &context->base);
        if (pyramid && pyramid->base.type == VX_TYPE_PYRAMID)
        {
            vx_status status;
            pyramid->base.is_virtual = is_virtual;
            status = vxInitPyramid(pyramid, levels, scale, width, height, format);
            if (status != VX_SUCCESS)
            {
                vxAddLogEntry((vx_reference)pyramid, status, "Failed to initialize pyramid\n");
                vxReleasePyramid((vx_pyramid *)&pyramid);
                pyramid = (vx_pyramid_t *)vxGetErrorObject(context, status);
            }
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Failed to allocate memory\n");
            vxAddLogEntry((vx_reference)context, VX_ERROR_NO_MEMORY, "Failed to allocate memory\n");
            pyramid = (vx_pyramid_t *)vxGetErrorObject(context, VX_ERROR_NO_MEMORY);
        }
    }
    return pyramid;
}
コード例 #3
0
VX_API_ENTRY vx_distribution VX_API_CALL vxCreateDistribution(vx_context context, vx_size numBins, vx_int32 offset, vx_uint32 range)
{
    vx_distribution distribution = NULL;

    if (vxIsValidContext(context) == vx_true_e)
    {
        if ((numBins != 0) && (range != 0))
        {
            distribution = (vx_distribution)vxCreateReference(context, VX_TYPE_DISTRIBUTION, VX_EXTERNAL, &context->base);
            if ( vxGetStatus((vx_reference)distribution) == VX_SUCCESS &&
                 distribution->base.type == VX_TYPE_DISTRIBUTION)
            {
                distribution->memory.ndims = 2;
                distribution->memory.nptrs = 1;
                distribution->memory.strides[0][VX_DIM_C] = sizeof(vx_int32);
                distribution->memory.dims[0][VX_DIM_C] = 1;
                distribution->memory.dims[0][VX_DIM_X] = (vx_int32)numBins;
                distribution->memory.dims[0][VX_DIM_Y] = 1;
				distribution->memory.cl_type = CL_MEM_OBJECT_BUFFER;
                distribution->window_x = (vx_uint32)range/(vx_uint32)numBins;
                distribution->window_y = 1;
                distribution->offset_x = offset;
                distribution->offset_y = 0;
            }
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Invalid parameters to distribution\n");
            vxAddLogEntry(&context->base, VX_ERROR_INVALID_PARAMETERS, "Invalid parameters to distribution\n");
            distribution = (vx_distribution)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
        }
    }

    return distribution;
}
コード例 #4
0
ファイル: vx_parameter.c プロジェクト: flowyard/FlowVX
VX_API_ENTRY vx_parameter VX_API_CALL vxGetKernelParameterByIndex(vx_kernel kernel, vx_uint32 index)
{
    vx_parameter parameter = NULL;
    if (vxIsValidSpecificReference(&kernel->base, VX_TYPE_KERNEL) == vx_true_e)
    {
        if (index < VX_INT_MAX_PARAMS && index < kernel->signature.num_parameters)
        {
            parameter = (vx_parameter)vxCreateReference(kernel->base.context, VX_TYPE_PARAMETER, VX_EXTERNAL, &kernel->base.context->base);
            if (parameter && parameter->base.type == VX_TYPE_PARAMETER)
            {
                parameter->index = index;
                parameter->node = NULL;
                parameter->kernel = kernel;
                vxIncrementReference(&parameter->kernel->base, VX_INTERNAL);
            }
        }
        else
        {
            vxAddLogEntry(&kernel->base, VX_ERROR_INVALID_PARAMETERS, "Index %u out of range for node %s (numparams = %u)!\n",
                    index, kernel->name, kernel->signature.num_parameters);
            parameter = (vx_parameter_t *)vxGetErrorObject(kernel->base.context, VX_ERROR_INVALID_PARAMETERS);
        }
    }
    return parameter;
}
コード例 #5
0
ファイル: vx_lut.c プロジェクト: ChiahungTai/clairvoyance
VX_API_ENTRY vx_lut VX_API_CALL vxCreateLUT(vx_context context, vx_enum data_type, vx_size count)
{
    vx_lut_t *lut = NULL;

    if (vxIsValidContext(context) == vx_true_e)
    {
        if (data_type == VX_TYPE_UINT8)
        {
#if defined(OPENVX_STRICT_1_0)
            if (count != 256)
            {
                VX_PRINT(VX_ZONE_ERROR, "Invalid parameter to LUT\n");
                vxAddLogEntry(&context->base, VX_ERROR_INVALID_PARAMETERS, "Invalid parameter to LUT\n");
                lut = (vx_lut_t *)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
            }
            else
#endif
            {
                lut = (vx_lut_t *)vxCreateArrayInt(context, VX_TYPE_UINT8, count, vx_false_e, VX_TYPE_LUT);
                if (vxGetStatus((vx_reference)lut) == VX_SUCCESS && lut->base.type == VX_TYPE_LUT)
                {
                    lut->num_items = count;
                    vxPrintArray(lut);
                }
            }
        }
#if !defined(OPENVX_STRICT_1_0)
        else if (data_type == VX_TYPE_UINT16)
        {
            lut = (vx_lut_t *)vxCreateArrayInt(context, VX_TYPE_UINT16, count, vx_false_e, VX_TYPE_LUT);
            if (vxGetStatus((vx_reference)lut) == VX_SUCCESS && lut->base.type == VX_TYPE_LUT)
            {
                lut->num_items = count;
                vxPrintArray(lut);
            }
        }
#endif
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Invalid data type\n");
            vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid data type\n");
            lut = (vx_lut_t *)vxGetErrorObject(context, VX_ERROR_INVALID_TYPE);
        }
    }

    return (vx_lut)lut;
}
コード例 #6
0
ファイル: vx_pyramid.c プロジェクト: flowyard/FlowVX
VX_API_ENTRY vx_pyramid VX_API_CALL vxCreatePyramid(vx_context context, vx_size levels, vx_float32 scale, vx_uint32 width, vx_uint32 height, vx_df_image format)
{
    if ((width == 0) || (height == 0) || (format == VX_DF_IMAGE_VIRT))
    {
        return (vx_pyramid)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
    }
    return (vx_pyramid)vxCreatePyramidInt(context,
                                           levels, scale, width, height, format,
                                           vx_false_e);
}
コード例 #7
0
ファイル: vx_parameter.c プロジェクト: flowyard/FlowVX
VX_API_ENTRY vx_parameter VX_API_CALL vxGetParameterByIndex(vx_node node, vx_uint32 index)
{
    vx_parameter param = NULL;
    if (vxIsValidSpecificReference(&node->base, VX_TYPE_NODE) == vx_false_e)
    {
        return param;
    }
    if (node->kernel == NULL)
    {
        /* this can probably never happen */
        vxAddLogEntry(&node->base, VX_ERROR_INVALID_NODE, "Node was created without a kernel! Fatal Error!\n");
        param = (vx_parameter_t *)vxGetErrorObject(node->base.context, VX_ERROR_INVALID_NODE);
    }
    else
    {
        if (/*0 <= index &&*/ index < VX_INT_MAX_PARAMS && index < node->kernel->signature.num_parameters)
        {
            param = (vx_parameter)vxCreateReference(node->base.context, VX_TYPE_PARAMETER, VX_EXTERNAL, &node->base);
            if (param && param->base.type == VX_TYPE_PARAMETER)
            {
                param->index = index;
                param->node = node;
                vxIncrementReference(&param->node->base, VX_INTERNAL);
                param->kernel = node->kernel;
                vxIncrementReference(&param->kernel->base, VX_INTERNAL);
                // if (node->parameters[index])
                    // vxIncrementReference(node->parameters[index], VX_INTERNAL);
            }
        }
        else
        {
            vxAddLogEntry(&node->base, VX_ERROR_INVALID_PARAMETERS, "Index %u out of range for node %s (numparams = %u)!\n",
                    index, node->kernel->name, node->kernel->signature.num_parameters);
            param = (vx_parameter_t *)vxGetErrorObject(node->base.context, VX_ERROR_INVALID_PARAMETERS);
        }
    }
    VX_PRINT(VX_ZONE_API, "%s: returning %p\n", __FUNCTION__, param);
    return param;
}
コード例 #8
0
ファイル: vx_array.c プロジェクト: ChiahungTai/clairvoyance
VX_API_ENTRY vx_array VX_API_CALL vxCreateArray(vx_context context, vx_enum item_type, vx_size capacity)
{
    vx_array arr = NULL;

    if (vxIsValidContext(context) == vx_true_e)
    {
        if ( (vxIsValidArrayItemType(context, item_type) == vx_true_e) &&
             (capacity > 0))
        {
            arr = (vx_array)vxCreateArrayInt(context, item_type, capacity, vx_false_e, VX_TYPE_ARRAY);

            if (arr == NULL)
            {
                arr = (vx_array)vxGetErrorObject(context, VX_ERROR_NO_MEMORY);
            }
        }
        else
        {
            arr = (vx_array)vxGetErrorObject(context, VX_ERROR_INVALID_PARAMETERS);
        }
    }

    return arr;
}
コード例 #9
0
ファイル: vx_import.c プロジェクト: flowyard/FlowVX
VX_API_ENTRY vx_reference VX_API_CALL vxGetReferenceByIndex(vx_import import, vx_uint32 index)
{
    vx_reference ref = NULL;
    if (import && import->base.type == VX_TYPE_IMPORT)
    {
        if (index < import->count)
        {
            ref = (vx_reference_t *)import->refs[index];
            vxIncrementReference(ref, VX_EXTERNAL);
        }
        else
        {
            VX_PRINT(VX_ZONE_ERROR, "Incorrect index value\n");
            vxAddLogEntry(&import->base.context->base, VX_ERROR_INVALID_PARAMETERS, "Incorrect index value\n");
            ref = (vx_reference_t *)vxGetErrorObject(import->base.context, VX_ERROR_INVALID_PARAMETERS);
        }
    }
    else
    {
        VX_PRINT(VX_ZONE_ERROR, "Invalid import reference!\n");
    }
    return ref;
}
コード例 #10
0
ファイル: vx_scalar.c プロジェクト: flowyard/FlowVX
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;
}