How to use frames method in Puppeteer

Best JavaScript code snippet using puppeteer

TestVSCode_stackTrace.py

Source:TestVSCode_stackTrace.py Github

copy

Full Screen

1"""2Test lldb-vscode setBreakpoints request3"""4from __future__ import print_function5import unittest26import vscode7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10import lldbvscode_testcase11import os12class TestVSCode_stackTrace(lldbvscode_testcase.VSCodeTestCaseBase):13 mydir = TestBase.compute_mydir(__file__)14 name_key_path = ['name']15 source_key_path = ['source', 'path']16 line_key_path = ['line']17 def verify_stackFrames(self, start_idx, stackFrames):18 frame_idx = start_idx19 for stackFrame in stackFrames:20 # Don't care about frame above main21 if frame_idx > 20:22 return23 self.verify_stackFrame(frame_idx, stackFrame)24 frame_idx += 125 def verify_stackFrame(self, frame_idx, stackFrame):26 frame_name = self.get_dict_value(stackFrame, self.name_key_path)27 frame_source = self.get_dict_value(stackFrame, self.source_key_path)28 frame_line = self.get_dict_value(stackFrame, self.line_key_path)29 if frame_idx == 0:30 expected_line = self.recurse_end31 expected_name = 'recurse'32 elif frame_idx < 20:33 expected_line = self.recurse_call34 expected_name = 'recurse'35 else:36 expected_line = self.recurse_invocation37 expected_name = 'main'38 self.assertTrue(frame_name == expected_name,39 'frame #%i name "%s" == "%s"' % (40 frame_idx, frame_name, expected_name))41 self.assertTrue(frame_source == self.source_path,42 'frame #%i source "%s" == "%s"' % (43 frame_idx, frame_source, self.source_path))44 self.assertTrue(frame_line == expected_line,45 'frame #%i line %i == %i' % (frame_idx, frame_line,46 expected_line))47 @skipIfWindows48 @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots49 @no_debug_info_test50 def test_stackTrace(self):51 '''52 Tests the 'stackTrace' packet and all its variants.53 '''54 program = self.getBuildArtifact("a.out")55 self.build_and_launch(program)56 source = 'main.c'57 self.source_path = os.path.join(os.getcwd(), source)58 self.recurse_end = line_number(source, 'recurse end')59 self.recurse_call = line_number(source, 'recurse call')60 self.recurse_invocation = line_number(source, 'recurse invocation')61 lines = [self.recurse_end]62 # Set breakoint at a point of deepest recuusion63 breakpoint_ids = self.set_source_breakpoints(source, lines)64 self.assertTrue(len(breakpoint_ids) == len(lines),65 "expect correct number of breakpoints")66 self.continue_to_breakpoints(breakpoint_ids)67 startFrame = 068 # Verify we get all stack frames with no arguments69 stackFrames = self.get_stackFrames()70 frameCount = len(stackFrames)71 self.assertTrue(frameCount >= 20,72 'verify we get at least 20 frames for all frames')73 self.verify_stackFrames(startFrame, stackFrames)74 # Verify all stack frames by specifying startFrame = 0 and levels not75 # specified76 stackFrames = self.get_stackFrames(startFrame=startFrame)77 self.assertTrue(frameCount == len(stackFrames),78 ('verify same number of frames with startFrame=%i') % (79 startFrame))80 self.verify_stackFrames(startFrame, stackFrames)81 # Verify all stack frames by specifying startFrame = 0 and levels = 082 levels = 083 stackFrames = self.get_stackFrames(startFrame=startFrame,84 levels=levels)85 self.assertTrue(frameCount == len(stackFrames),86 ('verify same number of frames with startFrame=%i and'87 ' levels=%i') % (startFrame, levels))88 self.verify_stackFrames(startFrame, stackFrames)89 # Get only the first stack frame by sepcifying startFrame = 0 and90 # levels = 191 levels = 192 stackFrames = self.get_stackFrames(startFrame=startFrame,93 levels=levels)94 self.assertTrue(levels == len(stackFrames),95 ('verify one frame with startFrame=%i and'96 ' levels=%i') % (startFrame, levels))97 self.verify_stackFrames(startFrame, stackFrames)98 # Get only the first 3 stack frames by sepcifying startFrame = 0 and99 # levels = 3100 levels = 3101 stackFrames = self.get_stackFrames(startFrame=startFrame,102 levels=levels)103 self.assertTrue(levels == len(stackFrames),104 ('verify %i frames with startFrame=%i and'105 ' levels=%i') % (levels, startFrame, levels))106 self.verify_stackFrames(startFrame, stackFrames)107 # Get only the first 15 stack frames by sepcifying startFrame = 5 and108 # levels = 16109 startFrame = 5110 levels = 16111 stackFrames = self.get_stackFrames(startFrame=startFrame,112 levels=levels)113 self.assertTrue(levels == len(stackFrames),114 ('verify %i frames with startFrame=%i and'115 ' levels=%i') % (levels, startFrame, levels))116 self.verify_stackFrames(startFrame, stackFrames)117 # Verify we cap things correctly when we ask for too many frames118 startFrame = 5119 levels = 1000120 stackFrames = self.get_stackFrames(startFrame=startFrame,121 levels=levels)122 self.assertTrue(len(stackFrames) == frameCount - startFrame,123 ('verify less than 1000 frames with startFrame=%i and'124 ' levels=%i') % (startFrame, levels))125 self.verify_stackFrames(startFrame, stackFrames)126 # Verify level=0 works with non-zerp start frame127 startFrame = 5128 levels = 0129 stackFrames = self.get_stackFrames(startFrame=startFrame,130 levels=levels)131 self.assertTrue(len(stackFrames) == frameCount - startFrame,132 ('verify less than 1000 frames with startFrame=%i and'133 ' levels=%i') % (startFrame, levels))134 self.verify_stackFrames(startFrame, stackFrames)135 # Verify we get not frames when startFrame is too high136 startFrame = 1000137 levels = 1138 stackFrames = self.get_stackFrames(startFrame=startFrame,139 levels=levels)140 self.assertTrue(0 == len(stackFrames),...

