31 lines
1012 B
Python
31 lines
1012 B
Python
from multiprocessing import Process
|
|
from lib.camera.MindVisionCamera import MindVisionCamera
|
|
from lib.cfg import cfg
|
|
from lib.cfg.cfg import CameraControl
|
|
|
|
|
|
class Process2D(Process):
|
|
def __init__(self, cfg, in_q, out_q):
|
|
# 设置进程名称
|
|
super().__init__(name=f"3D-{cfg['title']}")
|
|
self.cfg = cfg
|
|
self.in_q = in_q
|
|
self.out_q = out_q
|
|
self.camera = MindVisionCamera(cfg["sn"])
|
|
self.status = 0
|
|
|
|
def run(self):
|
|
while True:
|
|
sig = self.in_q.get()
|
|
if sig == CameraControl.CAPTURE:
|
|
img = self.camera.capture()
|
|
self.out_q.put({"title": cfg["title"], "img": img})
|
|
elif sig == CameraControl.DESTORY:
|
|
for fn in ("destroy", "close", "release"):
|
|
if hasattr(self.camera, fn):
|
|
try:
|
|
getattr(self.camera, fn)()
|
|
except:
|
|
pass
|
|
break
|