OpenVX直方图

时间:2017-07-27 08:19:08

标签: openvx

我正在尝试使用OpenVX直方图(根据Spec 1.1)并且在使用部分中很少有困惑。我的理解是这样的(请纠正我):

vx_size numBins = 10;
vx_uint32 offset = 10;
vx_uint32 range = 256;
// Create Object
vx_distribution vx_dist = vxCreateDistribution (Context, numBins, offset, 
range);

// Create Node
vx_status status = vxHistogramNode (context, img, vx_dist);

规范说vxHistogramNode()需要vx_distribution as [out],这是否意味着vxHistogramNode()在内部创建了对象?如果答案是“是”,那么我将如何传递numBins,Offset和我选择的范围?

另外。如何访问直方图结果的输出?

1 个答案:

答案 0 :(得分:1)

out表示节点会将结果写入提供的数据对象。所以你将对象传递给节点,运行图形,然后读取结果:

// Create Object
vx_size numBins = 10;
vx_uint32 offset = 10;
vx_uint32 range = 256;
vx_distribution vx_dist = vxCreateDistribution (Context, numBins, offset, range);

vx_graph graph = vxCreateGraph(context);
vxHistogramNode(graph, img, vx_dist);
vxVerifyGraph(graph);

vxProcessGraph(graph);

// Read the data
vx_map_id map_id;
vx_int32 *ptr;
vxMapDistribution(vx_dist, &map_id, (void **)&ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);
// use ptr, like ptr[0]
vxUnmapDistribution(vx_dist, map_id);