Browse Source

fix: vpu cam add: watchdog_vpu.py

micha 1 year ago
parent
commit
50fd543208
3 changed files with 124 additions and 15 deletions
  1. 12 7
      vpu/autostart.sh
  2. 16 8
      vpu/vpu_live.py
  3. 96 0
      vpu/watchdog_vpu.py

+ 12 - 7
vpu/autostart.sh

@@ -19,16 +19,21 @@ screen -m -d -S ASP -- python3 /opt/LibreLight/ASP/ArtNetProcessor.py
 #screen -m -d -S shader -- python3 /opt/LibreLight/Xdesk/vpu/shader_live.py
 #screen -m -d -S shader -- python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py -m 16,12,5
 
-screen -XS "vpu1_out" quit
-screen -XS "vpu2_out" quit
+#screen -XS "vpu01_out" quit
+#screen -XS "vpu02_out" quit
 
-# Ayrton VPU Offset Y ___ Y ___ (Ghost 255)
-screen -m -d -S vpu1_out -- python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py -m 16,12,5 -X 12 --pixel-map=_1 --gobo-ch=11 --countdown=31,51,151,171 --videoplayer=181,201 --title=LIVE
-sleep 1
+screen -XS "watchdog_vpu" quit
+#sleep 1
 
-# Ayrton VPU Offset X 235 Y 253 (Pannel 255)  7,5m-4m ... 9,5m-4m
-screen -m -d -S vpu2_out -- python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py -m 16,4,6 -X 4  --pixel-map=_2 --gobo-ch=21 --win-pos 430,164 --start-univ=4 --countdown=71,91,111,131 --videoplayer=221,241 --title=LIVE
+screen -m -d -S watchdog_vpu -- python3 /opt/LibreLight/Xdesk/vpu/watchdog_vpu.py
 
+## Ayrton VPU Offset Y ___ Y ___ (Ghost 255)
+#screen -m -d -S vpu1_out -- python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py -m 16,12,5 -X 12 --pixel-map=_1 --gobo-ch=11 --countdown=31,51,151,171 --videoplayer=181,201 --title=LIVE
+sleep 1
+#
+## Ayrton VPU Offset X 235 Y 253 (Pannel 255)  7,5m-4m ... 9,5m-4m
+#screen -m -d -S vpu2_out -- python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py -m 16,4,6 -X 4  --pixel-map=_2 --gobo-ch=21 --win-pos 430,164 --start-univ=4 --countdown=71,91,111,131 --videoplayer=221,241 --title=LIVE
+#
 sleep 3
 
 screen -ls

+ 16 - 8
vpu/vpu_live.py

@@ -215,6 +215,7 @@ class Vopen():
         self.end = 0
         self._video_nr = 0
 
+        self._stop = 0 # fix buffer-overflow ... ?? opencv
 
         self.shape_x = 370
         self.shape_y = 235
@@ -352,7 +353,9 @@ class Vopen():
                 print("Exception", "cam_cfg 878",e)
 
         df = "video{}".format(d)
-        if os.path.exists("/dev/{}".format(df)):
+        if self._stop:
+            df += "_stop"
+        elif os.path.exists("/dev/{}".format(df)):
             self.Rcap = self.cv2.VideoCapture(d)
             self.Rcap.set(self.cv2.CAP_PROP_FRAME_WIDTH, w)
             self.Rcap.set(self.cv2.CAP_PROP_FRAME_HEIGHT, h)
@@ -377,6 +380,8 @@ class Vopen():
     
         self.Rsuccess = 0
         if self.cv2:
+            if self._stop:
+                return
             #self.Rcap = self.cv2.VideoCapture(self.fpath+self.fname)
 
             #self.Rcap = self.cv2.VideoCapture(self.fpath+self.fname, cv2.CAP_GSTREAMER) 
@@ -398,6 +403,7 @@ class Vopen():
             self.Rsuccess = 1
             self._read()
     def _del(self):
+        self._stop = 1
         #self.Rcap = self.cv2.VideoCapture(self.fpath+self.fname)
         #for i in dir(self.Rcap):
         #    print(i)
@@ -448,6 +454,7 @@ class Vopen():
                 img = self.cv2.cvtColor(img, self.cv2.COLOR_BGR2RGB)
                 if self.fname.startswith("cam_"): 
                     pass
+                    #img = self.rescale_frame2(img, 1200)
                 else:
                     img = self.rescale_frame2(img, 200)
 
@@ -672,10 +679,11 @@ class Vopen():
         #print(yellow)
         if self.fname.startswith("cam_"):
             #if 10: #corner left up
