0

I am trying to pass SIFT features to netcdf file but when I tried to do then it shows me following error(I am using Ubuntu 15.10 and coding in python).

File "/home/Research/netcdf_helpers.py", line 15, in createNcVar nc_var.assignValue(data) ValueError: object too deep for desired array

I searched various solutions but still finding the correct solution for this.

Current format of my data structure is as follows:

[[(file1feature1,file1feature2,file1feature3,file1feature4,file1feature5),(file2feature1,file2feature2,file2feature3,file2feature4,file2feature5)(file3feature1,file3feature2,file3feature3,file3feature4,file3feature5)]]

The desired output I am looking to achieve is as follows:

[file1feature1,file1feature2,file1feature3,file1feature4,file2feature5,file2feature1,file2feature2,file2feature3,file2feature4.......]

I have consumed half of my day for correcting this error but still struggling. Any help would be highly appreciated.

3
  • With respect to the desired output, do you require the list to be sorted and if yes is it just exactly the way its specified above? Commented Feb 9, 2016 at 10:19
  • Actually, I need features values from an image, its not essential the list to be sorted. Commented Feb 9, 2016 at 10:51
  • The answer below, does it achieve the output you are looking for? Commented Feb 9, 2016 at 10:52

1 Answer 1

1

Example:

In order to mimic your data structure I used following data:

raw_data = [[(1, 2, 3), (9, 8, 7), (5, 6, 0)]]]  # this is the raw data

Following operation achieves the structure you are after:

data = () # place holder for your filtered data

for entry in raw_data[0]:  # operation
    data += entry

Output:

print(list(data)) # [1, 2, 3, 9, 8, 7, 5, 6, 0]
Sign up to request clarification or add additional context in comments.

7 Comments

The statement which is extracting SIFT features is as follows, temp = (point.size, point.angle, point.response, point.octave, point.class_id) If I will take 30 SIFT keypoints then for every keypoint the temp will record 5 features point and assigned to temp. After that I am appending a local list. The global list is appending with local list values and for next image the local list will be empty initially.
The code above should transform the raw output of that operation into the desired output you've declared in your original post.
Thanks for your help but this is not actual solution I am looking for. I am not sure about the data[ ][ ] because I am using huge dataset. I want general solution not to be specific with the elements of array. No matter how many elements in array I want at the end [1,2,3,4,5,6,7....]
github.com/jpuigcerver/rnnlib/blob/master/utils/… In this file the line 30 is creating problem for my code. I passed all values this file requires but when I passed feature values to it, I stucked with an error as mentioned above.
The initial solution has been a generic. The edited version is independed from no. of elements in your row data.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.