当前位置:网站首页>【OPENVX】对象基本使用之vx_pyramid
【OPENVX】对象基本使用之vx_pyramid
2022-07-28 03:25:00 【zhy29563】
1. 测试源码
#include <iostream>
#include <VX/vx.h>
void print_image(vx_image image, const char *message) {
vx_status status;
std::cout << "===============================" << std::endl;
std::cout << message << std::endl;
vx_uint32 img_width;
vxQueryImage(image, VX_IMAGE_WIDTH, &img_width, sizeof(vx_uint32));
vx_uint32 img_height;
vxQueryImage(image, VX_IMAGE_HEIGHT, &img_height, sizeof(vx_uint32));
vx_df_image_e format;
vxQueryImage(image, VX_IMAGE_FORMAT, &format, sizeof(vx_df_image));
vx_size planes;
vxQueryImage(image, VX_IMAGE_PLANES, &planes, sizeof(vx_size));
vx_color_space_e color_space;
vxQueryImage(image, VX_IMAGE_SPACE, &color_space, sizeof(vx_color_space_e));
vx_channel_range_e channel_range;
vxQueryImage(image, VX_IMAGE_RANGE, &channel_range, sizeof(vx_channel_range_e));
vx_memory_type_e memory_type;
vxQueryImage(image, VX_IMAGE_MEMORY_TYPE, &memory_type, sizeof(vx_memory_type_e));
vx_bool is_uniform;
vx_pixel_value_t uniform_value;
status = vxQueryImage(image, VX_IMAGE_IS_UNIFORM, &is_uniform, sizeof(is_uniform));
if (status != VX_SUCCESS)
is_uniform = false, uniform_value.S32 = -32768;
if (is_uniform == vx_true_e) {
status = vxQueryImage(image, VX_IMAGE_UNIFORM_VALUE, &uniform_value, sizeof(uniform_value));
if (status != VX_SUCCESS)
uniform_value.S32 = -32768;
}
std::cout << "\t" << "format : " << format << std::endl;
std::cout << "\t" << "img_width : " << img_width << std::endl;
std::cout << "\t" << "img_height : " << img_height << std::endl;
std::cout << "\t" << "planes : " << planes << std::endl;
std::cout << "\t" << "color_space : " << color_space << std::endl;
std::cout << "\t" << "channel_range : " << channel_range << std::endl;
std::cout << "\t" << "memory_type : " << memory_type << std::endl;
std::cout << "\t" << "is_uniform : " << is_uniform << std::endl;
if (is_uniform)
std::cout << "\t" << "uniform_value : " << uniform_value.S32 << std::endl;
std::cout << "\t" << "valid region : " << std::endl;
vx_rectangle_t patch;
vxGetValidRegionImage(image, &patch);
std::cout << "\t" << "\t" << "start_x : " << patch.start_x << std::endl;
std::cout << "\t" << "\t" << "start_y : " << patch.start_y << std::endl;
std::cout << "\t" << "\t" << "end_x : " << patch.end_x << std::endl;
std::cout << "\t" << "\t" << "end_y : " << patch.end_y << std::endl;
std::cout << "\t" << "image patch addressing : " << std::endl;
for (size_t i = 0; i < planes; i++) {
vx_imagepatch_addressing_t addr = VX_IMAGEPATCH_ADDR_INIT;
vx_map_id map_id;
unsigned char *ptr;
vxMapImagePatch(image, &patch, i, &map_id, &addr, (void **) &ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST,VX_NOGAP_X);
std::cout << "\t" << "\t" << "plane : " << i << std::endl;
std::cout << "\t" << "\t" << "addr.dim_x : " << addr.dim_x << std::endl;
std::cout << "\t" << "\t" << "addr.dim_y : " << addr.dim_y << std::endl;
std::cout << "\t" << "\t" << "addr.stride_x: " << addr.stride_x << std::endl;
std::cout << "\t" << "\t" << "addr.stride_y: " << addr.stride_y << std::endl;
std::cout << "\t" << "\t" << "addr.scale_x : " << addr.scale_x << std::endl;
std::cout << "\t" << "\t" << "addr.scale_y : " << addr.scale_y << std::endl;
std::cout << "\t" << "\t" << "addr.step_x : " << addr.step_x << std::endl;
std::cout << "\t" << "\t" << "addr.step_y : " << addr.step_y << std::endl;
std::cout << std::endl;
vxUnmapImagePatch(image, map_id);
}
}
void print_pyramid(vx_pyramid pyramid, const char *message)
{
std::cout << "===============================" << std::endl;
std::cout << message << std::endl;
vx_size level;
vxQueryPyramid(pyramid, (vx_enum)VX_PYRAMID_LEVELS, &level, sizeof(level));
vx_float32 scale;
vxQueryPyramid(pyramid, (vx_enum)VX_PYRAMID_SCALE, &scale, sizeof(scale));
vx_uint32 width;
vxQueryPyramid(pyramid, (vx_enum)VX_PYRAMID_WIDTH, &width, sizeof(width));
vx_uint32 height;
vxQueryPyramid(pyramid, (vx_enum)VX_PYRAMID_HEIGHT, &height, sizeof(height));
vx_df_image format;
vxQueryPyramid(pyramid, (vx_enum)VX_PYRAMID_FORMAT, &format, sizeof(format));
std::cout << "level : " << level << std::endl;
std::cout << "scale : " << scale << std::endl;
std::cout << "width : " << width << std::endl;
std::cout << "height : " << height << std::endl;
std::cout << "format : " << format << std::endl;
for (int i = 0; i <level; ++i) {
vx_image image = vxGetPyramidLevel(pyramid, i);
char msg[120]{
0};
sprintf(msg, "level: %d", i);
print_image(image, msg);
}
}
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
vx_context context = vxCreateContext();
vx_pyramid pyramid = vxCreatePyramid(context, 3, VX_SCALE_PYRAMID_HALF, 10, 10, VX_DF_IMAGE_U8);
print_pyramid(pyramid, "create");
vxReleasePyramid(&pyramid);
vxReleaseContext(&context);
return EXIT_SUCCESS;
}
2. 运行结果
===============================
create
level : 3
scale : 0.5
width : 10
height : 10
format : 942682197
===============================
level: 0
format : 942682197
img_width : 10
img_height : 10
planes : 1
color_space : 24576
channel_range : 28672
memory_type : 57344
is_uniform : 0
valid region :
start_x : 0
start_y : 0
end_x : 10
end_y : 10
image patch addressing :
plane : 0
addr.dim_x : 10
addr.dim_y : 10
addr.stride_x: 1
addr.stride_y: 10
addr.scale_x : 1024
addr.scale_y : 1024
addr.step_x : 1
addr.step_y : 1
===============================
level: 1
format : 942682197
img_width : 5
img_height : 5
planes : 1
color_space : 24576
channel_range : 28672
memory_type : 57344
is_uniform : 0
valid region :
start_x : 0
start_y : 0
end_x : 5
end_y : 5
image patch addressing :
plane : 0
addr.dim_x : 5
addr.dim_y : 5
addr.stride_x: 1
addr.stride_y: 5
addr.scale_x : 1024
addr.scale_y : 1024
addr.step_x : 1
addr.step_y : 1
===============================
level: 2
format : 942682197
img_width : 3
img_height : 3
planes : 1
color_space : 24576
channel_range : 28672
memory_type : 57344
is_uniform : 0
valid region :
start_x : 0
start_y : 0
end_x : 3
end_y : 3
image patch addressing :
plane : 0
addr.dim_x : 3
addr.dim_y : 3
addr.stride_x: 1
addr.stride_y: 3
addr.scale_x : 1024
addr.scale_y : 1024
addr.step_x : 1
addr.step_y : 1
边栏推荐
猜你喜欢