Full Screen

Full Screen

get_raw_skes_data.py

Source:get_raw_skes_data.py Github

copy

Full Screen

1# Copyright (c) Microsoft Corporation. All rights reserved.2# Licensed under the MIT License.3import os.path as osp4import os5import numpy as np6import pickle7import logging8import gc910def get_raw_bodies_data(skes_path, ske_name, frames_drop_skes, frames_drop_logger):11 """12 Get raw bodies data from a skeleton sequence.1314 Each body's data is a dict that contains the following keys:15 - joints: raw 3D joints positions. Shape: (num_frames x 25, 3)16 - colors: raw 2D color locations. Shape: (num_frames, 25, 2)17 - interval: a list which stores the frame indices of this body.18 - motion: motion amount (only for the sequence with 2 or more bodyIDs).1920 Return:21 a dict for a skeleton sequence with 3 key-value pairs:22 - name: the skeleton filename.23 - data: a dict which stores raw data of each body.24 - num_frames: the number of valid frames.25 """26 ske_file = osp.join(skes_path, ske_name + '.skeleton')27 assert osp.exists(ske_file), 'Error: Skeleton file %s not found' % ske_file28 # Read all data from .skeleton file into a list (in string format)29 # print('Reading data from %s' % ske_file[-29:])30 with open(ske_file, 'r') as fr:31 str_data = fr.readlines()3233 num_frames = int(str_data[0].strip('\r\n'))34 frames_drop = []35 bodies_data = dict()36 valid_frames = -1 # 0-based index37 current_line = 13839 for f in range(num_frames):40 num_bodies = int(str_data[current_line].strip('\r\n'))41 current_line += 14243 if num_bodies == 0: # no data in this frame, drop it44 frames_drop.append(f) # 0-based index45 continue4647 valid_frames += 148 joints = np.zeros((num_bodies, 25, 3), dtype=np.float32)49 colors = np.zeros((num_bodies, 25, 2), dtype=np.float32)5051 for b in range(num_bodies):52 bodyID = str_data[current_line].strip('\r\n').split()[0]53 current_line += 154 num_joints = int(str_data[current_line].strip('\r\n')) # 25 joints55 current_line += 15657 for j in range(num_joints):58 temp_str = str_data[current_line].strip('\r\n').split()59 joints[b, j, :] = np.array(temp_str[:3], dtype=np.float32)60 colors[b, j, :] = np.array(temp_str[5:7], dtype=np.float32)61 current_line += 16263 if bodyID not in bodies_data: # Add a new body's data64 body_data = dict()65 body_data['joints'] = joints[b] # ndarray: (25, 3)66 body_data['colors'] = colors[b, np.newaxis] # ndarray: (1, 25, 2)67 body_data['interval'] = [valid_frames] # the index of the first frame68 else: # Update an already existed body's data69 body_data = bodies_data[bodyID]70 # Stack each body's data of each frame along the frame order71 body_data['joints'] = np.vstack((body_data['joints'], joints[b]))72 body_data['colors'] = np.vstack((body_data['colors'], colors[b, np.newaxis]))73 pre_frame_idx = body_data['interval'][-1]74 body_data['interval'].append(pre_frame_idx + 1) # add a new frame index7576 bodies_data[bodyID] = body_data # Update bodies_data7778 num_frames_drop = len(frames_drop)79 assert num_frames_drop < num_frames, \80 'Error: All frames data (%d) of %s is missing or lost' % (num_frames, ske_name)81 if num_frames_drop > 0:82 frames_drop_skes[ske_name] = np.array(frames_drop, dtype=np.int)83 frames_drop_logger.info('{}: {} frames missed: {}\n'.format(ske_name, num_frames_drop,84 frames_drop))8586 # Calculate motion (only for the sequence with 2 or more bodyIDs)87 if len(bodies_data) > 1:88 for body_data in bodies_data.values():89 body_data['motion'] = np.sum(np.var(body_data['joints'], axis=0))9091 return {'name': ske_name, 'data': bodies_data, 'num_frames': num_frames - num_frames_drop}929394def get_raw_skes_data():95 skes_name = np.loadtxt(skes_name_file, dtype=str)9697 num_files = skes_name.size98 print('Found %d available skeleton files.' % num_files) # 56578 for rgbd-6099100 raw_skes_data = []101 frames_cnt = np.zeros(num_files, dtype=np.int)102103 for (idx, ske_name) in enumerate(skes_name):104 ##############################################105 gc.collect()106 if idx == 0:107 skes_path = '/content/skeleton1/nturgb+d_skeletons/'108 if idx == 56578:109 skes_path = '/content/skeleton2/'110 ##############################################111 bodies_data = get_raw_bodies_data(skes_path, ske_name, frames_drop_skes, frames_drop_logger)112 raw_skes_data.append(bodies_data)113 frames_cnt[idx] = bodies_data['num_frames']114 if (idx + 1) % 1000 == 0:115 print('Processed: %.2f%% (%d / %d)' % \116 (100.0 * (idx + 1) / num_files, idx + 1, num_files))117118 with open(save_data_pkl, 'wb') as fw:119 pickle.dump(raw_skes_data, fw, pickle.HIGHEST_PROTOCOL)120 np.savetxt(osp.join(save_path, 'raw_data', 'frames_cnt.txt'), frames_cnt, fmt='%d')121122 print('Saved raw bodies data into %s' % save_data_pkl)123 print('Total frames: %d' % np.sum(frames_cnt))124125 with open(frames_drop_pkl, 'wb') as fw:126 pickle.dump(frames_drop_skes, fw, pickle.HIGHEST_PROTOCOL)127128if __name__ == '__main__':129 save_path = './'130131 stat_path = osp.join(save_path, 'statistics')132 if not osp.exists('./raw_data'):133 os.makedirs('./raw_data')134135 skes_name_file = osp.join(stat_path, 'skes_available_name.txt')136 save_data_pkl = osp.join(save_path, 'raw_data', 'raw_skes_data.pkl')137 frames_drop_pkl = osp.join(save_path, 'raw_data', 'frames_drop_skes.pkl')138139 frames_drop_logger = logging.getLogger('frames_drop')140 frames_drop_logger.setLevel(logging.INFO)141 frames_drop_logger.addHandler(logging.FileHandler(osp.join(save_path, 'raw_data', 'frames_drop.log')))142 frames_drop_skes = dict()143144 get_raw_skes_data()145146 with open(frames_drop_pkl, 'wb') as fw: ...

