Browse Source

fix: MediaCam.draw

micha 1 week ago
parent
commit
9a0e5751c5
1 changed files with 11 additions and 20 deletions
  1. 11 20
      vpu/vpu_live4.py

+ 11 - 20
vpu/vpu_live4.py

@@ -310,11 +310,10 @@ class MediaCam():
     def __init__(self):
         pass
 
-    def draw(self,wn,im,x,y,w,h):
-        xx = int(im.shape[1]/2) 
-        yy = int(im.shape[0]/2)
-
-        wn.blit(im, (int(x-xx), int(y-yy)))  # draw frame
+    def draw(self,wn,im,x,y):
+        w2 = int(im.get_width()/2)
+        h2 = int(im.get_height()/2)
+        wn.blit(im, (int(x-w2), int(y-h2)))  # draw frame
 
     def _open_cam(self,obj):
         # LIVE VIDEO INPUT UVC DEVICE
@@ -491,7 +490,7 @@ class PixelMedia():
 
     def init(self):
         print("---- ---- PixelMedia.init()",[self.fname,self._media_nr])
-        print(MEDIALIST)
+        #print(MEDIALIST)
         self.time = 0
         self.t_delta = 0 
         self.t_last  = time.time()
@@ -753,16 +752,10 @@ class PixelMedia():
         yy = int(yy*self.scale/255)
         return xx,yy
 
-    def draw_video(self,wn,im,x,y,w,h):
-        #rgb = [255,0,0]
-        #rgb = calc_dim(self.dim,rgb)
-        #draw_media_background(wn,x,y,w=w,h=h,rgb=rgb)
-
-        xh=int(w/2) # half
-        yh=int(h/2) # half
-        wn.blit(im, (int(x-xh), int(y-yh))) # draw frame
-
-
+    def draw_video(self,wn,im,x,y):
+        w2 = int(im.get_width()/2)
+        h2 = int(im.get_height()/2)
+        wn.blit(im, (int(x-w2), int(y-h2))) # draw frame
 
     def draw_img(self,wn,img_meta):
         self.img_meta["pos"]   = [self.x,self.y]
@@ -817,11 +810,9 @@ class PixelMedia():
 
         if self.success and wn and im: 
             if self.fname.startswith("cam_"):
-                xx,yy = self.calc_zoom(w,h)
-                #self.cam.draw(wn,im,x,y,w,h)
-                self.cam.draw(wn,im,x,y,xx,yy)
+                self.cam.draw(wn,im,x,y)
             else:
-                self.draw_video(wn,im,x,y,w,h)
+                self.draw_video(wn,im,x,y)
 
         self.change_reset()