I am running a GUI with kivy, and simultaneously processing some realtime 3D scanner data. I'm using a multiprocessing instance to process the scan data, while the kivy GUI runs. The scanner data is read in by OpenCV, frame by frame.
My issue is that I can share the scanner data with the kivy instance, in order to display it within the GUI. I have tried making the the array "frame" global, but that doesn't seem to be doing the trick.
I have read about the multiprocessing manager, but im unclear on how to use it to manage a numpy array.
frame = np.zeros((480,640))
class CamApp(App):
def update_slider(self, instance, value):
#print(value)
self.slider_value = value*3
def build(self):
self.img1=Image()
layout = GridLayout(cols = 1)
layout.add_widget(self.img1)
Clock.schedule_interval(self.update, 1.0/33.0)
return layout
def update(self, dt):
global frame
#format as texture
buf1 = cv2.flip(frame, 0)
buf = buf1.tobytes()
texture1 = Texture.create(size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
texture1.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
# display image from the texture
self.img1.texture = texture1
def cam(message):
print(message)
dc = DepthCamera()
global frame
while True:
ret, depth_frame, colour_frame = dc.get_frame()
frame = cv2.applyColorMap(cv2.convertScaleAbs(depth_frame, alpha=0.2), cv2.COLORMAP_BONE)
#cv2.imshow("Depth frame", frame)
#cv2.imshow("Color frame", colour_frame)
#key = cv2.waitKey(1)
if __name__ == '__main__':
p = Process(target=cam, args=('beginning capture',))
p.start()
CamApp().run()
cv2.destroyAllWindows()