Full Screen

Full Screen

pydevd_custom_frames.py

Source:pydevd_custom_frames.py Github

copy

Full Screen

1from _pydevd_bundle.pydevd_constants import get_thread_id, Null2from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame3from _pydev_imps._pydev_saved_modules import thread, threading4import sys5DEBUG = False6#=======================================================================================================================7# CustomFramesContainer8#=======================================================================================================================9class CustomFramesContainer:10 # Actual Values initialized later on.11 custom_frames_lock = None #: :type custom_frames_lock: threading.Lock12 custom_frames = None13 _next_frame_id = None14 _py_db_command_thread_event = None15def custom_frames_container_init(): #Note: no staticmethod on jython 2.1 (so, use free-function)16 CustomFramesContainer.custom_frames_lock = thread.allocate_lock()17 # custom_frames can only be accessed if properly locked with custom_frames_lock!18 # Key is a string identifying the frame (as well as the thread it belongs to).19 # Value is a CustomFrame.20 #21 CustomFramesContainer.custom_frames = {}22 # Only to be used in this module23 CustomFramesContainer._next_frame_id = 024 # This is the event we must set to release an internal process events. It's later set by the actual debugger25 # when we do create the debugger.26 CustomFramesContainer._py_db_command_thread_event = Null()27#Initialize it the first time (it may be reinitialized later on when dealing with a fork).28custom_frames_container_init()29#=======================================================================================================================30# CustomFrame31#=======================================================================================================================32class CustomFrame:33 def __init__(self, name, frame, thread_id):34 # 0 = string with the representation of that frame35 self.name = name36 # 1 = the frame to show37 self.frame = frame38 # 2 = an integer identifying the last time the frame was changed.39 self.mod_time = 040 # 3 = the thread id of the given frame41 self.thread_id = thread_id42def add_custom_frame(frame, name, thread_id):43 CustomFramesContainer.custom_frames_lock.acquire()44 try:45 curr_thread_id = get_thread_id(threading.currentThread())46 next_id = CustomFramesContainer._next_frame_id = CustomFramesContainer._next_frame_id + 147 # Note: the frame id kept contains an id and thread information on the thread where the frame was added48 # so that later on we can check if the frame is from the current thread by doing frame_id.endswith('|'+thread_id).49 frame_id = '__frame__:%s|%s' % (next_id, curr_thread_id)50 if DEBUG:51 sys.stderr.write('add_custom_frame: %s (%s) %s %s\n' % (52 frame_id, get_abs_path_real_path_and_base_from_frame(frame)[-1], frame.f_lineno, frame.f_code.co_name))53 CustomFramesContainer.custom_frames[frame_id] = CustomFrame(name, frame, thread_id)54 CustomFramesContainer._py_db_command_thread_event.set()55 return frame_id56 finally:57 CustomFramesContainer.custom_frames_lock.release()58addCustomFrame = add_custom_frame # Backward compatibility59def update_custom_frame(frame_id, frame, thread_id, name=None):60 CustomFramesContainer.custom_frames_lock.acquire()61 try:62 if DEBUG:63 sys.stderr.write('update_custom_frame: %s\n' % frame_id)64 try:65 old = CustomFramesContainer.custom_frames[frame_id]66 if name is not None:67 old.name = name68 old.mod_time += 169 old.thread_id = thread_id70 except:71 sys.stderr.write('Unable to get frame to replace: %s\n' % (frame_id,))72 import traceback;traceback.print_exc()73 CustomFramesContainer._py_db_command_thread_event.set()74 finally:75 CustomFramesContainer.custom_frames_lock.release()76def get_custom_frame(thread_id, frame_id):77 '''78 :param thread_id: This should actually be the frame_id which is returned by add_custom_frame.79 :param frame_id: This is the actual id() of the frame80 '''81 CustomFramesContainer.custom_frames_lock.acquire()82 try:83 frame_id = int(frame_id)84 f = CustomFramesContainer.custom_frames[thread_id].frame85 while f is not None:86 if id(f) == frame_id:87 return f88 f = f.f_back89 finally:90 f = None91 CustomFramesContainer.custom_frames_lock.release()92def remove_custom_frame(frame_id):93 CustomFramesContainer.custom_frames_lock.acquire()94 try:95 if DEBUG:96 sys.stderr.write('remove_custom_frame: %s\n' % frame_id)97 CustomFramesContainer.custom_frames.pop(frame_id, None)98 CustomFramesContainer._py_db_command_thread_event.set()99 finally:100 CustomFramesContainer.custom_frames_lock.release()...

