How to use show_segment method in tempest

Best Python code snippet using tempest_python

HunkShow.py

Source:HunkShow.py Github

copy

Full Screen

...35 print "Library #%d" % lib['lib_no']36 for unit in lib['units']:37 self.print_unit(unit['unit_no'], unit['name'])38 for segment in unit['segments']:39 self.show_segment(segment, unit['segments'])40 def show_unit_segments(self):41 for unit in self.units:42 self.print_unit(unit['unit_no'], unit['name'])43 for segment in unit['segments']:44 self.show_segment(segment, unit['segments'])45 def show_loadseg_segments(self):46 # header + segments47 if not self.brief:48 self.print_header(self.header)49 for segment in self.segments:50 self.show_segment(segment, self.segments)51 # overlay52 if self.overlay != None:53 print "Overlay"54 num_ov = len(self.overlay_headers)55 for o in xrange(num_ov):56 if not self.brief:57 self.print_header(self.overlay_headers[o])58 for segment in self.overlay_segments[o]:59 self.show_segment(segment, self.overlay_segments[o])60 def show_segment(self, hunk, seg_list):61 main = hunk[0]62 # unit hunks are named63 name = ""64 if hunk[0].has_key('name'):65 name = "'%s'" % main['name']66 type_name = main['type_name'].replace("HUNK_","")67 size = main['size']68 hunk_no = main['hunk_no']69 if main.has_key('data_file_offset'):70 data_file_offset = main['data_file_offset']71 else:72 data_file_offset = None73 hunk_file_offset = main['hunk_file_offset']74 if main.has_key('alloc_size'):...

Full Screen

Full Screen

homography.py

Source:homography.py Github

copy

Full Screen

1import os2from pathlib import Path3import cv24import numpy as np5from visualize import vis_utils6from homography import transform_calculator7from homography.line import Line8def find_homography_lines(img,9 rotate=False,10 warp=False,11 vis=False,12 write=False,13 output_name=None):14 """15 Find homography transform using line detection16 :param output_name:17 :param img:18 :param rotate:19 :param warp:20 :param vis:21 :param write:22 :return:23 """24 if rotate:25 img = cv2.rotate(img, cv2.ROTATE_90_COUNTERCLOCKWISE)26 h, w = img.shape[:2]27 all_line, v_lines, h_lines = transform_calculator.get_lines(img)28 if output_name is not None:29 output_name_base = output_name.rsplit('.', 1)[0]30 else:31 output_name_base = 'test'32 if vis:33 # Drawing org lines34 # for org_line in all_line:35 # Line(org_line).draw(img, show_segment=False, long=False, line_color=(244, 0, 123))36 for org_line in h_lines:37 Line(org_line).draw(img, show_segment=False, long=False, line_color=(0, 0, 255))38 for org_line in v_lines:39 Line(org_line).draw(img, show_segment=False, long=False)40 vis_utils.show_img(img, output_name_base + '_line_detections.jpg', show=vis, write=write)41 thetas = [line[7] for line in v_lines]42 already_vertical = False43 if np.count_nonzero(abs(np.float32(thetas)) > 88) > 10: # many vertical lines44 already_vertical = True45 vanishing_point = [w / 2, 1000000000000]46 custom_lines = [Line(vanishing_point + [line[2], line[3]]) for line in v_lines]47 # custom_lines = [Line(line) for line in v_lines]48 # custom_lines = [Line(line.get_segment(0,w-1,0,h-1)) for line in custom_lines]49 else:50 vanishing_point = transform_calculator.get_vanishing_point(v_lines)51 custom_lines = [Line(vanishing_point + [line[2], line[3]]) for line in v_lines]52 for line in custom_lines:53 line.get_segment(0, w - 1, 0, h - 1)54 line1, line2 = transform_calculator.pick_two_good_lines(custom_lines, thres_length=h)55 if vis:56 # Drawing long lines57 for custom_line in custom_lines:58 custom_line.draw(img, show_segment=False)59 for custom_line in [line1, line2]:60 custom_line.draw(img, show_segment=False, line_color=(0, 100, 230))61 vis_utils.show_img(img, output_name_base + '_line_filter.jpg', show=vis, write=write)62 if not already_vertical:63 M_v, _ = transform_calculator.transform_from_vertical_lines(line1=line1, line2=line2, img=img, warp=False)64 else:65 M_v = np.eye(3)66 M_h, _ = transform_calculator.transform_from_horizontal_lines(line1, line2, h_lines, M_v)67 M_final = np.float32(M_h) @ np.float32(M_v)68 M_final_correct, img_final = transform_calculator.perspective_warp(img, M_final, warp=warp)69 vis_utils.show_img(img_final, output_name_base + '_line_homography_warped.jpg', show=vis, write=write)70 return M_final_correct, img_final71def find_homography_lines_video(video_dir, video_name, output_file=None):72 """73 Find homograhies for all frames in a video74 :param video_dir:75 :param video_name:76 :param output_file: output homographies to that file77 :return:78 """79 if output_file is not None and Path(output_file).exists():80 line_homographies = np.load(output_file)81 else:82 video_path = f'{video_dir}/{video_name}.mp4'83 vidcap = cv2.VideoCapture(video_path)84 line_homographies = []85 rotate = False86 while True:87 it_worked, img = vidcap.read()88 if not it_worked:89 break90 line_homography, _ = find_homography_lines(img, rotate=rotate, vis=False)91 line_homographies.append(line_homography)92 if output_file is not None:93 os.makedirs(str(Path(output_file).parent), exist_ok=True)94 with open(output_file, 'wb') as f:95 np.save(f, line_homographies)...

Full Screen

Full Screen

ioc.py

Source:ioc.py Github

copy

Full Screen

...32 if debugging:33 print(*args, file=sys.stderr, **kwargs)34def ERR(*args, **kwargs):35 print(*args, file=sys.stderr, **kwargs)36def show_segment(segments, index):37 lines = segments[index].split('\n')38 DEBUG(f's[{index}] =>\n{lines}\n----\n')39def _run_txt2csv(path, view=None, tab=False):40 DEBUG(f'running `refs` subcommand, path={path}, view={view}, tab={tab}')41 buffer = sys.stdin.read() if path == '-' else open(path).read()42 text = str(buffer)43 segments = text.split('\n\n\n\n')44 DEBUG(f'segments => {len(segments)}')45 # show_segment(segments, 0)46 # show_segment(segments, 1)47 # show_segment(segments, 2)48 # show_segment(segments, 3)49 # show_segment(segments, 4)50 separator = '\t' if tab else ','51 data = segments[1] if view == "peripheral" else segments[3]52 lines = data.split('\n')53 xs = [ (x.split('\t')) for x in lines ]54 xs = [ (separator.join(x)) for x in xs ]55 xs = '\n'.join(xs)56 print(xs)57 return 058def _build_parser():59 ###60 # Inspired by: https://medium.com/@dboyliao/python-%E8%B6%85%E5%A5%BD%E7%94%A8%E6%A8%99%E6%BA%96%E5%87%BD%E5%BC%8F%E5%BA%AB-argparse-part-2-b5a178f0881361 #62 parser = argparse.ArgumentParser()63 subcmd = parser.add_subparsers(dest='subcmd', help='subcommands', metavar='SUBCOMMAND')...

Full Screen

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 tempest 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