diff --git a/Build.py b/Build.py index c4ec4f6..06c1255 100644 --- a/Build.py +++ b/Build.py @@ -89,6 +89,7 @@ def main(): # Provisional extensions parser.add_option("--tiling", dest="tiling", help="Add -DOPENVX_USE_TILING=ON to support the tiling extension", default=False, action='store_true') parser.add_option("--s16", dest="s16", help="Add -DOPENVX_USE_S16=ON to have an extended support for S16", default=False, action='store_true') + parser.add_option("--userdataobj", dest="userdataobj", help="Add -DOPENVX_USE_USER_DATA_OBJECT=ON to support user data object extension", default=False, action='store_true') # Experimental features parser.add_option("--f16", dest="f16", help="Add -DEXPERIMENTAL_PLATFORM_SUPPORTS_16_FLOAT=ON to support VX_TYPE_FLOAT16", default=False, action='store_true') parser.add_option("--venum", dest="venum", help="Add -DEXPERIMENTAL_USE_VENUM=ON to build also raspberrypi 3B+ Neon target[Default False]", default=False, action='store_true') @@ -232,6 +233,8 @@ def main(): cmd += ['-DEXPERIMENTAL_USE_VENUM=ON'] if options.opencl: cmd += ['-DEXPERIMENTAL_USE_OPENCL=ON'] + if options.userdataobj: + cmd += ['-DOPENVX_USE_USER_DATA_OBJECT=ON'] cmd = ' '.join(cmd) print( "" ) diff --git a/cmake_utils/CMakeFuncs.txt b/cmake_utils/CMakeFuncs.txt index f90f2a8..fc3f5ef 100644 --- a/cmake_utils/CMakeFuncs.txt +++ b/cmake_utils/CMakeFuncs.txt @@ -94,7 +94,9 @@ endfunction ( FIND_SOURCES ) # function ( FIND_NUM_PROCESSORS ) set(PROCESSOR_COUNT_T 0) - if ( WIN32 ) + if(CMAKE_CROSSCOMPILING) + set(PROCESSOR_COUNT_T "1") + elseif ( WIN32 ) set(PROCESSOR_COUNT_T "$ENV{NUMBER_OF_PROCESSORS}") else ( WIN32 ) set(CPUINFO_FILE "/proc/cpuinfo") diff --git a/cmake_utils/CMake_linux_tools.cmake b/cmake_utils/CMake_linux_tools.cmake index 02df94b..3cd2688 100644 --- a/cmake_utils/CMake_linux_tools.cmake +++ b/cmake_utils/CMake_linux_tools.cmake @@ -29,7 +29,9 @@ endif (CYGWIN) if(BUILD_X64) if (EXPERIMENTAL_USE_VENUM OR OPENVX_USE_TILING OR EXPERIMENTAL_USE_OPENCL) - set(ARCH_BIT "-mfpu=neon") + if (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")) + set(ARCH_BIT "-mfpu=neon") + endif() else () set(ARCH_BIT -m64 ) endif(EXPERIMENTAL_USE_VENUM OR OPENVX_USE_TILING OR EXPERIMENTAL_USE_OPENCL) @@ -38,7 +40,9 @@ else() # architecture will be according to ATOM set(ARCH_BIT -m32 ) elseif (EXPERIMENTAL_USE_VENUM OR OPENVX_USE_TILING OR EXPERIMENTAL_USE_OPENCL) - set(ARCH_BIT "-mfpu=neon") + if (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")) + set(ARCH_BIT "-mfpu=neon") + endif() else () # need to force a more modern architecture than the degault m32 (i386). set(ARCH_BIT "-m32 -march=core2" ) diff --git a/cmake_utils/CMake_windows_tools.cmake b/cmake_utils/CMake_windows_tools.cmake index a7457fb..e2b4e7c 100644 --- a/cmake_utils/CMake_windows_tools.cmake +++ b/cmake_utils/CMake_windows_tools.cmake @@ -18,7 +18,7 @@ # Compiler switches that CANNOT be modified during makefile generation set (ADD_C_FLAGS "/Oi -D WINDOWS_ENABLE_CPLUSPLUS /GS") -set (ADD_C_FLAGS_DEBUG "-D _DEBUG /RTC1 /MTd") #/MTd /Gm +set (ADD_C_FLAGS_DEBUG "-D _DEBUG /RTC1 /MTd /bigobj") #/MTd /Gm set (ADD_C_FLAGS_RELEASE "/Zi /Gy -D NDEBUG /MT")# /Ob0") #/GL") #MT # Compiler switches that CAN be modified during makefile generation and configuration-independent diff --git a/kernels/c_model/c_khr_nn.c b/kernels/c_model/c_khr_nn.c index 7e29227..00ad99a 100644 --- a/kernels/c_model/c_khr_nn.c +++ b/kernels/c_model/c_khr_nn.c @@ -508,7 +508,7 @@ void PoolingKernelImpl( if (!max_pooling) { //result = conversion_24_8(result / (int16_t)(size_x * size_y)); - result = CLAMP(result / (size_x * size_y), getMinValue(fmt), getMaxValue(fmt)); + result = CLAMP(result / (int32_t)(size_x * size_y), getMinValue(fmt), getMaxValue(fmt)); } const size_t output_byte_offset = diff --git a/kernels/extras/extras_k.h b/kernels/extras/extras_k.h index 8cb02b9..9e3b662 100644 --- a/kernels/extras/extras_k.h +++ b/kernels/extras/extras_k.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _VX_EXTRAS_K_H_ -#define _VX_EXTRAS_K_H_ +#ifndef VX_EXTRAS_K_H_ +#define VX_EXTRAS_K_H_ #include #include diff --git a/sample/framework/vx_graph.c b/sample/framework/vx_graph.c index 8651d14..73d7479 100644 --- a/sample/framework/vx_graph.c +++ b/sample/framework/vx_graph.c @@ -655,6 +655,26 @@ void ownDestructGraph(vx_reference ref) } ownRemoveNodeInt(&graph->nodes[0]); } + /* Release virtual objects scoped to this graph */ + { + vx_context context = graph->base.context; + vx_uint32 r; + for (r = 0u; r < context->num_references; r++) + { + vx_reference virt_ref = context->reftable[r]; + if (virt_ref != NULL && virt_ref->is_virtual == vx_true_e && virt_ref->scope == (vx_reference)graph) + { + if (virt_ref->external_count > 0) + { + ownReleaseReferenceInt(&virt_ref, virt_ref->type, VX_EXTERNAL, NULL); + } + else if (virt_ref->internal_count > 0) + { + ownDecrementReference(virt_ref, VX_INTERNAL); + } + } + } + } // execution lock? ownDestroySem(&graph->lock); } diff --git a/sample/framework/vx_scalar.c b/sample/framework/vx_scalar.c index f68886c..d1e20fe 100644 --- a/sample/framework/vx_scalar.c +++ b/sample/framework/vx_scalar.c @@ -447,63 +447,70 @@ VX_API_ENTRY vx_status VX_API_CALL vxReadScalarValue(vx_scalar scalar, void *ptr return VX_ERROR_INVALID_PARAMETERS; ownSemWait(&scalar->base.lock); - vxPrintScalarValue(scalar); - switch (scalar->data_type) + if (scalar->data_addr != NULL && scalar->data_len != 0) { - case VX_TYPE_CHAR: - *(vx_char *)ptr = scalar->data.chr; - break; - case VX_TYPE_INT8: - *(vx_int8 *)ptr = scalar->data.s08; - break; - case VX_TYPE_UINT8: - *(vx_uint8 *)ptr = scalar->data.u08; - break; - case VX_TYPE_INT16: - *(vx_int16 *)ptr = scalar->data.s16; - break; - case VX_TYPE_UINT16: - *(vx_uint16 *)ptr = scalar->data.u16; - break; - case VX_TYPE_INT32: - *(vx_int32 *)ptr = scalar->data.s32; - break; - case VX_TYPE_UINT32: - *(vx_uint32 *)ptr = scalar->data.u32; - break; - case VX_TYPE_INT64: - *(vx_int64 *)ptr = scalar->data.s64; - break; - case VX_TYPE_UINT64: - *(vx_uint64 *)ptr = scalar->data.u64; - break; + memcpy(ptr, scalar->data_addr, scalar->data_len); + } + else + { + vxPrintScalarValue(scalar); + switch (scalar->data_type) + { + case VX_TYPE_CHAR: + *(vx_char *)ptr = scalar->data.chr; + break; + case VX_TYPE_INT8: + *(vx_int8 *)ptr = scalar->data.s08; + break; + case VX_TYPE_UINT8: + *(vx_uint8 *)ptr = scalar->data.u08; + break; + case VX_TYPE_INT16: + *(vx_int16 *)ptr = scalar->data.s16; + break; + case VX_TYPE_UINT16: + *(vx_uint16 *)ptr = scalar->data.u16; + break; + case VX_TYPE_INT32: + *(vx_int32 *)ptr = scalar->data.s32; + break; + case VX_TYPE_UINT32: + *(vx_uint32 *)ptr = scalar->data.u32; + break; + case VX_TYPE_INT64: + *(vx_int64 *)ptr = scalar->data.s64; + break; + case VX_TYPE_UINT64: + *(vx_uint64 *)ptr = scalar->data.u64; + break; #if OVX_SUPPORT_HALF_FLOAT - case VX_TYPE_FLOAT16: - *(vx_float16 *)ptr = scalar->data.f16; - break; + case VX_TYPE_FLOAT16: + *(vx_float16 *)ptr = scalar->data.f16; + break; #endif - case VX_TYPE_FLOAT32: - *(vx_float32 *)ptr = scalar->data.f32; - break; - case VX_TYPE_FLOAT64: - *(vx_float64 *)ptr = scalar->data.f64; - break; - case VX_TYPE_DF_IMAGE: - *(vx_df_image *)ptr = scalar->data.fcc; - break; - case VX_TYPE_ENUM: - *(vx_enum *)ptr = scalar->data.enm; - break; - case VX_TYPE_SIZE: - *(vx_size *)ptr = scalar->data.size; - break; - case VX_TYPE_BOOL: - *(vx_bool *)ptr = scalar->data.boolean; - break; - default: - VX_PRINT(VX_ZONE_ERROR, "some case is not covered in %s\n", __FUNCTION__); - status = VX_ERROR_NOT_SUPPORTED; - break; + case VX_TYPE_FLOAT32: + *(vx_float32 *)ptr = scalar->data.f32; + break; + case VX_TYPE_FLOAT64: + *(vx_float64 *)ptr = scalar->data.f64; + break; + case VX_TYPE_DF_IMAGE: + *(vx_df_image *)ptr = scalar->data.fcc; + break; + case VX_TYPE_ENUM: + *(vx_enum *)ptr = scalar->data.enm; + break; + case VX_TYPE_SIZE: + *(vx_size *)ptr = scalar->data.size; + break; + case VX_TYPE_BOOL: + *(vx_bool *)ptr = scalar->data.boolean; + break; + default: + VX_PRINT(VX_ZONE_ERROR, "some case is not covered in %s\n", __FUNCTION__); + status = VX_ERROR_NOT_SUPPORTED; + break; + } } ownSemPost(&scalar->base.lock); ownReadFromReference(&scalar->base); @@ -521,64 +528,71 @@ VX_API_ENTRY vx_status VX_API_CALL vxWriteScalarValue(vx_scalar scalar, const vo return VX_ERROR_INVALID_PARAMETERS; ownSemWait(&scalar->base.lock); - switch (scalar->data_type) + if (scalar->data_addr != NULL && scalar->data_len != 0) { - case VX_TYPE_CHAR: - scalar->data.chr = *(vx_char *)ptr; - break; - case VX_TYPE_INT8: - scalar->data.s08 = *(vx_int8 *)ptr; - break; - case VX_TYPE_UINT8: - scalar->data.u08 = *(vx_uint8 *)ptr; - break; - case VX_TYPE_INT16: - scalar->data.s16 = *(vx_int16 *)ptr; - break; - case VX_TYPE_UINT16: - scalar->data.u16 = *(vx_uint16 *)ptr; - break; - case VX_TYPE_INT32: - scalar->data.s32 = *(vx_int32 *)ptr; - break; - case VX_TYPE_UINT32: - scalar->data.u32 = *(vx_uint32 *)ptr; - break; - case VX_TYPE_INT64: - scalar->data.s64 = *(vx_int64 *)ptr; - break; - case VX_TYPE_UINT64: - scalar->data.u64 = *(vx_uint64 *)ptr; - break; + memcpy(scalar->data_addr, ptr, scalar->data_len); + } + else + { + switch (scalar->data_type) + { + case VX_TYPE_CHAR: + scalar->data.chr = *(vx_char *)ptr; + break; + case VX_TYPE_INT8: + scalar->data.s08 = *(vx_int8 *)ptr; + break; + case VX_TYPE_UINT8: + scalar->data.u08 = *(vx_uint8 *)ptr; + break; + case VX_TYPE_INT16: + scalar->data.s16 = *(vx_int16 *)ptr; + break; + case VX_TYPE_UINT16: + scalar->data.u16 = *(vx_uint16 *)ptr; + break; + case VX_TYPE_INT32: + scalar->data.s32 = *(vx_int32 *)ptr; + break; + case VX_TYPE_UINT32: + scalar->data.u32 = *(vx_uint32 *)ptr; + break; + case VX_TYPE_INT64: + scalar->data.s64 = *(vx_int64 *)ptr; + break; + case VX_TYPE_UINT64: + scalar->data.u64 = *(vx_uint64 *)ptr; + break; #if OVX_SUPPORT_HALF_FLOAT - case VX_TYPE_FLOAT16: - scalar->data.f16 = *(vx_float16 *)ptr; - break; + case VX_TYPE_FLOAT16: + scalar->data.f16 = *(vx_float16 *)ptr; + break; #endif - case VX_TYPE_FLOAT32: - scalar->data.f32 = *(vx_float32 *)ptr; - break; - case VX_TYPE_FLOAT64: - scalar->data.f64 = *(vx_float64 *)ptr; - break; - case VX_TYPE_DF_IMAGE: - scalar->data.fcc = *(vx_df_image *)ptr; - break; - case VX_TYPE_ENUM: - scalar->data.enm = *(vx_enum *)ptr; - break; - case VX_TYPE_SIZE: - scalar->data.size = *(vx_size *)ptr; - break; - case VX_TYPE_BOOL: - scalar->data.boolean = *(vx_bool *)ptr; - break; - default: - VX_PRINT(VX_ZONE_ERROR, "some case is not covered in %s\n", __FUNCTION__); - status = VX_ERROR_NOT_SUPPORTED; - break; + case VX_TYPE_FLOAT32: + scalar->data.f32 = *(vx_float32 *)ptr; + break; + case VX_TYPE_FLOAT64: + scalar->data.f64 = *(vx_float64 *)ptr; + break; + case VX_TYPE_DF_IMAGE: + scalar->data.fcc = *(vx_df_image *)ptr; + break; + case VX_TYPE_ENUM: + scalar->data.enm = *(vx_enum *)ptr; + break; + case VX_TYPE_SIZE: + scalar->data.size = *(vx_size *)ptr; + break; + case VX_TYPE_BOOL: + scalar->data.boolean = *(vx_bool *)ptr; + break; + default: + VX_PRINT(VX_ZONE_ERROR, "some case is not covered in %s\n", __FUNCTION__); + status = VX_ERROR_NOT_SUPPORTED; + break; + } + vxPrintScalarValue(scalar); } - vxPrintScalarValue(scalar); ownSemPost(&scalar->base.lock); ownWroteToReference(&scalar->base); return status; diff --git a/sample/framework/vx_tensor.c b/sample/framework/vx_tensor.c index 1e2bada..ac3357c 100644 --- a/sample/framework/vx_tensor.c +++ b/sample/framework/vx_tensor.c @@ -635,7 +635,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxMapTensorPatch(vx_tensor tensor, vx_size nu stride[0] = ownSizeOfType(tensor->data_type); for (vx_uint32 i = 1; i < number_of_dims; i++) { - stride[i] = stride[i - 1] * (view_end[i] - view_start[i]); + stride[i] = stride[i - 1] * tensor->dimensions[i - 1]; } //vx_map_id * map_id, vx_size * stride, void ** ptr size = ComputePatchSize(view_start, view_end, number_of_dims); diff --git a/sample/framework/vx_threshold.c b/sample/framework/vx_threshold.c index 86fe88d..22a7f16 100644 --- a/sample/framework/vx_threshold.c +++ b/sample/framework/vx_threshold.c @@ -422,6 +422,7 @@ VX_API_ENTRY vx_threshold VX_API_CALL vxCreateThresholdForImage(vx_context conte VX_PRINT(VX_ZONE_ERROR, "Invalid threshold type\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid threshold type\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); + return threshold; } if ( ((vxIsValidThresholdFormat (input_format) == vx_false_e) && @@ -432,6 +433,7 @@ VX_API_ENTRY vx_threshold VX_API_CALL vxCreateThresholdForImage(vx_context conte VX_PRINT(VX_ZONE_ERROR, "Invalid input or output format\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid input or output format\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); + return threshold; } diff --git a/sample/framework/vx_xml_export.c b/sample/framework/vx_xml_export.c index 4a458c1..ae6ee5c 100644 --- a/sample/framework/vx_xml_export.c +++ b/sample/framework/vx_xml_export.c @@ -902,7 +902,7 @@ static vx_status vxExportToXMLThreshold(FILE* fp, vx_reference refs[], vx_uint32 indent[i] = '\0'; fprintf(fp, "%strue_value, thresh->false_value, refNameStr); + indent, r, type_pairs[j].name, thresh->true_value.S32, thresh->false_value.S32, refNameStr); if (refs[r]->is_virtual == vx_true_e) /* is not virtual in 1.0, but check anyway */ { diff --git a/sample/include/vx_array.h b/sample/include/vx_array.h index 60e9db7..774e3f7 100644 --- a/sample/include/vx_array.h +++ b/sample/include/vx_array.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_ARRAY_H_ -#define _OPENVX_INT_ARRAY_H_ +#ifndef OPENVX_INT_ARRAY_H_ +#define OPENVX_INT_ARRAY_H_ #include diff --git a/sample/include/vx_context.h b/sample/include/vx_context.h index 04e2b39..588d3e4 100644 --- a/sample/include/vx_context.h +++ b/sample/include/vx_context.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_CONTEXT_H_ -#define _OPENVX_INT_CONTEXT_H_ +#ifndef OPENVX_INT_CONTEXT_H_ +#define OPENVX_INT_CONTEXT_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_convolution.h b/sample/include/vx_convolution.h index 11a5bd3..44ccd48 100644 --- a/sample/include/vx_convolution.h +++ b/sample/include/vx_convolution.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_CONVOLUTION_H_ -#define _OPENVX_INT_CONVOLUTION_H_ +#ifndef OPENVX_INT_CONVOLUTION_H_ +#define OPENVX_INT_CONVOLUTION_H_ #include diff --git a/sample/include/vx_delay.h b/sample/include/vx_delay.h index 80957c6..cdd0491 100644 --- a/sample/include/vx_delay.h +++ b/sample/include/vx_delay.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_DELAY_H_ -#define _OPENVX_INT_DELAY_H_ +#ifndef OPENVX_INT_DELAY_H_ +#define OPENVX_INT_DELAY_H_ #include diff --git a/sample/include/vx_distribution.h b/sample/include/vx_distribution.h index f6fced3..11fec11 100644 --- a/sample/include/vx_distribution.h +++ b/sample/include/vx_distribution.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_DISTRIBUTION_H_ -#define _OPENVX_INT_DISTRIBUTION_H_ +#ifndef OPENVX_INT_DISTRIBUTION_H_ +#define OPENVX_INT_DISTRIBUTION_H_ #include diff --git a/sample/include/vx_error.h b/sample/include/vx_error.h index 6bf1881..5850a73 100644 --- a/sample/include/vx_error.h +++ b/sample/include/vx_error.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_ERROR_H_ -#define _OPENVX_INT_ERROR_H_ +#ifndef OPENVX_INT_ERROR_H_ +#define OPENVX_INT_ERROR_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_graph.h b/sample/include/vx_graph.h index 5baaab6..ee91f16 100644 --- a/sample/include/vx_graph.h +++ b/sample/include/vx_graph.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_GRAPH_H_ -#define _OPENVX_INT_GRAPH_H_ +#ifndef OPENVX_INT_GRAPH_H_ +#define OPENVX_INT_GRAPH_H_ #include diff --git a/sample/include/vx_image.h b/sample/include/vx_image.h index aef2dcb..e85a1f1 100644 --- a/sample/include/vx_image.h +++ b/sample/include/vx_image.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_IMAGE_H_ -#define _OPENVX_INT_IMAGE_H_ +#ifndef OPENVX_INT_IMAGE_H_ +#define OPENVX_INT_IMAGE_H_ #include diff --git a/sample/include/vx_import.h b/sample/include/vx_import.h index a475c75..475c1a3 100644 --- a/sample/include/vx_import.h +++ b/sample/include/vx_import.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_IMPORT_H_ -#define _OPENVX_INT_IMPORT_H_ +#ifndef OPENVX_INT_IMPORT_H_ +#define OPENVX_INT_IMPORT_H_ #include diff --git a/sample/include/vx_inlines.c b/sample/include/vx_inlines.c index b455f62..b8e162c 100644 --- a/sample/include/vx_inlines.c +++ b/sample/include/vx_inlines.c @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _VX_INLINES_C_ -#define _VX_INLINES_C_ +#ifndef VX_INLINES_C_ +#define VX_INLINES_C_ #include #include "vx_internal.h" diff --git a/sample/include/vx_internal.h b/sample/include/vx_internal.h index cef2dfa..0d34ca4 100644 --- a/sample/include/vx_internal.h +++ b/sample/include/vx_internal.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _VX_INTERNAL_H_ -#define _VX_INTERNAL_H_ +#ifndef VX_INTERNAL_H_ +#define VX_INTERNAL_H_ /*! * \file vx_internal.h diff --git a/sample/include/vx_kernel.h b/sample/include/vx_kernel.h index 7e61dfe..f2d3abd 100644 --- a/sample/include/vx_kernel.h +++ b/sample/include/vx_kernel.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_KERNEL_H_ -#define _OPENVX_INT_KERNEL_H_ +#ifndef OPENVX_INT_KERNEL_H_ +#define OPENVX_INT_KERNEL_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_log.h b/sample/include/vx_log.h index 8c532e9..870f892 100644 --- a/sample/include/vx_log.h +++ b/sample/include/vx_log.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_LOG_H_ -#define _OPENVX_INT_LOG_H_ +#ifndef OPENVX_INT_LOG_H_ +#define OPENVX_INT_LOG_H_ #include diff --git a/sample/include/vx_lut.h b/sample/include/vx_lut.h index 35f3505..9c682ec 100644 --- a/sample/include/vx_lut.h +++ b/sample/include/vx_lut.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_LUT_H_ -#define _OPENVX_INT_LUT_H_ +#ifndef OPENVX_INT_LUT_H_ +#define OPENVX_INT_LUT_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_matrix.h b/sample/include/vx_matrix.h index 6d278b2..ae68f92 100644 --- a/sample/include/vx_matrix.h +++ b/sample/include/vx_matrix.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_MATRIX_H_ -#define _OPENVX_INT_MATRIX_H_ +#ifndef OPENVX_INT_MATRIX_H_ +#define OPENVX_INT_MATRIX_H_ #include diff --git a/sample/include/vx_memory.h b/sample/include/vx_memory.h index a2be0db..e53f49c 100644 --- a/sample/include/vx_memory.h +++ b/sample/include/vx_memory.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_MEMORY_H_ -#define _OPENVX_INT_MEMORY_H_ +#ifndef OPENVX_INT_MEMORY_H_ +#define OPENVX_INT_MEMORY_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_meta_format.h b/sample/include/vx_meta_format.h index 443265c..38095ad 100644 --- a/sample/include/vx_meta_format.h +++ b/sample/include/vx_meta_format.h @@ -16,8 +16,8 @@ */ -#ifndef _OPENVX_INT_META_FORMAT_H_ -#define _OPENVX_INT_META_FORMAT_H_ +#ifndef OPENVX_INT_META_FORMAT_H_ +#define OPENVX_INT_META_FORMAT_H_ #include diff --git a/sample/include/vx_node.h b/sample/include/vx_node.h index 72d6e73..de1b1b4 100644 --- a/sample/include/vx_node.h +++ b/sample/include/vx_node.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_NODE_H_ -#define _OPENVX_INT_NODE_H_ +#ifndef OPENVX_INT_NODE_H_ +#define OPENVX_INT_NODE_H_ #include diff --git a/sample/include/vx_object_array.h b/sample/include/vx_object_array.h index f61d1f8..4f687c2 100644 --- a/sample/include/vx_object_array.h +++ b/sample/include/vx_object_array.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_OBJECT_ARRAY_H_ -#define _OPENVX_INT_OBJECT_ARRAY_H_ +#ifndef OPENVX_INT_OBJECT_ARRAY_H_ +#define OPENVX_INT_OBJECT_ARRAY_H_ #include diff --git a/sample/include/vx_osal.h b/sample/include/vx_osal.h index c19c867..ce822bd 100644 --- a/sample/include/vx_osal.h +++ b/sample/include/vx_osal.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_OSAL_H_ -#define _OPENVX_INT_OSAL_H_ +#ifndef OPENVX_INT_OSAL_H_ +#define OPENVX_INT_OSAL_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_parameter.h b/sample/include/vx_parameter.h index c9aabbc..08e33af 100644 --- a/sample/include/vx_parameter.h +++ b/sample/include/vx_parameter.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_PARAMETER_H_ -#define _OPENVX_INT_PARAMETER_H_ +#ifndef OPENVX_INT_PARAMETER_H_ +#define OPENVX_INT_PARAMETER_H_ #include diff --git a/sample/include/vx_pyramid.h b/sample/include/vx_pyramid.h index 8db49c7..6b50c53 100644 --- a/sample/include/vx_pyramid.h +++ b/sample/include/vx_pyramid.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_PYRAMID_H_ -#define _OPENVX_INT_PYRAMID_H_ +#ifndef OPENVX_INT_PYRAMID_H_ +#define OPENVX_INT_PYRAMID_H_ #include diff --git a/sample/include/vx_reference.h b/sample/include/vx_reference.h index bed04db..6444db2 100644 --- a/sample/include/vx_reference.h +++ b/sample/include/vx_reference.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_REF_H_ -#define _OPENVX_INT_REF_H_ +#ifndef OPENVX_INT_REF_H_ +#define OPENVX_INT_REF_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_remap.h b/sample/include/vx_remap.h index 750eb14..2792e40 100644 --- a/sample/include/vx_remap.h +++ b/sample/include/vx_remap.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_REMAP_H_ -#define _OPENVX_INT_REMAP_H_ +#ifndef OPENVX_INT_REMAP_H_ +#define OPENVX_INT_REMAP_H_ #include diff --git a/sample/include/vx_sample.h b/sample/include/vx_sample.h index f872c5c..338e878 100644 --- a/sample/include/vx_sample.h +++ b/sample/include/vx_sample.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _VX_SAMPLE_H_ -#define _VX_SAMPLE_H_ +#ifndef VX_SAMPLE_H_ +#define VX_SAMPLE_H_ #include @@ -49,5 +49,5 @@ enum _vx_sample_kernels_e { */ vx_node ownCreateNodeFromGraph(vx_graph parent, vx_graph child); -#endif /* _VX_SAMPLE_H_ */ +#endif /* VX_SAMPLE_H_ */ diff --git a/sample/include/vx_scalar.h b/sample/include/vx_scalar.h index 12408e3..90f8a3b 100644 --- a/sample/include/vx_scalar.h +++ b/sample/include/vx_scalar.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_SCALAR_H_ -#define _OPENVX_INT_SCALAR_H_ +#ifndef OPENVX_INT_SCALAR_H_ +#define OPENVX_INT_SCALAR_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_target.h b/sample/include/vx_target.h index d237832..cc5001f 100644 --- a/sample/include/vx_target.h +++ b/sample/include/vx_target.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_TARGET_H_ -#define _OPENVX_INT_TARGET_H_ +#ifndef OPENVX_INT_TARGET_H_ +#define OPENVX_INT_TARGET_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_tensor.h b/sample/include/vx_tensor.h index c5002b2..60c556c 100644 --- a/sample/include/vx_tensor.h +++ b/sample/include/vx_tensor.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_TENSOR_H_ -#define _OPENVX_INT_TENSOR_H_ +#ifndef OPENVX_INT_TENSOR_H_ +#define OPENVX_INT_TENSOR_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_threshold.h b/sample/include/vx_threshold.h index 6e8219e..d83b126 100644 --- a/sample/include/vx_threshold.h +++ b/sample/include/vx_threshold.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_threshold_H_ -#define _OPENVX_INT_threshold_H_ +#ifndef OPENVX_INT_threshold_H_ +#define OPENVX_INT_threshold_H_ #include #include "vx_internal.h" diff --git a/sample/include/vx_type_pairs.h b/sample/include/vx_type_pairs.h index 8a5b063..55466ff 100644 --- a/sample/include/vx_type_pairs.h +++ b/sample/include/vx_type_pairs.h @@ -15,8 +15,8 @@ * limitations under the License. */ -#ifndef _OPENVX_INT_type_pairs_H_ -#define _OPENVX_INT_type_pairs_H_ +#ifndef OPENVX_INT_type_pairs_H_ +#define OPENVX_INT_type_pairs_H_ #include #include diff --git a/sample/targets/c_model/vx_pyramid.c b/sample/targets/c_model/vx_pyramid.c index 30f0816..9f036d0 100644 --- a/sample/targets/c_model/vx_pyramid.c +++ b/sample/targets/c_model/vx_pyramid.c @@ -691,15 +691,95 @@ static vx_param_description_t laplacian_pyramid_kernel_params[] = static vx_status VX_CALLBACK vxLaplacianPyramidKernel(vx_node node, const vx_reference parameters[], vx_uint32 num) { - vx_status status = VX_FAILURE; - (void)node; - (void)parameters; + vx_status status = VX_SUCCESS; if (num == dimof(laplacian_pyramid_kernel_params)) { - status = VX_SUCCESS; + vx_context context = vxGetContext((vx_reference)node); + + vx_size lev; + vx_size levels = 1; + vx_uint32 width = 0; + vx_uint32 height = 0; + vx_uint32 level_width = 0; + vx_uint32 level_height = 0; + vx_df_image format; + vx_enum policy = VX_CONVERT_POLICY_SATURATE; + vx_border_t border; + vx_convolution conv = 0; + vx_image pyr_gauss_curr_level_filtered = 0; + vx_image pyr_laplacian_curr_level = 0; + vx_image input = (vx_image)parameters[0]; + vx_pyramid laplacian = (vx_pyramid)parameters[1]; + vx_image output = (vx_image)parameters[2]; + vx_pyramid gaussian = 0; + vx_image gauss_cur = 0; + vx_image gauss_next = 0; + + status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); + status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); + status |= vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format)); + + status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); + + status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); + + border.mode = VX_BORDER_REPLICATE; + + vxSetContextAttribute(context, VX_CONTEXT_IMMEDIATE_BORDER, &border, sizeof(border)); + + gaussian = vxCreatePyramid(context, levels + 1, VX_SCALE_PYRAMID_HALF, width, height, VX_DF_IMAGE_U8); + vxuGaussianPyramid(context, input, gaussian); + + conv = vxCreateGaussian5x5Convolution(context); + + level_width = width; + level_height = height; + + gauss_cur = vxGetPyramidLevel(gaussian, 0); + gauss_next = vxGetPyramidLevel(gaussian, 1); + for (lev = 0; lev < levels; lev++) + { + pyr_gauss_curr_level_filtered = vxCreateImage(context, level_width, level_height, VX_DF_IMAGE_S16); + upsampleImage(context, level_width, level_height, gauss_next, conv, pyr_gauss_curr_level_filtered, &border); + + pyr_laplacian_curr_level = vxGetPyramidLevel(laplacian, (vx_uint32)lev); + status |= vxuSubtract(context, gauss_cur, pyr_gauss_curr_level_filtered, policy, pyr_laplacian_curr_level); + + if (lev == levels - 1) + { + vx_image tmp = vxGetPyramidLevel(gaussian, (vx_uint32) levels); + ownCopyImage(tmp, output); + vxReleaseImage(&tmp); + vxReleaseImage(&gauss_next); + vxReleaseImage(&gauss_cur); + } + else + { + /* compute dimensions for the next level */ + level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_HALF); + level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_HALF); + /* prepare to the next iteration */ + /* make the next level of gaussian pyramid the current level */ + vxReleaseImage(&gauss_next); + vxReleaseImage(&gauss_cur); + gauss_cur = vxGetPyramidLevel(gaussian, (vx_uint32)lev + 1); + gauss_next = vxGetPyramidLevel(gaussian, (vx_uint32)lev + 2); + + } + + /* decrements the references */ + + status |= vxReleaseImage(&pyr_gauss_curr_level_filtered); + status |= vxReleaseImage(&pyr_laplacian_curr_level); + } + + status |= vxReleasePyramid(&gaussian); + status |= vxReleaseConvolution(&conv); } + return status; + } static vx_status VX_CALLBACK vxLaplacianPyramidInputValidator(vx_node node, vx_uint32 index) @@ -862,89 +942,8 @@ static vx_status VX_CALLBACK vxLaplacianPyramidInitializer(vx_node node, const v if (num == dimof(laplacian_pyramid_kernel_params)) { - vx_context context = vxGetContext((vx_reference)node); - - vx_size lev; - vx_size levels = 1; - vx_uint32 width = 0; - vx_uint32 height = 0; - vx_uint32 level_width = 0; - vx_uint32 level_height = 0; - vx_df_image format; - vx_enum policy = VX_CONVERT_POLICY_SATURATE; - vx_border_t border; - vx_convolution conv = 0; - vx_image pyr_gauss_curr_level_filtered = 0; - vx_image pyr_laplacian_curr_level = 0; - vx_image input = (vx_image)parameters[0]; - vx_pyramid laplacian = (vx_pyramid)parameters[1]; - vx_image output = (vx_image)parameters[2]; - vx_pyramid gaussian = 0; - vx_image gauss_cur = 0; - vx_image gauss_next = 0; - - status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); - status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); - status |= vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format)); - - status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); - - status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); - - border.mode = VX_BORDER_REPLICATE; - - vxSetContextAttribute(context, VX_CONTEXT_IMMEDIATE_BORDER, &border, sizeof(border)); - - gaussian = vxCreatePyramid(context, levels + 1, VX_SCALE_PYRAMID_HALF, width, height, VX_DF_IMAGE_U8); - vxuGaussianPyramid(context, input, gaussian); - - conv = vxCreateGaussian5x5Convolution(context); - - level_width = width; - level_height = height; - - gauss_cur = vxGetPyramidLevel(gaussian, 0); - gauss_next = vxGetPyramidLevel(gaussian, 1); - for (lev = 0; lev < levels; lev++) - { - pyr_gauss_curr_level_filtered = vxCreateImage(context, level_width, level_height, VX_DF_IMAGE_S16); - upsampleImage(context, level_width, level_height, gauss_next, conv, pyr_gauss_curr_level_filtered, &border); - - pyr_laplacian_curr_level = vxGetPyramidLevel(laplacian, (vx_uint32)lev); - status |= vxuSubtract(context, gauss_cur, pyr_gauss_curr_level_filtered, policy, pyr_laplacian_curr_level); - - if (lev == levels - 1) - { - vx_image tmp = vxGetPyramidLevel(gaussian, (vx_uint32) levels); - ownCopyImage(tmp, output); - vxReleaseImage(&tmp); - vxReleaseImage(&gauss_next); - vxReleaseImage(&gauss_cur); - } - else - { - /* compute dimensions for the next level */ - level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_HALF); - level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_HALF); - /* prepare to the next iteration */ - /* make the next level of gaussian pyramid the current level */ - vxReleaseImage(&gauss_next); - vxReleaseImage(&gauss_cur); - gauss_cur = vxGetPyramidLevel(gaussian, (vx_uint32)lev + 1); - gauss_next = vxGetPyramidLevel(gaussian, (vx_uint32)lev + 2); - - } - - /* decrements the references */ - - status |= vxReleaseImage(&pyr_gauss_curr_level_filtered); - status |= vxReleaseImage(&pyr_laplacian_curr_level); - } - - status |= vxReleasePyramid(&gaussian); - status |= vxReleaseConvolution(&conv); + /* computation moved to kernel */ } - return status; } @@ -988,15 +987,88 @@ static vx_param_description_t laplacian_reconstruct_kernel_params[] = static vx_status VX_CALLBACK vxLaplacianReconstructKernel(vx_node node, const vx_reference parameters[], vx_uint32 num) { - vx_status status = VX_FAILURE; - (void)node; - (void)parameters; + vx_status status = VX_SUCCESS; if (num == dimof(laplacian_reconstruct_kernel_params)) { - status = VX_SUCCESS; + vx_context context = vxGetContext((vx_reference)node); + + vx_size lev; + vx_size levels = 1; + vx_uint32 width = 0; + vx_uint32 height = 0; + vx_uint32 level_width = 0; + vx_uint32 level_height = 0; + vx_df_image format = VX_DF_IMAGE_S16; + vx_enum policy = VX_CONVERT_POLICY_SATURATE; + vx_border_t border; + vx_image filling = 0; + vx_image pyr_level = 0; + vx_image filter = 0; + vx_image out = 0; + vx_convolution conv; + + vx_pyramid laplacian = (vx_pyramid)parameters[0]; + vx_image input = (vx_image)parameters[1]; + vx_image output = (vx_image)parameters[2]; + + vx_scalar spolicy = vxCreateScalar(context, VX_TYPE_ENUM, &policy); + + status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); + status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); + + status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); + + status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); + border.mode = VX_BORDER_REPLICATE; + conv = vxCreateGaussian5x5Convolution(context); + + level_width = (vx_uint32)ceilf(width * VX_SCALE_PYRAMID_DOUBLE); + level_height = (vx_uint32)ceilf(height * VX_SCALE_PYRAMID_DOUBLE); + filling = vxCreateImage(context, width, height, format); + for (lev = 0; lev < levels; lev++) + { + out = vxCreateImage(context, level_width, level_height, format); + filter = vxCreateImage(context, level_width, level_height, format); + + pyr_level = vxGetPyramidLevel(laplacian, (vx_uint32)((levels - 1) - lev)); + + if (lev == 0) + { + ownCopyImage(input, filling); + } + upsampleImage(context, level_width, level_height, filling, conv, filter, &border); + vxAddition(filter, pyr_level, spolicy, out); + + status |= vxReleaseImage(&pyr_level); + + if ((levels - 1) - lev == 0) + { + ownCopyImage(out, output); + status |= vxReleaseImage(&filling); + } + else + { + /* compute dimensions for the next level */ + status |= vxReleaseImage(&filling); + filling = vxCreateImage(context, level_width, level_height, format); + ownCopyImage(out, filling); + + level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_DOUBLE); + level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_DOUBLE); + + + } + status |= vxReleaseImage(&out); + status |= vxReleaseImage(&filter); + + } + status |= vxReleaseConvolution(&conv); + status |= vxReleaseScalar(&spolicy); } + return status; + } static vx_status VX_CALLBACK vxLaplacianReconstructInputValidator(vx_node node, vx_uint32 index) @@ -1144,82 +1216,8 @@ static vx_status VX_CALLBACK vxLaplacianReconstructInitializer(vx_node node, con if (num == dimof(laplacian_reconstruct_kernel_params)) { - vx_context context = vxGetContext((vx_reference)node); - - vx_size lev; - vx_size levels = 1; - vx_uint32 width = 0; - vx_uint32 height = 0; - vx_uint32 level_width = 0; - vx_uint32 level_height = 0; - vx_df_image format = VX_DF_IMAGE_S16; - vx_enum policy = VX_CONVERT_POLICY_SATURATE; - vx_border_t border; - vx_image filling = 0; - vx_image pyr_level = 0; - vx_image filter = 0; - vx_image out = 0; - vx_convolution conv; - - vx_pyramid laplacian = (vx_pyramid)parameters[0]; - vx_image input = (vx_image)parameters[1]; - vx_image output = (vx_image)parameters[2]; - - vx_scalar spolicy = vxCreateScalar(context, VX_TYPE_ENUM, &policy); - - status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); - status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); - - status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); - - status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); - border.mode = VX_BORDER_REPLICATE; - conv = vxCreateGaussian5x5Convolution(context); - - level_width = (vx_uint32)ceilf(width * VX_SCALE_PYRAMID_DOUBLE); - level_height = (vx_uint32)ceilf(height * VX_SCALE_PYRAMID_DOUBLE); - filling = vxCreateImage(context, width, height, format); - for (lev = 0; lev < levels; lev++) - { - out = vxCreateImage(context, level_width, level_height, format); - filter = vxCreateImage(context, level_width, level_height, format); - - pyr_level = vxGetPyramidLevel(laplacian, (vx_uint32)((levels - 1) - lev)); - - if (lev == 0) - { - ownCopyImage(input, filling); - } - upsampleImage(context, level_width, level_height, filling, conv, filter, &border); - vxAddition(filter, pyr_level, spolicy, out); - - status |= vxReleaseImage(&pyr_level); - - if ((levels - 1) - lev == 0) - { - ownCopyImage(out, output); - status |= vxReleaseImage(&filling); - } - else - { - /* compute dimensions for the next level */ - status |= vxReleaseImage(&filling); - filling = vxCreateImage(context, level_width, level_height, format); - ownCopyImage(out, filling); - - level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_DOUBLE); - level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_DOUBLE); - - - } - status |= vxReleaseImage(&out); - status |= vxReleaseImage(&filter); - - } - status |= vxReleaseConvolution(&conv); - status |= vxReleaseScalar(&spolicy); + /* computation moved to kernel */ } - return status; } diff --git a/sample/targets/venum/vx_laplacianpyramid.c b/sample/targets/venum/vx_laplacianpyramid.c index 42c3fc2..4c80331 100644 --- a/sample/targets/venum/vx_laplacianpyramid.c +++ b/sample/targets/venum/vx_laplacianpyramid.c @@ -229,12 +229,93 @@ static vx_param_description_t laplacian_pyramid_kernel_params[] = static vx_status VX_CALLBACK vxLaplacianPyramidKernel(vx_node node, const vx_reference parameters[], vx_uint32 num) { + vx_status status = VX_SUCCESS; - vx_status status = VX_FAILURE; if (num == dimof(laplacian_pyramid_kernel_params)) { - status = VX_SUCCESS; + vx_context context = vxGetContext((vx_reference)node); + + vx_size lev; + vx_size levels = 1; + vx_uint32 width = 0; + vx_uint32 height = 0; + vx_uint32 level_width = 0; + vx_uint32 level_height = 0; + vx_df_image format; + vx_enum policy = VX_CONVERT_POLICY_SATURATE; + vx_border_t border; + vx_convolution conv = 0; + vx_image pyr_gauss_curr_level_filtered = 0; + vx_image pyr_laplacian_curr_level = 0; + vx_image input = (vx_image)parameters[0]; + vx_pyramid laplacian = (vx_pyramid)parameters[1]; + vx_image output = (vx_image)parameters[2]; + vx_pyramid gaussian = 0; + vx_image gauss_cur = 0; + vx_image gauss_next = 0; + vx_image upsample = 0; + + status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); + status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); + status |= vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format)); + + status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); + + status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); + + border.mode = VX_BORDER_REPLICATE; + + gaussian = vxCreatePyramid(context, levels + 1, VX_SCALE_PYRAMID_HALF, width, height, VX_DF_IMAGE_U8); + vxuGaussianPyramid(context, input, gaussian); + + conv = vxCreateGaussian5x5Convolution(context); + + level_width = width; + level_height = height; + + gauss_cur = vxGetPyramidLevel(gaussian, 0); + gauss_next = vxGetPyramidLevel(gaussian, 1); + for (lev = 0; lev < levels; lev++) + { + pyr_gauss_curr_level_filtered = vxCreateImage(context, level_width, level_height, VX_DF_IMAGE_S16); + xLaplacianPyramidupsampleImage(context, level_width, level_height, gauss_next, conv, pyr_gauss_curr_level_filtered, &border); + + pyr_laplacian_curr_level = vxGetPyramidLevel(laplacian, (vx_uint32)lev); + status |= vxuSubtract(context, gauss_cur, pyr_gauss_curr_level_filtered, policy, pyr_laplacian_curr_level); + vxReleaseImage(&upsample); + + if (lev == levels - 1) + { + vx_image tmp = vxGetPyramidLevel(gaussian, levels); + ownCopyImage(tmp, output); + vxReleaseImage(&tmp); + vxReleaseImage(&gauss_next); + vxReleaseImage(&gauss_cur); + } + else + { + /* compute dimensions for the next level */ + level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_HALF); + level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_HALF); + /* prepare to the next iteration */ + /* make the next level of gaussian pyramid the current level */ + vxReleaseImage(&gauss_next); + vxReleaseImage(&gauss_cur); + gauss_cur = vxGetPyramidLevel(gaussian, lev + 1); + gauss_next = vxGetPyramidLevel(gaussian, lev + 2); + + } + + /* decrements the references */ + + status |= vxReleaseImage(&pyr_gauss_curr_level_filtered); + status |= vxReleaseImage(&pyr_laplacian_curr_level); + } + + status |= vxReleasePyramid(&gaussian); + status |= vxReleaseConvolution(&conv); } + return status; } @@ -398,89 +479,8 @@ static vx_status VX_CALLBACK vxLaplacianPyramidInitializer(vx_node node, const v if (num == dimof(laplacian_pyramid_kernel_params)) { - vx_context context = vxGetContext((vx_reference)node); - - vx_size lev; - vx_size levels = 1; - vx_uint32 width = 0; - vx_uint32 height = 0; - vx_uint32 level_width = 0; - vx_uint32 level_height = 0; - vx_df_image format; - vx_enum policy = VX_CONVERT_POLICY_SATURATE; - vx_border_t border; - vx_convolution conv = 0; - vx_image pyr_gauss_curr_level_filtered = 0; - vx_image pyr_laplacian_curr_level = 0; - vx_image input = (vx_image)parameters[0]; - vx_pyramid laplacian = (vx_pyramid)parameters[1]; - vx_image output = (vx_image)parameters[2]; - vx_pyramid gaussian = 0; - vx_image gauss_cur = 0; - vx_image gauss_next = 0; - vx_image upsample = 0; - - status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); - status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); - status |= vxQueryImage(input, VX_IMAGE_FORMAT, &format, sizeof(format)); - - status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); - - status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); - - border.mode = VX_BORDER_REPLICATE; - - gaussian = vxCreatePyramid(context, levels + 1, VX_SCALE_PYRAMID_HALF, width, height, VX_DF_IMAGE_U8); - vxuGaussianPyramid(context, input, gaussian); - - conv = vxCreateGaussian5x5Convolution(context); - - level_width = width; - level_height = height; - - gauss_cur = vxGetPyramidLevel(gaussian, 0); - gauss_next = vxGetPyramidLevel(gaussian, 1); - for (lev = 0; lev < levels; lev++) - { - pyr_gauss_curr_level_filtered = vxCreateImage(context, level_width, level_height, VX_DF_IMAGE_S16); - xLaplacianPyramidupsampleImage(context, level_width, level_height, gauss_next, conv, pyr_gauss_curr_level_filtered, &border); - - pyr_laplacian_curr_level = vxGetPyramidLevel(laplacian, (vx_uint32)lev); - status |= vxuSubtract(context, gauss_cur, pyr_gauss_curr_level_filtered, policy, pyr_laplacian_curr_level); - vxReleaseImage(&upsample); - - if (lev == levels - 1) - { - vx_image tmp = vxGetPyramidLevel(gaussian, levels); - ownCopyImage(tmp, output); - vxReleaseImage(&tmp); - vxReleaseImage(&gauss_next); - vxReleaseImage(&gauss_cur); - } - else - { - /* compute dimensions for the next level */ - level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_HALF); - level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_HALF); - /* prepare to the next iteration */ - /* make the next level of gaussian pyramid the current level */ - vxReleaseImage(&gauss_next); - vxReleaseImage(&gauss_cur); - gauss_cur = vxGetPyramidLevel(gaussian, lev + 1); - gauss_next = vxGetPyramidLevel(gaussian, lev + 2); - - } - - /* decrements the references */ - - status |= vxReleaseImage(&pyr_gauss_curr_level_filtered); - status |= vxReleaseImage(&pyr_laplacian_curr_level); - } - - status |= vxReleasePyramid(&gaussian); - status |= vxReleaseConvolution(&conv); + /* computation moved to kernel */ } - return status; } diff --git a/sample/targets/venum/vx_pyramid.c b/sample/targets/venum/vx_pyramid.c index 5959f55..9f45956 100644 --- a/sample/targets/venum/vx_pyramid.c +++ b/sample/targets/venum/vx_pyramid.c @@ -741,12 +741,88 @@ static vx_param_description_t laplacian_reconstruct_kernel_params[] = static vx_status VX_CALLBACK vxLaplacianReconstructKernel(vx_node node, const vx_reference parameters[], vx_uint32 num) { - vx_status status = VX_FAILURE; + vx_status status = VX_SUCCESS; + if (num == dimof(laplacian_reconstruct_kernel_params)) { - status = VX_SUCCESS; + vx_context context = vxGetContext((vx_reference)node); + + vx_size lev; + vx_size levels = 1; + vx_uint32 width = 0; + vx_uint32 height = 0; + vx_uint32 level_width = 0; + vx_uint32 level_height = 0; + vx_df_image format = VX_DF_IMAGE_S16; + vx_enum policy = VX_CONVERT_POLICY_SATURATE; + vx_border_t border; + vx_image filling = 0; + vx_image pyr_level = 0; + vx_image filter = 0; + vx_image out = 0; + vx_convolution conv; + + vx_pyramid laplacian = (vx_pyramid)parameters[0]; + vx_image input = (vx_image)parameters[1]; + vx_image output = (vx_image)parameters[2]; + + vx_scalar spolicy = vxCreateScalar(context, VX_TYPE_ENUM, &policy); + + status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); + status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); + + status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); + + status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); + border.mode = VX_BORDER_REPLICATE; + conv = vxCreateGaussian5x5Convolution(context); + + level_width = (vx_uint32)ceilf(width * VX_SCALE_PYRAMID_DOUBLE); + level_height = (vx_uint32)ceilf(height * VX_SCALE_PYRAMID_DOUBLE); + filling = vxCreateImage(context, width, height, format); + for (lev = 0; lev < levels; lev++) + { + out = vxCreateImage(context, level_width, level_height, format); + filter = vxCreateImage(context, level_width, level_height, format); + + pyr_level = vxGetPyramidLevel(laplacian, (vx_uint32)((levels - 1) - lev)); + + if (lev == 0) + { + ownCopyImage_S16(input, filling); + } + upsampleImage(context, level_width, level_height, filling, conv, filter, &border); + vxAddition(filter, pyr_level, spolicy, out); + + status |= vxReleaseImage(&pyr_level); + + if ((levels - 1) - lev == 0) + { + ownCopyImage(out, output); + status |= vxReleaseImage(&filling); + } + else + { + /* compute dimensions for the next level */ + status |= vxReleaseImage(&filling); + filling = vxCreateImage(context, level_width, level_height, format); + ownCopyImage(out, filling); + + level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_DOUBLE); + level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_DOUBLE); + + + } + status |= vxReleaseImage(&out); + status |= vxReleaseImage(&filter); + + } + status |= vxReleaseConvolution(&conv); + status |= vxReleaseScalar(&spolicy); } + return status; + } static vx_status VX_CALLBACK vxLaplacianReconstructInputValidator(vx_node node, vx_uint32 index) @@ -967,82 +1043,8 @@ static vx_status VX_CALLBACK vxLaplacianReconstructInitializer(vx_node node, con if (num == dimof(laplacian_reconstruct_kernel_params)) { - vx_context context = vxGetContext((vx_reference)node); - - vx_size lev; - vx_size levels = 1; - vx_uint32 width = 0; - vx_uint32 height = 0; - vx_uint32 level_width = 0; - vx_uint32 level_height = 0; - vx_df_image format = VX_DF_IMAGE_S16; - vx_enum policy = VX_CONVERT_POLICY_SATURATE; - vx_border_t border; - vx_image filling = 0; - vx_image pyr_level = 0; - vx_image filter = 0; - vx_image out = 0; - vx_convolution conv; - - vx_pyramid laplacian = (vx_pyramid)parameters[0]; - vx_image input = (vx_image)parameters[1]; - vx_image output = (vx_image)parameters[2]; - - vx_scalar spolicy = vxCreateScalar(context, VX_TYPE_ENUM, &policy); - - status |= vxQueryImage(input, VX_IMAGE_WIDTH, &width, sizeof(width)); - status |= vxQueryImage(input, VX_IMAGE_HEIGHT, &height, sizeof(height)); - - status |= vxQueryPyramid(laplacian, VX_PYRAMID_LEVELS, &levels, sizeof(levels)); - - status |= vxQueryNode(node, VX_NODE_BORDER, &border, sizeof(border)); - border.mode = VX_BORDER_REPLICATE; - conv = vxCreateGaussian5x5Convolution(context); - - level_width = (vx_uint32)ceilf(width * VX_SCALE_PYRAMID_DOUBLE); - level_height = (vx_uint32)ceilf(height * VX_SCALE_PYRAMID_DOUBLE); - filling = vxCreateImage(context, width, height, format); - for (lev = 0; lev < levels; lev++) - { - out = vxCreateImage(context, level_width, level_height, format); - filter = vxCreateImage(context, level_width, level_height, format); - - pyr_level = vxGetPyramidLevel(laplacian, (vx_uint32)((levels - 1) - lev)); - - if (lev == 0) - { - ownCopyImage_S16(input, filling); - } - upsampleImage(context, level_width, level_height, filling, conv, filter, &border); - vxAddition(filter, pyr_level, spolicy, out); - - status |= vxReleaseImage(&pyr_level); - - if ((levels - 1) - lev == 0) - { - ownCopyImage(out, output); - status |= vxReleaseImage(&filling); - } - else - { - /* compute dimensions for the next level */ - status |= vxReleaseImage(&filling); - filling = vxCreateImage(context, level_width, level_height, format); - ownCopyImage(out, filling); - - level_width = (vx_uint32)ceilf(level_width * VX_SCALE_PYRAMID_DOUBLE); - level_height = (vx_uint32)ceilf(level_height * VX_SCALE_PYRAMID_DOUBLE); - - - } - status |= vxReleaseImage(&out); - status |= vxReleaseImage(&filter); - - } - status |= vxReleaseConvolution(&conv); - status |= vxReleaseScalar(&spolicy); + /* computation moved to kernel */ } - return status; }