mesher = dic.Mesher(deg_e=3, deg_n=3) # mesh = mesher.mesh(images,Xc1=200,Xc2=1050,Yc1=200,Yc2=650,n_ely=8,n_elx=8, GUI=True) mesh = mesher.mesh(images, Xc1=20, Xc2=105, Yc1=20, Yc2=65, n_ely=8, n_elx=8, GUI=True) # Instantiate settings object and set some settings manually settings = dic.DICInput(mesh, images) # 图像数量 settings.max_nr_im = 2 settings.ref_update = [15] settings.maxit = 20 # If you want to access the residual fields after the analysis, this should be set to True settings.store_internals = False # Instantiate job object job = dic.DICAnalysis(settings) # Running DIC analysis dic_results = job.run() # 用于仿真,假设z均为3,拼接出三维obj_points # 世界三维坐标为参考图的点 cols, rows = dic_results.xnodesT.shape obj_points = np.zeros((cols, 3), np.float32) obj_points[:, 0] = dic_results.xnodesT[:, 0] obj_points[:, 1] = dic_results.ynodesT[:, 0] # obj_points = np.append(np.array(dic_results.xnodesT[:, 1]), np.array(dic_results.ynodesT[:, 1])) znodes = np.zeros(cols, np.float32) # obj_points = np.append(obj_points, znodes, axis=1) obj_points[:, 2] = znodes objectpoints = []
mesher = dic.Mesher(deg_n=3, deg_e=3, type="spline") #mesh = mesher.mesh(image_stack) # Use this if you want to mesh with a GUI mesh = mesher.mesh(image_stack, Xc1=50, Xc2=450, Yc1=50, Yc2=450, n_ely=8, n_elx=8, GUI=False) # Prepare the analysis input and initiate the analysis input = dic.DICInput(mesh, image_stack) input.tol = 1e-6 dic_job = dic.DICAnalysis(input) results = dic_job.run() # Calculate the fields for later use fields = dic.Fields(results, seed=101) # We will now compare the results from the analysis to the displacement which the image was deformed by # We do this by evaluating the same function as used to deform the images. # First we find the image coordinates of the image xs, ys = dic.utils.image_coordinates(image_stack[0]) # We then find the displacement components for each image coordinate u_x, u_y = displacement_function(xs, ys, omega=2. * np.pi / 500., amp=2.0) # We now need to find the material points used in the DIC analysis, and extract the corresponding # correct displacement values
def run_DIC(folder_path, n_images, filter, filter_sigma, maxim, maxit, padding, poly_order, converge): # Set the amount of info printed to terminal during analysis logging.basicConfig(format='%(name)s:%(levelname)s:%(message)s', level=logging.INFO) # Path to folder containing images path = folder_path # Generate image instance containing all images found in the folder images = dic.IO.image_stack_from_folder(path, file_type='.png') images.use_every_n_image(int(n_images)) if filter == "Lowpass Gaussian": images.set_filter(dic.filtering.lowpass_gaussian, sigma=int(filter_sigma)) elif filter == "Highpass Gaussian": images.set_filter(dic.filtering.highpass_gaussian, sigma=int(filter_sigma)) elif filter == "Homomorphic Median": images.set_filter(dic.filtering.homomorphic_median, sigma=int(filter_sigma)) else: pass # Generate mesh mesher = dic.Mesher(deg_e=3, deg_n=3, type="q4") #type="b_splines") mesh = mesher.mesh(images, Xc1=316, Xc2=523, Yc1=209, Yc2=1055, n_ely=18, n_elx=5, GUI=True) # Instantiate settings object and set some settings manually (first video) settings = dic.DICInput(mesh, images) if bool(maxim): settings.max_nr_im = int(maxim) settings.ref_update = [15] settings.maxit = int(maxit) settings.tol = 1.e-6 settings.interpolation_order = int(poly_order) # If you want to access the residual fields after the analysis, this should be set to True settings.store_internals = True # This setting defines the behaviour when convergence is not obtained if converge == "Ignore": settings.noconvergence = "ignore" elif converge == "Update": settings.noconvergence = "update" elif converge == "Break": settings.noconvergence = "break" else: pass # Instantiate job object job = dic.DICAnalysis(settings) # Running DIC analysis dic_results = job.run() return images, dic_results