【OPENVX】对象基本使用之vx_lut

1. 测试源码

#include <iostream>
#include <VX/vx.h>

void print_lut(vx_lut lut, const char *message)
{
    std::cout << "===============================" << std::endl;
    std::cout << message << std::endl;

    vx_enum type;
    vxQueryLUT(lut, (vx_enum)VX_LUT_TYPE, &type, sizeof(type));

    vx_size count;
    vxQueryLUT(lut, (vx_enum)VX_LUT_COUNT, &count, sizeof(count));

    vx_size size;
    vxQueryLUT(lut, (vx_enum)VX_LUT_SIZE, &size, sizeof(size));

    vx_uint32 offset;
    vxQueryLUT(lut, (vx_enum)VX_LUT_OFFSET, &offset, sizeof(offset));

    std::cout << "type    : " << type << std::endl;
    std::cout << "count   : " << count << std::endl;
    std::cout << "size    : " << size << std::endl;
    std::cout << "offset  : " << offset << std::endl;

    vx_map_id map_id;
    void* ptr;
    std::cout << "item    : " << std::endl;
    vxMapLUT(lut, &map_id, &ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);
    for (int i = 0; i < count; ++i) {
        std::cout << "\t" << "index: " << i << ", value: " << (int)((vx_uint8*)ptr)[i] << std::endl;
    }
    vxUnmapLUT(lut, map_id);
}

int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;

    vx_context context = vxCreateContext();

    vx_lut lut = vxCreateLUT(context, VX_TYPE_UINT8, 10);
    print_lut(lut, "create");

    vx_uint8 *array = new vx_uint8 [10];
    for (int i = 0; i < 10; ++i)
        array[i] = i;
    vxCopyLUT(lut, array, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
    print_lut(lut, "update");

    delete[] array;
    vxReleaseLUT(&lut);
    vxReleaseContext(&context);
    return EXIT_SUCCESS;
}

2. 运行结果

===============================
create
type : 3
count : 10
size : 10
offset : 0
item :
index: 0, value: 112
index: 1, value: 215
index: 2, value: 2
index: 3, value: 30
index: 4, value: 102
index: 5, value: 85
index: 6, value: 0
index: 7, value: 0
index: 8, value: 0
index: 9, value: 0

===============================
update
type : 3
count : 10
size : 10
offset : 0
item :
index: 0, value: 0
index: 1, value: 1
index: 2, value: 2
index: 3, value: 3
index: 4, value: 4
index: 5, value: 5
index: 6, value: 6
index: 7, value: 7
index: 8, value: 8
index: 9, value: 9

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhy29563

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值