|
|
@@ -164,25 +164,6 @@ except:pass
|
|
|
|
|
|
from tool.video_capture import scan_capture #as scan_capture
|
|
|
|
|
|
-def _cam_cfg_new(fn):
|
|
|
- #fn = HOME+'/LibreLight/video_in.txt'
|
|
|
- txt = [
|
|
|
- "# Example",
|
|
|
- "d0 w640 h480 # PAL",
|
|
|
- "d0 w800 h600 # SVGA",
|
|
|
- "d0 w960 h540 # 540p",
|
|
|
- "d0 w1024 h768 # XGA <---",
|
|
|
- "d0 w1280 h720 # 720p",
|
|
|
- "d0 w1440 h900 # WSXGA+",
|
|
|
- "d0 w1600 h900 # WSXGA - Laptop 16:9",
|
|
|
- "d0 w1920 h1080 # HD 1080p",
|
|
|
- "",
|
|
|
- "# config",
|
|
|
- "d0 w1024 h768 # XGA",
|
|
|
- ]
|
|
|
- f = open(fn ,"w")
|
|
|
- f.write("\n".join(txt))
|
|
|
- f.close()
|
|
|
|
|
|
|
|
|
def VideoMeta():
|
|
|
@@ -288,84 +269,6 @@ def _rotateImage(image, angle):
|
|
|
except Exception as e:
|
|
|
raise(e)
|
|
|
|
|
|
-def _cam_cfg():
|
|
|
- fn = HOME+'/LibreLight/video_in.txt'
|
|
|
- if not os.path.isfile(fn):
|
|
|
- _cam_cfg_new(fn)
|
|
|
- f = open(fn ,"r")
|
|
|
- lines = f.readlines()
|
|
|
- f.close()
|
|
|
- cfg = ""
|
|
|
- for i in lines:
|
|
|
- if i.startswith("d"):
|
|
|
- cfg = i
|
|
|
- cfg = cfg.split()
|
|
|
- capture = scan_capture(name="MiraBox",serial="")
|
|
|
- #capture = scan_capture(name="Integrated",serial="")
|
|
|
- if capture:
|
|
|
- print("capture",capture)
|
|
|
- try:
|
|
|
- cfg.append(capture[0][0])
|
|
|
- except Exception as e:
|
|
|
- cprint("except 2992",e,color="red")
|
|
|
- else:
|
|
|
- cprint("---- ERROR NO VIDEO CAPTURE DEV - FOUND ----",color="red")
|
|
|
- print("_cam_cfg:",len(cfg),[cfg])
|
|
|
-
|
|
|
- return cfg
|
|
|
-
|
|
|
-def _open_cam(obj):
|
|
|
- # LIVE VIDEO INPUT UVC DEVICE
|
|
|
- cfg = _cam_cfg()
|
|
|
- print("III",cfg)
|
|
|
-
|
|
|
- res = "HD"
|
|
|
- #res = "4K"
|
|
|
- #res = ""
|
|
|
-
|
|
|
- if res == "HD":
|
|
|
- # HD
|
|
|
- w = 1920
|
|
|
- h = 1080
|
|
|
- elif res == "4K":
|
|
|
- # 4K
|
|
|
- w = 3840
|
|
|
- h = 2160
|
|
|
- else:
|
|
|
-
|
|
|
- # LOW
|
|
|
- w = 1280
|
|
|
- h = 720
|
|
|
- d = 0 # VIDEO INPUT DEV
|
|
|
-
|
|
|
- for c in cfg:
|
|
|
- try:
|
|
|
- if c.startswith("d"):
|
|
|
- d = int(c[1:])
|
|
|
- if c.startswith("h"):
|
|
|
- h = int(c[1:])
|
|
|
- if c.startswith("w"):
|
|
|
- w = int(c[1:])
|
|
|
- if c.startswith("video"):
|
|
|
- d = int(c[-1])
|
|
|
- except Exception as e:
|
|
|
- cprint("Exception", "cam_cfg 878",e,color="red")
|
|
|
-
|
|
|
- df = "video{}".format(d)
|
|
|
- if obj._stop:
|
|
|
- df += "_stop"
|
|
|
- elif os.path.exists("/dev/{}".format(df)):
|
|
|
- obj.Rcap = cv2.VideoCapture(d)
|
|
|
- obj.Rcap.set(cv2.CAP_PROP_FRAME_WIDTH, w)
|
|
|
- obj.Rcap.set(cv2.CAP_PROP_FRAME_HEIGHT, h)
|
|
|
- else:
|
|
|
- #obj.Rcap = None
|
|
|
- #obj.end = 1
|
|
|
- df += "_error"
|
|
|
-
|
|
|
- if obj.fname.startswith("cam_"):
|
|
|
- obj.fname = "cam_{}".format(df)
|
|
|
-
|
|
|
def calc_dim(dim=1,rgb=[255,255,255]):
|
|
|
rgb[0] = int(rgb[0]*dim/255)
|
|
|
rgb[1] = int(rgb[1]*dim/255)
|
|
|
@@ -398,6 +301,124 @@ def draw_media_background(wn,x,y,w,h,rgb):
|
|
|
pygame.draw.line(wn,rgb ,p3 ,p4) # tr - bl
|
|
|
|
|
|
|
|
|
+
|
|
|
+class MediaImg():
|
|
|
+ def __init__(self):
|
|
|
+ pass
|
|
|
+
|
|
|
+class MediaCam():
|
|
|
+ def __init__(self):
|
|
|
+ pass
|
|
|
+
|
|
|
+ def draw(self,wn,im,x,y,w,h):
|
|
|
+ #if not self.fname.startswith("cam_"):
|
|
|
+ # return
|
|
|
+ xx = w #self.shape_x
|
|
|
+ yy = h #self.shape_y
|
|
|
+
|
|
|
+ xx,yy = self.calc_zoom(xx,yy)
|
|
|
+
|
|
|
+ wn.blit(im, (int(x-xx/2), int(y-yy))) # draw frame
|
|
|
+
|
|
|
+ def _open_cam(self,obj):
|
|
|
+ # LIVE VIDEO INPUT UVC DEVICE
|
|
|
+ cfg = self._cam_cfg()
|
|
|
+ print("III",cfg)
|
|
|
+
|
|
|
+ res = "HD"
|
|
|
+ #res = "4K"
|
|
|
+ #res = ""
|
|
|
+
|
|
|
+ if res == "HD":
|
|
|
+ # HD
|
|
|
+ w = 1920
|
|
|
+ h = 1080
|
|
|
+ elif res == "4K":
|
|
|
+ # 4K
|
|
|
+ w = 3840
|
|
|
+ h = 2160
|
|
|
+ else:
|
|
|
+
|
|
|
+ # LOW
|
|
|
+ w = 1280
|
|
|
+ h = 720
|
|
|
+ d = 0 # VIDEO INPUT DEV
|
|
|
+
|
|
|
+ for c in cfg:
|
|
|
+ try:
|
|
|
+ if c.startswith("d"):
|
|
|
+ d = int(c[1:])
|
|
|
+ if c.startswith("h"):
|
|
|
+ h = int(c[1:])
|
|
|
+ if c.startswith("w"):
|
|
|
+ w = int(c[1:])
|
|
|
+ if c.startswith("video"):
|
|
|
+ d = int(c[-1])
|
|
|
+ except Exception as e:
|
|
|
+ cprint("Exception", "cam_cfg 878",e,color="red")
|
|
|
+
|
|
|
+ df = "video{}".format(d)
|
|
|
+ if obj._stop:
|
|
|
+ df += "_stop"
|
|
|
+ elif os.path.exists("/dev/{}".format(df)):
|
|
|
+ obj.Rcap = cv2.VideoCapture(d)
|
|
|
+ obj.Rcap.set(cv2.CAP_PROP_FRAME_WIDTH, w)
|
|
|
+ obj.Rcap.set(cv2.CAP_PROP_FRAME_HEIGHT, h)
|
|
|
+ else:
|
|
|
+ #obj.Rcap = None
|
|
|
+ #obj.end = 1
|
|
|
+ df += "_error"
|
|
|
+
|
|
|
+ if obj.fname.startswith("cam_"):
|
|
|
+ obj.fname = "cam_{}".format(df)
|
|
|
+
|
|
|
+ def _cam_cfg(self):
|
|
|
+ fn = HOME+'/LibreLight/video_in.txt'
|
|
|
+ if not os.path.isfile(fn):
|
|
|
+ self._cam_cfg_new(fn)
|
|
|
+ f = open(fn ,"r")
|
|
|
+ lines = f.readlines()
|
|
|
+ f.close()
|
|
|
+ cfg = ""
|
|
|
+ for i in lines:
|
|
|
+ if i.startswith("d"):
|
|
|
+ cfg = i
|
|
|
+ cfg = cfg.split()
|
|
|
+ capture = scan_capture(name="MiraBox",serial="")
|
|
|
+ #capture = scan_capture(name="Integrated",serial="")
|
|
|
+ if capture:
|
|
|
+ print("capture",capture)
|
|
|
+ try:
|
|
|
+ cfg.append(capture[0][0])
|
|
|
+ except Exception as e:
|
|
|
+ cprint("except 2992",e,color="red")
|
|
|
+ else:
|
|
|
+ cprint("---- ERROR NO VIDEO CAPTURE DEV - FOUND ----",color="red")
|
|
|
+ print("_cam_cfg:",len(cfg),[cfg])
|
|
|
+
|
|
|
+ return cfg
|
|
|
+
|
|
|
+
|
|
|
+ def _cam_cfg_new(self,fn):
|
|
|
+ #fn = HOME+'/LibreLight/video_in.txt'
|
|
|
+ txt = [
|
|
|
+ "# Example",
|
|
|
+ "d0 w640 h480 # PAL",
|
|
|
+ "d0 w800 h600 # SVGA",
|
|
|
+ "d0 w960 h540 # 540p",
|
|
|
+ "d0 w1024 h768 # XGA <---",
|
|
|
+ "d0 w1280 h720 # 720p",
|
|
|
+ "d0 w1440 h900 # WSXGA+",
|
|
|
+ "d0 w1600 h900 # WSXGA - Laptop 16:9",
|
|
|
+ "d0 w1920 h1080 # HD 1080p",
|
|
|
+ "",
|
|
|
+ "# config",
|
|
|
+ "d0 w1024 h768 # XGA",
|
|
|
+ ]
|
|
|
+ f = open(fn ,"w")
|
|
|
+ f.write("\n".join(txt))
|
|
|
+ f.close()
|
|
|
+
|
|
|
class PixelMedia():
|
|
|
|
|
|
def __init__(self,dmx=None,_id=None):
|
|
|
@@ -413,6 +434,7 @@ class PixelMedia():
|
|
|
except Exception as e:
|
|
|
cprint("Exception set video from MEDIALIST 5543:",e,color="red")
|
|
|
|
|
|
+ self.cam = MediaCam()
|
|
|
self.img_meta = {}
|
|
|
self.restart_t = time.time()
|
|
|
self.fps = 0
|
|
|
@@ -538,7 +560,7 @@ class PixelMedia():
|
|
|
return # STOP
|
|
|
|
|
|
if self.fname.startswith("cam_"):
|
|
|
- _open_cam(obj=self)
|
|
|
+ self.cam._open_cam(obj=self)
|
|
|
self.img_meta = {}
|
|
|
else:
|
|
|
self.Rcap = cv2.VideoCapture(self.fpath+self.fname, cv2.CAP_FFMPEG)
|
|
|
@@ -745,15 +767,6 @@ class PixelMedia():
|
|
|
wn.blit(im, (int(x-xh), int(y-yh))) # draw frame
|
|
|
|
|
|
|
|
|
- def draw_cam(self,wn,im,x,y,w,h):
|
|
|
- if not self.fname.startswith("cam_"):
|
|
|
- return
|
|
|
- xx = w #self.shape_x
|
|
|
- yy = h #self.shape_y
|
|
|
-
|
|
|
- xx,yy = self.calc_zoom(xx,yy)
|
|
|
-
|
|
|
- wn.blit(im, (int(x-xx/2), int(y-yy))) # draw frame
|
|
|
|
|
|
def draw_img(self,wn,img_meta):
|
|
|
self.img_meta["pos"] = [self.x,self.y]
|
|
|
@@ -808,7 +821,7 @@ class PixelMedia():
|
|
|
|
|
|
if self.success and wn and im:
|
|
|
if self.fname.startswith("cam_"):
|
|
|
- self.draw_cam(wn,im,x,y,w,h)
|
|
|
+ self.cam.draw(wn,im,x,y,w,h)
|
|
|
else:
|
|
|
self.draw_video(wn,im,x,y,w,h)
|
|
|
|
|
|
@@ -2341,9 +2354,6 @@ def draw_all_video(VIDEO):
|
|
|
k = "PAN"
|
|
|
cpan_max = block[0] *(_x) #+block[0]
|
|
|
if k in count:
|
|
|
- #if 0:#video1.fname.startswith("cam_"):
|
|
|
- # cpan = int(count[k]) #/ 255*cpan_max
|
|
|
- #else:
|
|
|
cpan = int(count[k]) / 255*cpan_max
|
|
|
cpan = int(cpan)
|
|
|
|