def GeneratePlot(outfile, Filename, xpixel, ypixel, nyanFlag=0, nyanAudio=0): video = imageio.get_reader(Filename, 'ffmpeg') colorArr = [] maxLen = int(len(video)) gradient = np.linspace(0,1,256) gradient = np.vstack((gradient, gradient)) index = range(maxLen) RGB = [[],[],[]] #0 - Red, 1 - Green, 2 - Blue progress = "" if(nyanAudio): progress = NyanBar(audiofile="./NyanCat.mp3") elif(nyanFlag): progress = NyanBar() try: print "Starting Collection" for i in index: try: frame = video.get_data(i) pass except KeyboardInterrupt: print "\nEnding Collection" break tempArr = frame[ypixel,xpixel] #Get the Frame at X=xpixel and Y=ypixel for j in range(3): RGB[j].append(float(tempArr[j])/256.0) #Normalizing the RGB values to 256 to get RGB value less than 1 for Matplotlib cmap colorArr.append([x[i] for x in RGB]) #Get the RGB values of the most recent entry and appent to colorArr if(nyanFlag): progress.update(int(float(i)/float(maxLen) * 100)) #sys.stdout.write("\rFrame %i of %i" % (i, maxLen)) #sys.stdout.flush() if(nyanFlag): progress.finish() #RGB Plots for Rates plt.plot(RGB[0], 'r') plt.plot(RGB[1], 'g') plt.plot(RGB[2], 'b') plt.savefig(AppendTitleToFilename(outfile, "RGB")) plt.clf() #Making Colorbar cmap1 = LinearSegmentedColormap.from_list("cmap", colorArr, N=256, gamma=1.0) #Need normalized RGB to 256 therefore from 0 to 1 gradient = np.linspace(0,1,256) gradient = np.vstack((gradient, gradient)) plt.imshow(gradient, aspect='auto', cmap=cmap1) plt.savefig(outfile) plt.clf() return except KeyboardInterrupt: print "\nEnding Plot"
else: print "The test filename must either contain word *spam* or *ham* indicating its class!" print "The filter won't be tested on `%s` file." % os.path.join( e, d) if show_progress and progress_bar == "nyan": print "Test [%d/%d]" % (ei + 1, len(emails_dir)) progress = NyanBar(tasks=100) tp, tn, fp, fn = 0, 0, 0, 0 evaluation_start_time = time.time() for ii, i in enumerate(emails): if show_progress and progress_bar == "classic": print "[%d/%d] %.2d%% (%s)" % (ei + 1, len(emails_dir), 100. * ii / len(emails), i) elif show_progress and progress_bar == "nyan": progress.update(100. * ii / len(emails)) current_email = execute % os.path.abspath(i) if "spam" in os.path.split(i)[1]: ground_truth = "spam" elif "ham" in os.path.split(i)[1]: ground_truth = "ham" else: sys.exit( "File %s has neither *ham* nor *spam* keyword in its name!" % i) exe = subprocess.Popen(current_email.split(), cwd=path_prefix, stdout=subprocess.PIPE) output, error = exe.communicate()
from nyanbar import NyanBar import time progress = NyanBar(audiofile="NyanCat-original.mp3") for n in range(100): time.sleep(.3) progress.update(n) progress.finish()
# Sampling every x minutes intervals = 5 nMins = nHours * 60 timer = 0 leds = 1 # Initialize the leds with the first one only pfd.leds[0].turn_on() pfd.leds[0].set_high() progress = NyanBar() while timer <= nMins: # Update progress bar progress.update((timer / nMins) * 100) # Light up the transilluminator pfd.relays[0].value = 1 # Set camera values camera.awb_gains = 1, 0.5 camera.brightness = 55 camera.saturation = 30 camera.exposure_compensation = 25 camera.contrast = 50 camera.shutter_speed = 220000 # Let camera stabilize time.sleep(10) # Take the gfp image