def singleSnap(tweet,ti): #Single picture capture on() c = picamera.PiCamera() c.resolution = (1600,900) s(1) c.capture(ti+'.png') c.close() scale.scaleB(ti+'.png') off()
def timeLapse(tweet,ti): fonT = imgF.truetype('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf',60) frequency = 1 duration = 1 #Looking for the requested duration if (u'duration' in tweet): indexD = tweet.index('duration')+9 duration = u'' while tweet[indexD] != u' ': duration = duration+tweet[indexD] indexD = indexD+1 if indexD > len(tweet)-1: break duration = int(duration) #Looking for the frequency if (u'frequency' in tweet): indexF = tweet.index('frequency')+10 frequency = u'' while tweet[indexF] != u' ': # and indexF <len(tweet) ? frequency = frequency+tweet[indexF] indexF = indexF+1 if indexF > len(tweet)-1: break frequency = int(frequency) nImg = int(frequency*duration) on() #Timelapse loop for ix in range(0,nImg): c = picamera.PiCamera() c.resolution = (1600,900) s(1) c.capture(str(ix)+'.png') c.close() s(60/frequency) off() tempIm = img.new('RGB',(800,900)) for k in range(0,nImg): img2open = img.open(str(k)+'.png') imgD.Draw(img2open).text((1530,830),str(k+1),font=fonT,fill=(0,0,0,255)) img2open.save(str(k)+'.png') uploadFlickr(str(k)+'.png','Image '+str(k+1)+' of timelapse initiated on '+ti) image1 = img.open('0.png').resize((800,450)) image2 = img.open(str(nImg-1)+'.png').resize((800,450)) tempIm.paste(image1,(0,0)) tempIm.paste(image2,(0,450)) tempIm.save(ti+'.png')
def focusImg(tweet,ti): if (u'further' in tweet): indexUp = tweet.index('further')+8 nUp = u'' if indexUp < len(tweet): try: while tweet[indexUp] != u' ': nUp = nUp+tweet[indexUp] indexUp = indexUp+1 if indexUp > len(tweet)-1: break except IndexError,TypeError: nUp = 1 if nUp == u'': nUp = 1 else: nUp = int(nUp) up(nUp) on() c = picamera.PiCamera() s(1) c.capture(ti+'.png') c.close() off()
png = ".png" e = mc.events.pollBlockHits() if len(e) != 0: p = e[0].pos # Move the sample stage down if p.x == -34 and p.y == 1 and p.z == 63: mc.events.clearAll() focus.down() # Capture an image from the picamera. if p.x == -34 and p.y == 1 and p.z == 61: # Verify if the preview window is on. if prevOn: c.stop_preview() c.close() prevOn = False focus.off() mc.postToChat("Picture taken") mc.events.clearAll() focus.on() c = cam.PiCamera() c.capture(str(i) + png) c.close() focus.off() i = i + 1 # Open/close the preview window. if p.x == -34 and p.y == 1 and p.z == 59: if prevOn: focus.off() c.stop_preview() c.close() prevOn = False
indexDn = indexDn+1 if indexDn > len(tweet)-1: break except IndexError,TypeError: nDn = 1 if nDn == u'': nDn = 1 else: nDn = int(nDn) down(nDn) c = picamera.PiCamera() s(1) c.capture(ti+'.png') c.close() off() if (u'dofocus' in tweet): fonT = imgF.truetype('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf',30) imgArray = [] indexF = tweet.index('dofocus')+8 nFocus = u'' if indexF < len(tweet): try: while tweet[indexF] != u' ': nFocus = nFocus+tweet[indexF] indexF = indexF+1 if indexF > len(tweet)-1: break