TractorVision初期移植
This commit is contained in:
30
lib/io/process2d.py
Normal file
30
lib/io/process2d.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from multiprocessing import Process
|
||||
from lib.camera.MindVisionCamera import MindVisionCamera
|
||||
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
|
||||
# 仅对轨道摄像头启用 TrackDetector
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
sig = self.in_q.get()
|
||||
if sig == CameraControl.CAPTURE:
|
||||
img = self.camera.capture()
|
||||
self.out_q.put(img)
|
||||
elif sig == CameraControl.DESTORY:
|
||||
for fn in ("destroy", "close", "release"):
|
||||
if hasattr(self.camera, fn):
|
||||
try:
|
||||
getattr(self.camera, fn)()
|
||||
except:
|
||||
pass
|
||||
break
|
Reference in New Issue
Block a user