• 【OPENVX】对象基本使用之vx_lut


    1. 测试源码

    #include 
    #include 
    
    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;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56

    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

  • 相关阅读:
    编程猫创作工具:新版Kitten新体验
    考研五大热门专业排名 考研热门专业排行榜
    我的大学期末网页作业 仿学校网站制作实现 HTML+CSS西北大学新闻网带psd带js
    JavaScript中事件绑定和DOM事件流(冒泡和捕获)-案例详解
    eCharts实现漏斗图
    排查 Spring Boot 没有你想的那么简单
    java 面试 英语自我介绍
    〖Python 数据库开发实战 - MySQL篇㉝〗- 数据的导入与导出
    Android 缩短开机动画的播放时长
    NUC980webServer开发
  • 原文地址:https://blog.csdn.net/zhy29563/article/details/126002909