def TakeSnapshot(self, e, args): #print('CAPTURE')#DEBUG if self.camset == 1: self.framlog += 1 #print(self.camhero)#DEBUG vidcap = vlc.libvlc_video_take_snapshot( self.player, 0, os.path.join(self.imgdir, str(self.framlog).zfill(3) + '.png'), 0, 0) self.cur.execute('INSERT INTO Timeline VALUES(Null,?,?)', (str(self.framlog).zfill(3) + '.png', 0)) # add graphically to timeline img = self.MakeThumbnail( os.path.join(self.imgdir, str(self.framlog).zfill(3) + '.png'), self.thumbsize) self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY, wx.BitmapFromImage(img), name=str(self.framlog).zfill(3) + '.png') self.imageCtrl.SetBitmap(wx.BitmapFromImage(img)) self.imageCtrl.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick) self.imageCtrl.Bind(wx.EVT_LEFT_UP, self.OnLeftRelease) #print(self.imageCtrl.GetId())#DEBUG self.hbox2.Add(self.imageCtrl, 0, wx.ALL, 5) # scroll right 100% to get close to new frame self.panel3.Scroll(self.thumbsize, 0) self.Layout() # draw new frame self.hbox2.Layout() self.panel3.Refresh() # scroll WAY right again to show frame self.panel3.Scroll(200, 0) # send the shot to onion skin img = os.path.join(self.imgdir, str(self.framlog).zfill(3) + '.png') self.OnionSkin(img) #print(self.framlog) else: dlg = wx.MessageDialog(self, 'Please select your camera first.', '', wx.OK | wx.ICON_ERROR) val = dlg.ShowModal() if val == wx.ID_OK: dlg.Destroy() if val == wx.ID_CANCEL: dlg.Destroy() self.player.play() self.brec.SetBitmapLabel(self.brecicon)
def TakeSnapshot(self,e,args): #print('CAPTURE')#DEBUG if self.camset == 1: self.framlog += 1 #print(self.camhero)#DEBUG vidcap = vlc.libvlc_video_take_snapshot(self.player, 0, os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'), 0,0) self.cur.execute('INSERT INTO Timeline VALUES(Null,?,?)', (str(self.framlog).zfill(3)+'.png',0)) # add graphically to timeline img = self.MakeThumbnail(os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'), self.thumbsize) self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY, wx.BitmapFromImage(img),name=str(self.framlog).zfill(3)+'.png') self.imageCtrl.SetBitmap(wx.BitmapFromImage(img)) self.imageCtrl.Bind( wx.EVT_LEFT_DOWN, self.OnLeftClick ) self.imageCtrl.Bind( wx.EVT_LEFT_UP, self.OnLeftRelease ) #print(self.imageCtrl.GetId())#DEBUG self.hbox2.Add( self.imageCtrl, 0, wx.ALL, 5 ) # scroll right 100% to get close to new frame self.panel3.Scroll(self.thumbsize,0) self.Layout() # draw new frame self.hbox2.Layout() self.panel3.Refresh() # scroll WAY right again to show frame self.panel3.Scroll(200,0) # send the shot to onion skin img = os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png') self.OnionSkin(img) #print(self.framlog) else: dlg = wx.MessageDialog(self, 'Please select your camera first.','',wx.OK | wx.ICON_ERROR) val = dlg.ShowModal() if val == wx.ID_OK: dlg.Destroy() if val == wx.ID_CANCEL: dlg.Destroy() self.player.play() self.brec.SetBitmapLabel(self.brecicon)
image_count = len(press_event.objects.all()) os.chdir(os.getcwd() + '/static/images/users') #Main loop which handles serial information while True: serialString=str(ser.readline()) serialString=serialString.strip("b'") serialString=serialString.strip("\\r\\n") serialString=serialString.split(',') event_type = serialString[0] if(event_type == "pressed"): vlc.libvlc_video_take_snapshot(player, 0, os.getcwdb(), 0, 0) #Cheeky hack to get a list of images, and take the name of the one which has just been taken image_list = os.listdir() image_list.remove('defaults') image_name = image_list[image_count] image_count+=1 #Calculate height from temp and humidity using func time_now=timezone.now() duration=float(serialString[1]) #looking at serial info humid=float(serialString[2]) temper=float(serialString[3])
def TakeSnapshot(self): logging.exception('CAPTURE') if self.camset == 1: lsdir = os.listdir(self.imgdir) if not lsdir: print("ENMPTY EMPTY EMPTY EMPTY") self.latestfram = 0 else: print(" G IAL JAZ FRANM") self.latestfram = int(str(sorted(lsdir)[-1]).split('.')[0]) self.latestfram += 1 print("plus one === ", self.latestfram) iname = str(self.latestfram).zfill(3) + '.png' print("iname ----> ", iname) vidcap = vlc.libvlc_video_take_snapshot( self.stream, 0, os.path.join(self.imgdir, iname), 0, 0) # scale for thumbnail inmg = os.path.join(self.imgdir, iname) img = Magick.Image(str(inmg)) otmg = os.path.join(self.thumbdir, iname) geometry = img.size() w, h = geometry.width(), geometry.height() new_width = self.thumbsize factor = new_width / float(w) new_height = int(h * factor) img.resize("{}x{}".format(new_width, new_height)) img.write(str(otmg)) # add graphically to timeline # TODO add thumb to timeline but BIG image to viewport img = self.MakeThumbnail(otmg, self.thumbsize) self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY, wx.BitmapFromImage(img), name=iname) self.imageCtrl.SetBitmap(wx.BitmapFromImage(img)) self.imageCtrl.Bind(wx.EVT_LEFT_DOWN, self.OnLeftClick) self.imageCtrl.Bind(wx.EVT_LEFT_UP, self.OnLeftRelease) logging.exception(self.imageCtrl.GetId()) self.hbox2.Add(self.imageCtrl, 0, wx.ALL, 5) # scroll right 100% to get close to new frame self.panel3.Scroll(self.thumbsize, 0) self.Layout() # draw new frame self.hbox2.Layout() self.panel3.Refresh() # scroll WAY right again to show frame self.panel3.Scroll(200, 0) # send the shot to onion skin img = os.path.join(self.imgdir, iname) self.OnionSkin(img) else: self.camhero = 0 ''' dlg = wx.MessageDialog(self, 'Please select your camera first.','',wx.OK | wx.ICON_ERROR) val = dlg.ShowModal() if val == wx.ID_OK: dlg.Destroy() if val == wx.ID_CANCEL: dlg.Destroy() ''' self.stream.play() self.brec.SetBitmapLabel(self.brecicon)