0

so I return (N.B. self.name is %s, others %f)

return np.array([self.name, self.x1_hand, self.y1_hand, self.x2_hand, self.y2_hand, self.x1_obj, self.y1_obj, self.x2_hand, self.x2_obj])

and if variable exists I append, if not I set that one as [0] (making array of arrays) temp is the array returned (the one above)

            if 'array' in locals():
                print(array)
                print(temp)
                array = np.append(array,temp)
            else:
                array = temp

after some data processing, I get an array shape (1188,) which I need to save to a file

['61255/0014.jpg' '0' '193.7876340493057' ... '86.83602771362587' '147.85219399538107' '240.13856812933022'] ['47350/0024.jpg' '90.4849884526559' '81.20092378752885' '134.54965357967666' '114.73441108545035' '215.05773672055426' '87.02078521939954' '134.54965357967666' '262.5866050808314'] ['61255/0014.jpg' '0' '193.7876340493057' '152.51979991070488' '239.04912287258873']

as

name x1 y1 x2 y2 x1' y1' x2' y2'
name x1 y1 x2 y2 x1' y1' x2' y2'
name x1 y1 x2 y2 x1' y1' x2' y2'

for instance: (shape: (8,1))

61255/0014.jpg 0 193.7876340493057 ... 86.83602771362587 147.85219399538107 240.13856812933022

I struggle getting the array in right format, saving because it is a mix of data, getting an error back saying format doesn't match, also I need to make a row out of an array. How should I approach this?

jokkk2312
  • 61
  • 5
  • Take a look at this post, I thinks it is quite similar problem: https://stackoverflow.com/questions/24832715/numpy-array-matrix-of-mixed-types – Rune Trold Aug 17 '22 at 14:44

1 Answers1

0
            if 'array' in locals():
                array = np.append(array,temp, axis=0)
            else:
                array = temp

The code was missing the keyword and that is 'axis=0', where it defines in what axis the line has to be added.

jokkk2312
  • 61
  • 5