OpenVX 直方图

OpenVX Histogram

我正在尝试使用 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() 在内部创建对象?如果答案是 'Yes' 那么我将如何传递我选择的 numBins、Offset 和范围?

还有。如何访问直方图结果的输出?

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);