Full Screen

Full Screen

calculateExtractiveSummaryAccuracy.py

Source:calculateExtractiveSummaryAccuracy.py Github

copy

Full Screen

1import sys2import os3import csv4startFrames = []5endFrames = []6writer = 07FL =["FL"]8DM = ["DM"]9FB1 = ["FB1"]10FB2 = ["FB2"]11FB3 = ["FB3"]12def runAlgo(folder, experiment):13 print folder14 print experiment15 path = os.path.join(folder, experiment)16 path = os.path.join(path, "keyFrames")17 imageFrames = []18 imageExtension = ".jpg"19 for image in os.listdir(path):20 if image.endswith(imageExtension):21 image = image[:-len(imageExtension)]22 imageFrames.append(int(image))23 imageFrames.sort()24 print "Keyframes:"25 print "\t" + str(imageFrames)26 shotIndex = 027 truePositive = 028 trueNegative = 029 falsePositive = 030 falseNegative = 031 shotScore = 032 for keyframe in imageFrames:33 for i in range(0, len(startFrames)-1):34 if keyframe >= startFrames[i] and keyframe <= startFrames[i+1]:35 shotIndex = i36 break37 # print "Keyframe " + str(keyframe)38 # print "Shot index " + str(shotIndex)39 # print "Start frame " + str(startFrames[shotIndex])40 # print "End frame " + str(endFrames[shotIndex])41 if keyframe >= startFrames[shotIndex] and keyframe <= endFrames[shotIndex]:42 truePositive = truePositive + 143 print "Adding " + str(keyframe)44 else:45 falsePositive = falsePositive + 146 for i in range(0, len(startFrames)):47 shotList = list(range(startFrames[i],endFrames[i]))48 # print "Start: " + str(startFrames[i])49 # print "End: " + str(endFrames[i])50 # print "ShotList " + str(shotList)51 exclusionList = set(shotList) - set(imageFrames)52 print "Exclusion " + str(exclusionList)53 falseNegative = falseNegative + len(exclusionList)54 commonSet = list(set(shotList).intersection(imageFrames))55 print "Common " + str(commonSet)56 if len(commonSet) > 0:57 shotScore = shotScore + 158 # break59 print "True Positive " + str(truePositive)60 print "False Positive " + str(falsePositive)61 print "False Negative " + str(falseNegative)62 shotScoreScaled = float(shotScore)/len(startFrames)63 print "Shot Score " + str(shotScoreScaled)64 if "FL" in experiment:65 FL.append("="+str(shotScore)+"/"+str(len(startFrames)))66 elif "DM" in experiment:67 DM.append("="+str(shotScore)+"/"+str(len(startFrames)))68 elif "FB1" in experiment:69 FB1.append("="+str(shotScore)+"/"+str(len(startFrames)))70 elif "FB2" in experiment:71 FB2.append("="+str(shotScore)+"/"+str(len(startFrames)))72 elif "FB3" in experiment:73 FB3.append("="+str(shotScore)+"/"+str(len(startFrames)))74if __name__ == "__main__":75 if len(sys.argv) < 4:76 print "\n\nUSAGE: calculateExtractiveSummaryAccuracy.py <shot/video/location> <keyframes/folder> <output/csv/file/path>\n\n"77 sys.exit()78 shotFolder = sys.argv[1]79 resultsFolder = sys.argv[2]80 outputFilePath = sys.argv[3]81 csvFile = open(outputFilePath, "wb")82 writer = csv.writer(csvFile, delimiter=",", quotechar='"', quoting=csv.QUOTE_ALL)83 rowData = ["Shot Path", shotFolder]84 writer.writerow(rowData)85 rowData = ["Keyframe folder", resultsFolder]86 writer.writerow(rowData)87 for file in os.listdir(shotFolder):88 if file.endswith(".avi"):89 file = file[:-4]90 splitData = file.split("-")91 startFrames.append(int(splitData[0]))92 endFrames.append(int(splitData[1]))93 startFrames.sort()94 print "Start times:"95 print "\t" + str(startFrames)96 endFrames.sort()97 print "End times:"98 print "\t" + str(endFrames)99 print "Start Frame count " + str(len(startFrames))100 print "End Frame count " + str(len(endFrames))101 print "Shot data ready"102 subFolders = [int(d[:-1]) for d in os.listdir(resultsFolder) if os.path.isdir(os.path.join(resultsFolder, d))]103 # print subFolders104 subFolders.sort()105 # print subFolders106 writer.writerow([""]+subFolders)107 for folder in subFolders:108 folderName = str(folder) + "%"109 folderPath = os.path.join(resultsFolder, folderName)110 experimentFolders = [d for d in os.listdir(folderPath) if os.path.isdir(os.path.join(folderPath, d))]111 print experimentFolders112 for experiment in experimentFolders:113 path = os.path.join(folderPath,experiment)114 path = os.path.join(path, "keyFrames")115 runAlgo(folderPath, experiment)116 writer.writerow(FL)117 writer.writerow(DM)118 writer.writerow(FB1)119 writer.writerow(FB2)...

