def capture_sequence(self, num, delay, ): for i in range(num): dt = datetime.datetime.now() filename_prefix = dt.strftime("%Y-%m-%d_%H_%M_%S") filename_suffix = "%03d" % i self.capture(filename_prefix = filename_prefix, filename_suffix = filename_suffix, ) remotepath='pvos.org/ircam/latest.png' baseDir="./imgs" server='habeo.net' user='******' password='******' print "Sending ..." sender.sendMostRecentFile(baseDir, remotepath,server,user,password) """ files=os.listdir(baseDir) #print files latestFile=sender.getRecentfile(baseDir,files) #print latestFile ssh = sender.createSSHClient(server=server, user=user, password=password) #print ssh print "Sending ..." scp1 = scp.SCPClient(ssh.get_transport()) scp1.put(latestFile,'pvos.org/ircam/latest.png') """ if not (i == num-1): time.sleep(delay)
def capture(self, filename_prefix = None, filename_suffix = "", ): if filename_prefix is None: dt = datetime.datetime.now() filename_prefix = dt.strftime("%Y-%m-%d_%H_%M_%S") #build the common capture command options base_cmd = ["fswebcam"] base_cmd.append("-r %s" % self.resolution) base_cmd.append("--png %d" % self.png_compression) base_cmd.append("-D %d" % self.pre_capture_delay) base_cmd.append("-S %d" % self.frame_skip) #update prefix to include the output path filename_prefix = os.sep.join((self.output_path,filename_prefix)) #construct the filepaths fn0 = "%s_IRimg%s.png" % (filename_prefix, filename_suffix) fn1 = "%s_VISimg%s.png" % (filename_prefix, filename_suffix) #construct the full capture commands cmd0 = base_cmd[:] #copy list cmd0.append("--save %s" % fn0) cmd0.append("-d %s" % self._cam0) cmd0 = " ".join(cmd0) cmd1 = base_cmd[:] #copy list cmd1.append("--save %s" % fn1) cmd1.append("-d %s" % self._cam1) cmd1 = " ".join(cmd1) #run the commands asynchronously if self.verbose: print "running following commands asynchronously:" print cmd0 print cmd1 print '-'*40 #because of weird pool timing error on R-Pi, skip this, do old way: #self._pool.map(run_cmd,[cmd0.split(), cmd1.split()]) os.system(cmd0) os.system(cmd1) try: sender.sendMostRecentFile(baseDir,remotepath,server,user,password) except: pass print "now waiting ..."