当前位置:网站首页>[openvx] VX for basic use of objects_ convolution
[openvx] VX for basic use of objects_ convolution
2022-07-28 03:39:00 【zhy29563】
1. Program source code
#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);
// In user memory , Convolution coefficients are stored in the form of row spindles
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();
// Parameters columns And rows Must be base , And within the scope [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");
// Update elements
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");
// Set properties
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. Running results
===============================
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
边栏推荐
猜你喜欢

单调栈——42. 接雨水——面大厂必须会的困难题

Qt:QMessageBox消息框、自定义信号和槽

STM32 RT thread virtual file system mount operation

How to make the Internet access the intranet IP (used by esp8266 web pages)

C language to achieve a dynamic version of the address book

8000字讲透OBSA原理与应用实践

In December, the PMP Exam adopted the new syllabus for the first time. How to learn?
D2dengine edible tutorial (4) -- draw text

鼠标操作和响应

最新版宝塔安装zip扩展,php -m 不显示的处理方法
随机推荐
【OPENVX】对象基本使用之vx_convolution
Response to questions about the balanced beacon group of Hubei University of Arts and Sciences
Container related concepts
Tungsten Fabric SDN — BGP as a Service
动态规划——63. 不同路径 II
数字经济已成为最大看点
光年(Light Year Admin)后台管理系统模板
Use of custom annotations
【OPENVX】对象基本使用之vx_distribution
超好看的Nteam官网PHP程序源码
Redis persistence mechanism
95后阿里P7晒出工资单:真的是狠狠扎心了...
LabVIEW加载和使用树型控件项目中的定制符号
【OPENVX】对象基本使用之vx_image
203. Remove linked list elements
沃尔沃:深入人心的“安全感” 究竟靠的是什么?
Unity backpack system
Unity simply implements the dialog function
[5g NR] RRC reject analysis
单调栈——42. 接雨水——面大厂必须会的困难题