Skip to content

Commit 3057675

Browse files
committed
Let image processor create shared array
1 parent 9f60684 commit 3057675

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lfgen/image_processor.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ def set_dims_and_get_array(self, x, y, extension):
8888

8989
return self._get_array(image)
9090

91+
def get_shared_numpy_array(self, array):
92+
return np.ndarray((self.buffer_height, self.buffer_width, 3), dtype=np.uint8, buffer=array.buf)
93+
9194
def set_shared_array_from_image(self, x, y, np_img, image):
9295
array_x_start = x*self.output_width
9396
array_y_start = (self.max_y-y)*self.output_height
@@ -103,7 +106,7 @@ def set_shared_array(self, x, y, extension, array):
103106
self.set_shared_array_from_image(
104107
x,
105108
y,
106-
np.ndarray((self.buffer_height, self.buffer_width, 3), dtype=np.uint8, buffer=array.buf),
109+
self.get_shared_numpy_array(array),
107110
self._get_array(self._get_image(x, y, extension))
108111
)
109112

lfgen/main.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ def main():
126126
shared_array = smm.SharedMemory(
127127
(max_x+1)*img_processor.output_width*(max_y+1)*img_processor.output_height*3
128128
)
129-
shared_np_array = np.ndarray((
130-
img_processor.buffer_height,
131-
img_processor.buffer_width,
132-
3
133-
), buffer=shared_array.buf, dtype=np.uint8)
129+
shared_np_array = img_processor.get_shared_numpy_array(shared_array)
134130

135131
img_processor.set_shared_array_from_image(x, y, shared_np_array, subimage)
136132

0 commit comments

Comments
 (0)