4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits

What are the fragments of MySQL

2022 summary of the latest Android handler related interview questions

How to uninstall clean ZABBIX service? (super detailed)
![[SAML SSO solution] Shanghai daoning brings you SAML for asp NET/SAML for ASP. Net core download, trial, tutorial](/img/7d/c372dba73531f4574ca3d379668b13.jpg)
[SAML SSO solution] Shanghai daoning brings you SAML for asp NET/SAML for ASP. Net core download, trial, tutorial

max_ pool2d(): argument ‘input‘ (position 1) must be Tensor, not NoneType

Unity backpack system

Redis implements distributed locks

收藏|0 基础开源数据可视化平台 FlyFish 大屏开发指南
![2022-07-27:小红拿到了一个长度为N的数组arr,她准备只进行一次修改, 可以将数组中任意一个数arr[i],修改为不大于P的正数(修改后的数必须和原数不同), 并使得所有数之和为X的倍数。](/img/24/fbf63272f83b932e0ee953f8d4db75.png)
2022-07-27:小红拿到了一个长度为N的数组arr,她准备只进行一次修改, 可以将数组中任意一个数arr[i],修改为不大于P的正数(修改后的数必须和原数不同), 并使得所有数之和为X的倍数。
随机推荐
Robot development -- lead screw and guide rail
每周推荐短视频:如何正确理解“精益”这个词?
How to solve the problem of win11 black desktop background?
The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
Billions of asset addresses are blacklisted? How to use the tether address freezing function?
SAP UI5 FileUploader 控件深入介绍 - 为什么需要一个隐藏的 iframe 试读版
我的创作纪念日
MySQL事务的ACID特性及并发问题实例分析
Qt:QMessageBox消息框、自定义信号和槽
Analysis of redis network model
Unity背包系统
单调栈——739. 每日温度
STM32 RT-Thread虚拟文件系统挂载操作
Redis 5 kinds of data structure analysis
C language to achieve a dynamic version of the address book
CF question making record from July 25th to July 31st
Redis implements distributed locks
接口自动化测试,完整入门篇
AIRIOT答疑第6期|如何使用二次开发引擎?
沃尔沃:深入人心的“安全感” 究竟靠的是什么?