Full Screen

Full Screen

views.py

Source:views.py Github

copy

Full Screen

...28 return render(request, 'about.html') #the about page29def character(request):30 #return HttpResponse('character')31 return render(request, 'character.html')32def frames(request):33 #return HttpResponse('frames')34 return render(request,'frames.html')35def KanoHome(request):36 #return HttpResponse('Kano')37 KanoBasicFrames = KanoBasicAttack.objects.all()38 KanoStringFrames = KanoStringAttack.objects.all()39 KanoSpecialFrames = KanoSpecialAttack.objects.all()40 KanoRipperFrames = KanoRipperAttack.objects.all()41 KanoDirtbagFrames = KanoDirtbagAttack.objects.all()42 return render(request, 'KanoHome.html',43 {'KanoBasicFrames': KanoBasicFrames ,'KanoStringFrames': KanoStringFrames ,44 'KanoSpecialFrames': KanoSpecialFrames, 'KanoRipperFrames':KanoRipperFrames, 'KanoDirtbagFrames': KanoDirtbagFrames})45def NightwolfHome(request):46 #return HttpResponse('Nightwolf')...

Full Screen

Full Screen

vpxtest.py

Source:vpxtest.py Github

copy

Full Screen

...9def main():10 camera = Camera(0, dict(width=640, height=480))11 clock = Clock(RATE)12 # capture frames as scv images13 frames = list(capture_frames(camera, clock, NUM_FRAMES))14 print '=== REALTIME ==='15 decoded_frames = run_test(frames, vpx.VPX_DL_REALTIME)16 playback(clock, decoded_frames)17 print '=== GOOD QUALITY ==='18 decoded_frames = run_test(frames, vpx.VPX_DL_GOOD_QUALITY)19 playback(clock, decoded_frames)20 print '=== BEST QUALITY ==='21 decoded_frames = run_test(frames, vpx.VPX_DL_BEST_QUALITY)22 playback(clock, decoded_frames)23def capture_frames(camera, clock, num_frames):24 for fno in xrange(num_frames):25 clock.tick()26 yield camera.getImage()27def playback(clock, frames):28 for img in frames:29 clock.tick()30 img.show()31def run_test(frames, deadline):32 # Encode frames33 start = time.time()34 w,h = frames[0].width, frames[0].height35 clip = M.Clip.encode(w,h,frames, deadline=deadline)36 elapsed = time.time() - start37 print '%d frames encoded in %fs, %.2f fps (avg) (%d kB)' % (...

