Best Python code snippet using localstack_python
B1_a2_find_boundary_edges.py
Source:B1_a2_find_boundary_edges.py
1#find the start vertex, start edge and start edge loop for the input quad mesh2# ==============================================================================3#Imports4# ==============================================================================5import compas_rhino6from compas_rhino.geometry import RhinoMesh7from compas.datastructures import Mesh8from compas_rhino.artists import MeshArtist9# ==============================================================================10#Select inputs11# ==============================================================================12guid = compas_rhino.select_mesh()13quad_mesh = RhinoMesh.from_guid(guid).to_compas()14# ==============================================================================15#Helper functions16# ==============================================================================17def find_boundary(mesh):18 """19 identifies the start vertex, its respective edge and its continuous edge loop20 Param21 -----22 mesh: compas quad mesh23 return24 ------25 list of corner vertex key, start edge tuple, list of start edge continuous loop26 """27 corners = list(mesh.vertices_where({'vertex_degree':2}))28 corner = corners[1]29 corner_edges = mesh.vertex_neighbors(corner)30 start_edge = (corner, corner_edges[0])31 print("start_edge", start_edge)32 start_loop = mesh.edge_loop(start_edge)33 print("start_loop", start_loop)34 return corner, start_edge, start_loop35# ==============================================================================36#Create vertices of the Brick Pattern37# ==============================================================================38#Step_1 identify the start vertex, edge and start edge loop39corner, start_edge, start_loop = find_boundary(quad_mesh)40# ==============================================================================41# Visualize Rhino42# ==============================================================================43edgecolor = {}44for edge in start_loop:45 if edge not in quad_mesh.edges():46 edge = (edge[1], edge[0])47 edgecolor[edge] = (0, 255, 0)48if start_edge not in quad_mesh.edges():49 start = (start_edge[1], start_edge[0])50edgecolor[start_edge] = (255, 0, 0)51vertexcolor = {}52vertexcolor[corner] = (255, 0, 0)53baselayer = "CSD2::BRICK_PATTERN"54artist = MeshArtist(quad_mesh, layer=baselayer+"::input_quad_mesh")55artist.clear_layer()56artist.draw_faces(join_faces=True)57artist.draw_vertices(color=vertexcolor)58artist.draw_edges(color=edgecolor)59artist.draw()60if __name__ == '__main__':...
segment.py
Source:segment.py
1#!/usr/bin/env python32import numpy as np3from skimage import filtes, io4from matplotlib import pyplot as plt5from helpers import *6def simple_horizontal(image, threshold=500):7 """8 Computes a simple horizontal segmentation of the input captcha9 by splitting at black vertical "bars"10 """11 is_data = image.sum(axis=0) > threshold12 edges = np.diff(np.concatenate(([False], is_data))).nonzero()13 dims = image.shape14 start_edge = 015 while start_edge < len(edges):16 if start_edge + 1 >= len(edges):17 debug("missing end edge", image)18 break19 start = edges[start_edge]20 if start21 end =22 last_end = 023 while last_end < dims[1]:24 start = is_data[last_end:].nonzero()25 if bars[start]26 pass27if __name__ == '__main__':...
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!!