Closed AbdelRahmanNasser20 closed 2 years ago
@AbdelRahmanNasser20 The error is insufficient for me to know exactly what you are trying to do here. The array of shape 307200 is bytestream and it might be that you want to reshape it into depth image shape. But I need more information.
depth_bytestream.reshape((1,)+depth_image_shape)
This error originates in circular_buffer_numpy library. Here is the simplest code that reproduces the error and provides work-around, see 'In [8]:' In [8]: buffer.append(img.reshape((1,) + img.shape))
. Here the image was reshape to include an extra dimension with length 1, which helps with appending.
In [1]: from time import time
In [2]: from circular_buffer_numpy.circular_buffer import CircularBuffer
In [3]: import numpy as np
In [4]: buffer = CircularBuffer((100, 480, 640), dtype="float64")
In [5]: img = np.zeros((480, 640)) + time()
In [6]: buffer.append(img)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [6], in <module>
----> 1 buffer.append(img)
File c:\users\ar-vr lab w1\appdata\local\programs\python\python38\lib\site-packages\circular_buffer_numpy\circular_buffer.py:72, in CircularBuffer.append(self, data)
51 """
52 appends data to the existing circular buffer.
53
(...)
69 5
70 """
71 if len(data.shape) == len(self.shape)-1:
---> 72 data = data.reshape((1,data.shape[0]))
73 for i in range(data.shape[0]):
74 if self.pointer == self.shape[0]-1:
ValueError: cannot reshape array of size 307200 into shape (1,480)
In [7]: buffer.append(img.reshape(1, img.shape))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [7], in <module>
----> 1 buffer.append(img.reshape(1, img.shape))
TypeError: 'tuple' object cannot be interpreted as an integer
In [8]: buffer.append(img.reshape((1,) + img.shape))
@AbdelRahmanNasser20 There is a bug in circular buffer library and it does not allow appending of image without addition reshaping. you can modify your code to reshape images prior to appending as show in example below.
buffer.append(img.reshape((1,) + img.shape))
Thanks, just implemented it and it works
Having issues with inserting img (color,depth,inf) data into the circular buffer. ERROR: depth_array = np.asanyarray((img_dict[DEPTH])).reshape(1,1) ValueError: cannot reshape array of size 307200 into shape (1,1) not sure how to reshape it correctly.