Best Python code snippet using avocado_python
main.py
Source:main.py
...25 break26 f2 = Image.open(frames[next_frame])27 if f2.mode != "RGB":28 f2 = f2.convert("RGB") 29 f1_levels = get_resolutions(f1, 3)30 f2_levels = get_resolutions(f2, 3)31 f1_levels.append(f1)32 f2_levels.append(f2)33 width, height = f1.size34 # Temporal difference between frames35 dt = diff(f1, f2)36 # Apply sobel and harris to get the best points to track37 start = time()38 dx, dy = sobel(f1, 3)39 print "Sobel: %.2f segundos" % (time() - start)40 start = time()41 corners = harris(dx, dy, width, height, 3)42 print "Harris: %.2f segundos" % (time() - start)43 # Obtain optical flow using pyramidal implemenatation of lukas kanade feature tracker44 start = time()45 optical_flow = lukas_kanade_pyramidal(corners, f1_levels, f2_levels, dx, dy, dt, 3)46 for point, velocity_vector in optical_flow:47 f1 = draw_velocity_vector(f1, point, velocity_vector)48 print "Lukas Kanade Pyramidal: %.2f segundos" % (time() - start)49 f1_name = os.path.basename(os.path.splitext(frames[i])[0])50 f2_name = os.path.basename(os.path.splitext(frames[next_frame])[0])51 f1.save(os.path.join(sys.argv[2], "flow_%s_to_%s.png") % (f1_name, f2_name), "png")52'''if __name__ == "__main__":53 pipe = communicate_with_ffmpeg_by_pipe(sys.argv[1], 'rgb24')54 f1 = extract_frame_from_video_buffer(pipe.stdout, 1920, 1080, 3)55 if f1 is not None:56 f1 = Image.fromarray(f1)57 i = 158 while f1 is not None: 59 f2 = extract_frame_from_video_buffer(pipe.stdout, 1920, 1080, 3)60 if f2 is None:61 break62 f2 = Image.fromarray(f2)63 f1_levels = get_resolutions(f1, 3)64 f2_levels = get_resolutions(f2, 3)65 f1_levels.append(f1)66 f2_levels.append(f2)67 width, height = f1.size68 # Temporal difference between frames69 dt = diff(f1, f2)70 # Apply sobel and harris to get the best points to track71 start = time()72 dx, dy = sobel(f1, 3)73 print "Sobel: %.2f segundos" % (time() - start)74 start = time()75 corners = harris(dx, dy, width, height, 3)76 print "Harris: %.2f segundos" % (time() - start)77 # Obtain optical flow using pyramidal implemenatation of lukas kanade feature tracker78 start = time()...
resolution_analysis.py
Source:resolution_analysis.py
...23 plt.savefig(figs_path + fig_name, dpi=900)24 # plt.show()25 plt.close()26 return 027def get_resolutions(all_res_df):28 print "Getting all startup values."29 resolutions = all_res_df["resolution_mc"]30 plot_CDF("all", resolutions)31 services = ["amazon", "netflix", "twitch", "youtube"]32 for service in services:33 print "Getting " + service + " resolution values."34 tmp_df = all_res_df[all_res_df['session_id'].str.contains(service)]35 service_resolutions = tmp_df["resolution_mc"]36 plot_CDF(service, service_resolutions)37 return 038def main():39 print "Script Start"40 print datetime.datetime.now()41 parser = argparse.ArgumentParser()42 parser.add_argument('-f', '--file', type=str, required=True, help="Pickle File with all resolutions (without 1st min) for all deployments.")43 args = vars(parser.parse_args())44 resolutions_pickle = args["file"]45 all_res_df = pd.read_pickle(resolutions_pickle)46 get_resolutions(all_res_df)47 print "Script End"48 print datetime.datetime.now()49 return 050if __name__ == '__main__':...
download_youtube_video.py
Source:download_youtube_video.py
...5 print(f"Saved to {path}")6def down_progress(chunk,file_handler,remaining_bytes):7 # Segment of media file binary data, not yet written to disk.8 print(chunk,file_handler,remaining_bytes)9def get_resolutions(obj):10 return [i.resolution for i in obj]11def download_video(yt):12 print(yt.title)13 available_streams = yt.streams.filter(file_extension='mp4',progressive=True)14 # available_streams = yt.streams.filter(file_extension='mp4',adaptive=True)15 print(f"Available Quality - {get_resolutions(available_streams)}")16 vid_quality = input("Video Quality: ")17 desired_stream = available_streams.get_by_resolution(vid_quality)18 file_size = round(desired_stream.filesize_approx/1048576,2)19 print(f"File Size: {file_size}MB")20 desired_stream.download(output_path="downloads")21link = input("Enter the link: ")22yt = YouTube(link,on_complete_callback=completed)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!