VisionWorks / OpenVX on TX1 - vxMapArrayRange

Hi All,

I am trying to use vxMapArrayRange() to write some initial values to vx_array. But it is always returning failed (error code -10 == VX_ERROR_INVALID_PARAMETERS).

Below is a piece of code that demonstrates the issue. Any suggestion is highly appreciated.

Thanks,
Byin

#include <VX/vx.h>
#include <stdio.h>//printf()
#include <stdlib.h>//exit() 
#define ERROR_CHECK_STATUS( status ) { \
	vx_status status_ = (status); \
	if(status_ != VX_SUCCESS) { \
		printf("No ERROR: failed with status = (%d) at " __FILE__ "#%d\n", status_, __LINE__); \
		exit(1); \
	} \
}

int main() {
	vx_context context = vxCreateContext();	
	vx_array array = vxCreateArray(context, VX_TYPE_KEYPOINT, 50);
	
	vx_size stride = sizeof(vx_size);
	void *base = NULL;
	vx_map_id map_id;
	/* access entire array at once */
	ERROR_CHECK_STATUS(vxMapArrayRange(array, 0, 20, &map_id, &stride, &base, VX_READ_AND_WRITE, VX_MEMORY_TYPE_HOST, 0));
/*	
	vx_size i = 0;
	vx_kepoint_t* cur_entry_ptr = (vx_keypoint_t*)(base + i * stride);
	//since vxMapArrayRange() fail, the cur_entry_ptr is invalid, via which I cannot read or write data in "array[i]".
*/
	vxUnmapArrayRange(array, map_id);
	return 0;
}

========
I also have tried to use vxCopyArrayRange(), got same error code -10.

Hi,

Could you run hough transform sample first since it also use vxMapArrayRange()?
I have tested on my tx1, build and run successfully.

$ /usr/share/visionworks/sources/install-samples.sh .
$ cd VisionWorks-1.5-Samples/
$ make
$ ./bin/aarch64/linux/release/nvx_demo_hough_transform

Please let me know the results.
Thanks.

Hi AstaLLL,

Thanks for your quick response. That Hough Transform runs on my TX1. But when looking into the code, I found there is a significant difference.

When vxMapArrayRange() called for first time at line 548, the parameter “circles”(reference of a vx_array) has already been operated(filled) by nvxHoughCirclesNode() at line 437. Before that, vx_array circles is created by vxCreateArray() at line 352.

========

  1. Is this HT example suggesting that vxMapArrayRange() or vxCopyArray() can only be called after some assignment to vx_array by the vx / nvx node or method?

  2. Will vxCreateArray() create an instance / object of vx_array or just a reference to that type?

Thanks,
Byin

Hi,

This is the Makefile to that piece of code.

vxArrayMapRangeTest: main.cpp
	gcc -o vxArrayMapRangeTest main.cpp -lvisionworks

Thanks,
Byin

Hi,

Sorry for my late reply.
Error code -10 means VX_ERROR_INVALID_PARAMETERS.

vxMapArrayRange function are used to access a set of valid items in the array.
When you create the array with a given capacity, you tell how much memory needs to be allocated, but the array is empty (there is no item in it yet). Then, calling vxAccessArrayRange returns an error.

Try to add some item before calling vxMapArrayRange() and this issue should be fixed.

#include <VX/vx.h>
#include <stdio.h>//printf()
#include <stdlib.h>//exit() 
#define ERROR_CHECK_STATUS( status ) { \
	vx_status status_ = (status); \
        if(status_ != VX_SUCCESS) { \
        	printf("No ERROR: failed with status = (%d) at " __FILE__ "#%d\n", status_, __LINE__); \
        	exit(1); \
        } \
}

int main() {
    vx_context context = vxCreateContext();	
    vx_array array = vxCreateArray(context, VX_TYPE_KEYPOINT, 50);

    vx_keypoint_t keypoints[50];
    for(int i=0; i<50; i++) {
        keypoints[i].x = 0;
        keypoints[i].y = 0;
    }
    ERROR_CHECK_STATUS(vxAddArrayItems(array, 50, &keypoints, sizeof(vx_keypoint_t)));

    vx_size stride = sizeof(vx_size);
    void *base = NULL;
    vx_map_id map_id;
    /* access entire array at once */
    ERROR_CHECK_STATUS(vxMapArrayRange(array, 0, 20, &map_id, &stride, &base, VX_READ_AND_WRITE, VX_MEMORY_TYPE_HOST, 0));
/*	
    vx_size i = 0;
    vx_keypoint_t* cur_entry_ptr = (vx_keypoint_t*)(base + i * stride);
    //since vxMapArrayRange() fail, the cur_entry_ptr is invalid, via which I cannot read or write data in "array[i]".
*/
    vxUnmapArrayRange(array, map_id);
    return 0;
}