updated cv_pubsubs to handle multiple output windows. Combined all RGC filters into one file. Added whole image color averaging.
This commit is contained in:
+5
-1
@@ -18,6 +18,7 @@ def get_open_cv_cam_ids(): # type: () -> List[cv2.VideoCapture]
|
||||
cam_list.append(len(cam_list))
|
||||
|
||||
return cam_list
|
||||
import time
|
||||
|
||||
def pub_cv_cam_thread(camId, # type: Union[int, str]
|
||||
requestSize=(1280, 720) # type: Tuple[int, int]
|
||||
@@ -30,7 +31,10 @@ def pub_cv_cam_thread(camId, # type: Union[int, str]
|
||||
if not cam.isOpened():
|
||||
pubsub.publish("cvcams." + str(camId) + ".status", "failed")
|
||||
return False
|
||||
now = time.time()
|
||||
while ( msg != 'q'):
|
||||
time.sleep(1./(60-(time.time()-now)))
|
||||
now = time.time()
|
||||
(ret, frame) = cam.read() # type: Tuple[bool, np.ndarray ]
|
||||
if ret is False or not isinstance(frame, np.ndarray):
|
||||
cam.release()
|
||||
@@ -77,7 +81,7 @@ def cv_cam_pub_handler(camId, # type: Union[int, str]
|
||||
frame = frame[0]
|
||||
frameHandler(frame, camId)
|
||||
msgOwner = listenFixed(subOwner, block=False, empty='')
|
||||
pubsub.publish("cvcams.0.cmd", 'q')
|
||||
pubsub.publish("cvcams."+str(camId)+".cmd", 'q')
|
||||
t.join()
|
||||
|
||||
def init_cv_cam_pub_handler(camId, # type: Union[int, str]
|
||||
|
||||
+19
-8
@@ -5,30 +5,41 @@ if False:
|
||||
|
||||
cvWindows = []
|
||||
frameDict={}
|
||||
|
||||
import time
|
||||
def cv_win_sub(*,
|
||||
names, # type: List[str]
|
||||
inputVidGlobalNames, # type: List[str]
|
||||
callbacks=(None,)
|
||||
):
|
||||
global cvWindows
|
||||
for name in names:
|
||||
cvWindows.append(name)
|
||||
cv2.namedWindow(name)
|
||||
|
||||
global frameDict
|
||||
firstRun=True
|
||||
timeMod = None
|
||||
while True:
|
||||
t = int(time.time()) * 1000
|
||||
if firstRun:
|
||||
timeMod = t % 1000
|
||||
firstRun = False
|
||||
#global camImg
|
||||
for i in range(len(inputVidGlobalNames)):
|
||||
if inputVidGlobalNames[i] in frameDict and frameDict[inputVidGlobalNames[i]] is not None:
|
||||
if callbacks[i%len(callbacks)] is not None:
|
||||
frame = callbacks[i%len(callbacks)](frameDict[inputVidGlobalNames[i]])
|
||||
frames = callbacks[i%len(callbacks)](frameDict[inputVidGlobalNames[i]])
|
||||
else:
|
||||
frame = frameDict[inputVidGlobalNames[i]]
|
||||
cv2.imshow(names[i%len(names)], frame)
|
||||
frames = frameDict[inputVidGlobalNames[i]]
|
||||
for i in range(len(frames)):
|
||||
if t % 1000 == timeMod:
|
||||
if names[i%len(names)]+str(i) not in cvWindows:
|
||||
cvWindows.append(names[i%len(names)]+str(i))
|
||||
cv2.namedWindow(names[i%len(names)]+str(i))
|
||||
cv2.imshow(names[i%len(names)]+str(i), frames[i])
|
||||
if cv2.waitKey(1)& 0xFF==ord('q'):
|
||||
for name in names:
|
||||
for name in cvWindows:
|
||||
cv2.destroyWindow(name)
|
||||
for n in names:
|
||||
pubsub.publish("cvcamhandlers." + str(n) + ".cmd", "q")
|
||||
|
||||
return
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user