Full Screen

Full Screen

VideoFrame.py

Source:VideoFrame.py Github

copy

Full Screen

1"""Dummy Dataset and data loader for frames in single video."""2import os3import skvideo.io4import torch.utils.data as data5class VideoFrame(data.Dataset):6 """Dummy dataset for frames in single video."""7 def __init__(self, filepath, num_frames, transform=None):8 """Init VideoFrame dataset."""9 super(VideoFrame, self).__init__()10 self.filepath = filepath11 self.num_frames = num_frames12 self.transform = transform13 self.frames = None14 self.decode()15 def __getitem__(self, index):16 """Get frames from video."""17 frame = self.frames[index, ...]18 if self.transform is not None:19 frame = self.transform(frame)20 return frame21 def __len__(self):22 """Get number of the frames."""23 return self.num_frames24 def decode(self):25 """Decode frames from video."""26 if os.path.exists(self.filepath):27 try:28 self.frames = skvideo.io.vread(29 self.filepath, num_frames=self.num_frames)30 except AssertionError:31 self.frames = skvideo.io.vread(self.filepath)32 # return numpy.ndarray (N x H x W x C)33 self.frames = skvideo.utils.vshape(self.frames)34 self.num_frames = self.frames.shape[0]35 else:...

Full Screen

Full Screen

