当前位置:网站首页>【OPENVX】对象基本使用之vx_convolution
【OPENVX】对象基本使用之vx_convolution
2022-07-28 03:25:00 【zhy29563】
1. 程序源码
#include <iostream>
#include <VX/vx.h>
void print_convolution(vx_convolution convolution, const char *message)
{
std::cout << "===============================" << std::endl;
std::cout << message << std::endl;
vx_size rows;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_ROWS, &rows, sizeof(rows));
vx_size cols;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_COLUMNS, &cols, sizeof(cols));
vx_uint32 scale;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_SCALE, &scale, sizeof(scale));
vx_size size;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_SIZE, &size, sizeof(size));
std::cout << "rows : " << rows << std::endl;
std::cout << "cols : " << cols << std::endl;
std::cout << "scale : " << scale << std::endl;
std::cout << "size : " << size << std::endl;
std::cout << "item size : " << size / (rows * cols) << std::endl;
void* buffer = malloc(size);
// 在用户内存中,卷积系数以行主轴的方式进行存储
vxCopyConvolutionCoefficients(convolution, buffer, VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
std::cout << "convolution coefficients" << std::endl;
for (int row = 0; row < rows; ++row) {
std::cout << "\t";
for (int col = 0; col < cols; ++col) {
std::cout << ((vx_int16*)buffer)[row * cols + col] << "\t";
}
std::cout << std::endl;
}
free(buffer);
}
int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
vx_status status;
vx_context context = vxCreateContext();
// 参数 columns 与 rows 必须为基数,且要在范围 [3, VX_CONTEXT_CONVOLUTION_MAX_DIMENSION)
vx_size cols = 7U;
vx_size rows = 5U;
vx_convolution convolution = vxCreateConvolution(context, cols, rows);
print_convolution(convolution, "create");
// 更新元素
vx_int16 *coefficients = (vx_int16*)malloc(rows * cols * sizeof (vx_int16));
for (int i = 0; i < rows * cols; ++i) {
coefficients[i] = i;
}
vxCopyConvolutionCoefficients(convolution, coefficients, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
print_convolution(convolution, "update items");
// 设置属性
vx_uint32 scale = 2;
vxSetConvolutionAttribute(convolution, (vx_enum)VX_CONVOLUTION_SCALE, &scale, sizeof (scale));
print_convolution(convolution, "update scale");
free(coefficients);
vxReleaseConvolution(&convolution);
vxReleaseContext(&context);
return EXIT_SUCCESS;
}
2. 运行结果
===============================
create
rows : 5
cols : 7
scale : 1
size : 70
item size : 2
convolution coefficients
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
===============================
update items
rows : 5
cols : 7
scale : 1
size : 70
item size : 2
convolution coefficients
0 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
===============================
update scale
rows : 5
cols : 7
scale : 2
size : 70
item size : 2
convolution coefficients
0 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
边栏推荐
猜你喜欢

"Xiaodeng" network equipment monitoring in operation and maintenance

Airiot Q & A issue 6 | how to use the secondary development engine?

「运维有小邓」网络设备监控

Illustrated: detailed explanation of JVM memory layout

20220726汇承科技的蓝牙模块HC-05的AT命令测试

Acid characteristics of MySQL transactions and example analysis of concurrency problems

Summary of concurrent programming interview questions

verticle-align行内元素垂直居中对齐

MySQL的碎片有哪些

Robot development -- lead screw and guide rail
随机推荐
SAP UI5 FileUploader 控件深入介绍 - 为什么需要一个隐藏的 iframe 试读版
MangoPapa 的实用小脚本(目录篇)
【P4】 查看库文件两个历史版本的区别
Tensorboard usage record
动态规划——63. 不同路径 II
动态规划——509. 斐波那契数
GNU General Public License v2.0 GNU General Public License
Daily practice ----- realize the lottery function of two-color ball. Rules: Six non repeating numbers are randomly selected from 36 red balls, and one from 15 basketball is randomly selected to form a
IronOCR for .NET 2022.8
动画(animation)
Outlook 教程,如何在 Outlook 中使用颜色类别和提醒?
⽇志分析⼯具(Splunk)
Xctf attack and defense world web master advanced area php2
Asemi rectifier bridge gbpc5010, gbpc5010 parameters, gbpc5010 size
How to make the Internet access the intranet IP (used by esp8266 web pages)
ThreadLocal usage scenario
过亿资产地址被拉入黑名单?Tether地址冻结功能该怎么用?
MSGAN用于多种图像合成的模式搜索生成对抗网络---解决模式崩塌问题
光年(Light Year Admin)后台管理系统模板
TypeError: ufunc ‘bitwise_and‘ not supported for the input types, and the inputs could not be safely