-            pygame.draw.rect(wn,yellow,[self.x,self.y,__xw,__yw])
-            pygame.draw.rect(wn,[25,20,20],[self.x+1,self.y+1,__xw-2,__yw-2])
-            pygame.draw.line(wn,yellow,[self.x+2,self.y+2],[self.x+__xw-4,self.y+__yw-4])
-            pygame.draw.line(wn,yellow,[self.x+__xw-4,self.y+2],[self.x+2,self.y+__yw-4])
+            #pygame.draw.rect(wn,yellow,[self.x,self.y,__xw,__yw])
+            #pygame.draw.rect(wn,[25,20,20],[self.x+1,self.y+1,__xw-2,__yw-2])
+            #pygame.draw.line(wn,yellow,[self.x+2,self.y+2],[self.x+__xw-4,self.y+__yw-4])
+            #pygame.draw.line(wn,yellow,[self.x+__xw-4,self.y+2],[self.x+2,self.y+__yw-4])
+            pass
         elif 1: #corner left up
             p1 = [self.x+2,self.y+2]  
             p2 = [self.x+__xw-4,self.y+__yw-4]
@@ -729,7 +737,7 @@ class Vopen():
             #print(xx,yy)
             #wn.blit(self.im, (int(self.x+xx/2), int(self.y+yy/2)))
             if self.fname.startswith("cam_"):
-                wn.blit(self.im, (int(self.x), int(self.y)))
+                wn.blit(self.im, (int(self.x-xx/2), int(self.y)))
             else:
                 wn.blit(self.im, (int(self.x-xx/2), int(self.y-yy/2)))
 
@@ -1486,8 +1494,8 @@ def generate_grid(mapping=0):
         _dmx = dmx - (_univ)*512 
 
         pos=[x,y]
-        line="{},{},{},{},{},{}\n".format(i+1,_univ,_dmx+1,pos[0],pos[1],ch)
-        line="{},{},{},{},{}\n".format(_univ,_dmx+1,x,y,ch)
+        #line="{},{},{},{},{},{}\n".format(i+1,_univ,_dmx+1,pos[0],pos[1],ch)
+        #line="{},{},{},{},{}\n".format(_univ,_dmx+1,x,y,ch)
         line="{},{},x\n".format(i+1,i+1)
         #print("wcsv:",[line])
         #if PIXEL_MAPPING:

+ 96 - 0
vpu/watchdog_vpu.py

@@ -0,0 +1,96 @@
+#!/usr/bin/python3
+import os
+import time
+
+# Ayrton VPU Offset X 235 Y 253 (Pannel 255)  7,5m-4m ... 9,5m-4m
+
+#os.chdir(""")
+print(os.getcwd())
+
+print("-- init --")
+#cmd = 'screen -XS "watchdog_vpu" quit'
+#print("CMD:",cmd)
+#os.system(cmd)
+cmd = 'screen -XS "vpu01_out" quit'
+print("CMD:",cmd)
+os.system(cmd)
+cmd = 'screen -XS "vpu02_out" quit'
+print("CMD:",cmd)
+os.system(cmd)
+
+print("-- loop --")
+
+def vpu01():
+    # Ayrton VPU Offset Y ___ Y ___ (Ghost 255)
+
+    cmd = 'screen -ls | grep "\.vpu01_out"'
+    print("CMD:",cmd)
+    r = os.popen(cmd)
+    lines = r.readlines()
+
+    if lines:
+        print(" ok")
+        return 0
+
+    cmd = 'screen -XS "vpu01_out" quit'
+    print("CMD:",cmd)
+    os.system(cmd)
+
+    cmd = "screen -m -d -S vpu01_out --"
+    cmd = "screen -m -d -S vpu01_out --"
+    cmd+= " python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py"
+    cmd+= " -m 16,12,5"
+    cmd+= " -X 12 "
+    cmd+= " --pixel-map=_1 "
+    cmd+= " --gobo-ch=11"
+    cmd+= " --countdown=31,51,151,171 --videoplayer=181,201 --title=LIVE"
+
+    print("CMD:",cmd)
+    os.system(cmd)
+    #time.sleep(1)
+    return 1
+
+
+def vpu02():
+    # Ayrton VPU Offset X 235 Y 253 (Pannel 255)  7,5m-4m ... 9,5m-4m
+
+    cmd = 'screen -ls | grep "\.vpu02_out"'
+    print("CMD:",cmd)
+    r = os.popen(cmd)
+    lines = r.readlines()
+
+    if lines:
+        print(" ok")
+        return 0
+
+    cmd = 'screen -XS "vpu02_out" quit'
+    print("CMD:",cmd)
+    os.system(cmd)
+
+    cmd ="screen -m -d -S vpu02_out --"
+    cmd += " python3 /opt/LibreLight/Xdesk/vpu/vpu_live.py"
+    cmd += " -m 16,4,6"
+    cmd += " -X 4"
+    cmd += " --pixel-map=_2"
+    cmd += " --gobo-ch=21"
+    cmd += " --win-pos 430,164"
+    cmd += " --start-univ=4"
+    cmd += " --countdown=71,91,111,131"
+    cmd += " --videoplayer=221,241"
+    cmd += " --title=LIVE"
+    print("CMD:",cmd)
+    os.system(cmd)
+    #time.sleep(1)
+
+    return 1
+
+
+
+while 1:
+    r1=vpu01()
+    r2=vpu02()
+
+    time.sleep(3)
+
+
+