preprocessor.py

Source:preprocessor.py Github

copy

Full Screen

1import json2import numpy as np3import seaborn as sns4import matplotlib.pylab as plt5# Raw frames are joined into sequences of 16 frames (about 2 seconds each)6# The sequences are then saved as samples for training7raw_data_folder=r"C:\chalmers_thesis\data\TurnAround_201956203615"8destination_data_folder=r"C:\training_data\turn_around"9frames=[]10prefix="\\frame"11frame_rate=1612num_doppler_bins=1613num_range_bins=6414start_index=115end_index=1250+start_index+frame_rate16for i in range(start_index,end_index):17 frames.append(np.nan_to_num(np.array(json.load(open(raw_data_folder+prefix+str(i)+".txt")),dtype="float")[0:frame_rate,18:82]))18 frames[-1]=((frames[-1])/(np.max(frames[-1]))).tolist()19for i in range(len(frames)-frame_rate):20 sequence=[]21 sequence.append(frames[i])22 sequence.append(frames[i+1])23 sequence.append(frames[i+2])24 sequence.append(frames[i+3])25 sequence.append(frames[i+4])26 sequence.append(frames[i+5])27 sequence.append(frames[i+6])28 sequence.append(frames[i+7])29 sequence.append(frames[i+8])30 sequence.append(frames[i+9])31 sequence.append(frames[i+10])32 sequence.append(frames[i+11])33 sequence.append(frames[i+12])34 sequence.append(frames[i+13])35 sequence.append(frames[i+14])36 sequence.append(frames[i+15])...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5 const browser = await puppeteer.launch();6 const page = await browser.newPage();7 await page.emulate(iPhone);8 await page.screenshot({path: 'example.png'});9 await browser.close();10})();11const puppeteer = require('puppeteer');12const devices = require('puppeteer/DeviceDescriptors');13const iPhone = devices['iPhone 6'];14(async () => {15 const browser = await puppeteer.launch();16 const page = await browser.newPage();17 await page.emulate(iPhone);18 await page.screenshot({path: 'example.png'});19 await browser.close();20})();21const puppeteer = require('puppeteer');22const devices = require('puppeteer/DeviceDescriptors');23const iPhone = devices['iPhone 6'];24(async () => {25 const browser = await puppeteer.launch();26 const page = await browser.newPage();27 await page.emulate(iPhone);28 await page.screenshot({path: 'example.png'});29 await browser.close();30})();31const puppeteer = require('puppeteer');32const devices = require('puppeteer/DeviceDescriptors');33const iPhone = devices['iPhone 6'];34(async () => {35 const browser = await puppeteer.launch();36 const page = await browser.newPage();37 await page.emulate(iPhone);38 await page.screenshot({path: 'example.png'});39 await browser.close();40})();41const puppeteer = require('puppeteer');42const devices = require('puppeteer/DeviceDescriptors');43const iPhone = devices['iPhone 6'];44(async () => {45 const browser = await puppeteer.launch();46 const page = await browser.newPage();47 await page.emulate(iPhone);

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5 const browser = await puppeteer.launch({6 });7 const page = await browser.newPage();8 await page.emulate(iPhone);9 await browser.close();10})();11const puppeteer = require('puppeteer');12(async () => {13 const browser = await puppeteer.launch({14 });15 const page = await browser.newPage();16 await page.emulate(iPhone);17 await browser.close();18})();19const puppeteer = require('puppeteer');20(async () => {21 const browser = await puppeteer.launch({22 });23 const page = await browser.newPage();24 await page.emulate(iPhone);25 await browser.close();26})();27const puppeteer = require('puppeteer');28(async () => {29 const browser = await puppeteer.launch({30 });31 const page = await browser.newPage();32 await page.emulate(iPhone);33 await browser.close();34})();35const puppeteer = require('puppeteer');36(async () => {37 const browser = await puppeteer.launch({38 });39 const page = await browser.newPage();40 await page.emulate(iPhone);41 await browser.close();42})();43const puppeteer = require('puppeteer');44(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({ headless: false, slowMo: 50 });4 const page = await browser.newPage();5 await page.focus('#lst-ib');6 await page.keyboard.type('puppeteer');7 await page.keyboard.press('Enter');8 await page.waitForNavigation();9 await page.click('#rso > div:nth-child(1) > div > div > div > div > h3 > a');10 await page.waitForNavigation();11 await page.click('#main-content > div > div > div > div > div > div > div > div > div > div > d

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4(async () => {5 const browser = await puppeteer.launch({headless: false});6 const page = await browser.newPage();7 await page.waitFor(5000);8 await page.screenshot({path: 'youtube.png'});9 await browser.close();10})();11const puppeteer = require('puppeteer');12const fs = require('fs');13const path = require('path');14(async () => {15 const browser = await puppeteer.launch({headless: false});16 const page = await browser.newPage();17 await page.waitFor(5000);18 await page.screenshot({path: 'youtube.png'});19 await browser.close();20})();21const puppeteer = require('puppeteer');22const fs = require('fs');23const path = require('path');24(async () => {25 const browser = await puppeteer.launch({headless: false});26 const page = await browser.newPage();27 await page.waitFor(5000);28 await page.screenshot({path: 'youtube.png'});29 await browser.close();30})();31const puppeteer = require('puppeteer');32const fs = require('fs');33const path = require('path');34(async () => {35 const browser = await puppeteer.launch({headless: false});36 const page = await browser.newPage();37 await page.waitFor(5000);38 await page.screenshot({path: 'youtube.png'});39 await browser.close();40})();41const puppeteer = require('puppeteer');42const fs = require('fs');43const path = require('path');

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 await page.screenshot({ path: 'google.png' });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4const url = require('url');5const { promisify } = require('util');6const writeFile = promisify(fs.writeFile);7const unlink = promisify(fs.unlink);8(async () => {9 const browser = await puppeteer.launch({10 });11 const page = await browser.newPage();12 await page.goto(URL);13 await page.waitForSelector('iframe');14 const frames = await page.frames();15 const frame = frames.find((f) => f.name() === 'myframe');16 await frame.waitForSelector('input[name="firstname"]');17 await frame.type('input[name="firstname"]', 'John');18 await frame.type('input[name="lastname"]', 'Doe');19 await frame.click('input[type="submit"]');20 await page.screenshot({ path: 'example.png' });21 await browser.close();22})();23## 4. How to use page.evaluate() method of Puppeteer24const puppeteer = require('puppeteer');25const fs = require('fs');26const path = require('path');27const url = require('url');28const { promisify } = require('util');29const writeFile = promisify(fs.writeFile);30const unlink = promisify(fs.unlink);31(async () => {32 const browser = await puppeteer.launch({33 });34 const page = await browser.newPage();35 await page.goto(URL);36 await page.waitForSelector('iframe');37 const frames = await page.frames();38 const frame = frames.find((f) => f.name() === 'myframe');39 await frame.waitForSelector('input[name="firstname"]');40 await frame.type('input[name="firstname"]', 'John');41 await frame.type('input[name="lastname"]', 'Doe');42 await frame.click('input[type="submit"]');43 const result = await frame.evaluate(() => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const path = require('path');4(async () => {5 const browser = await puppeteer.launch({6 });7 const page = await browser.newPage();8 await page.goto(url);9 await page.waitForSelector('iframe');10 const elementHandle = await page.$('iframe');11 const frame = await elementHandle.contentFrame();12 await frame.waitForSelector('video');13 const video = await frame.$('video');14 const src = await frame.evaluate((video) => video.src, video);15 console.log(src);16 const response = await page.goto(src);17 const buffer = await response.buffer();18 fs.writeFileSync(path.join(__dirname, 'video.mp4'), buffer);19 console.log('Video downloaded');20 await browser.close();21})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const path = require('path');3const fs = require('fs-extra');4const mkdirp = require('mkdirp');5const rimraf = require('rimraf');6const { promisify } = require('util');7const { exec } = require('child_process');8const execAsync = promisify(exec);9const { spawn } = require('child_process');10const { execFile } = require('child_process');11const { execFileSync } = require('ch

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful