def draw_3d_graph(graph: Graph, pov_coords: Coords, fname: str = 'graph.png', verbose: bool = True): """Draw a projection of given graph""" amplitudes, center = graph.amplitudes, graph.center pov_coords = Coords(*pov_coords) pov = projection.create_pov_toward(center, pov_coords) print('CENTER PROJECTION:', projection.projection(center, pov, verbose=verbose)) # exit() if verbose: print('POV:', pov) # print('ANGLES OF CENTER:', geometry.angles_from_coords(geometry.coords_centered_on(center, pov.coords))) nodes_projections = { node: projection.projection(Coords(*node), pov, verbose=verbose) for node in graph.nodes } # draw_map(pov, nodes_projections, center, center) if verbose: print('NODES PROJECTIONS:', nodes_projections) graph_2d = frozenset( (nodes_projections[source], nodes_projections[target]) for source, target in graph.links if nodes_projections[source] and nodes_projections[target]) if verbose: print('2D GRAPH:', graph_2d) draw_2d_graph(graph_2d, fname=fname, center=projection.projection(center, pov, verbose=verbose))
def rope_particles(self, screen: pygame.Surface, camera: pygame.Vector3, rx: int, ry: int, k_rx, x1: int, x2: int): left = projection(self.polygons[1].points[0], camera, rx, ry, True, k_rx) right = projection(self.polygons[0].points[2], camera, rx, ry, True, k_rx) pygame.draw.line(screen, "grey", (x1, SCREEN_DIMENSION[1]), left.xy, 2) pygame.draw.line(screen, "grey", (x2, SCREEN_DIMENSION[1]), right.xy, 2) body_left = projection(self.polygons[0].points[0], camera, rx, ry, True, k_rx) body_right = projection(self.polygons[1].points[2], camera, rx, ry, True, k_rx) self.particles.append( Particle((body_left.x - random.randint(0, abs(int(body_right.x - body_left.x))), body_left.y + 10), (0, 10), random.randint(10, 30))) self.particles.append( Particle((body_right.x + random.randint(0, abs(int(body_right.x - body_left.x))), body_right.y + 10), (0, 10), random.randint(10, 30))) for particle in self.particles: particle.update() particle.draw(screen)
def draw(self, screen: pygame.Surface, camera: pygame.Vector3, rx: int, ry: int, water: int = None) -> None: points2d = [] z = 0 vec3_cloud = None clouds2d = [] zn = 0 for p in self.points: if self.perlin_depth > 2: vec3_cloud = projection(pygame.Vector3(p.x, p.y + 7, p.z), camera, rx, ry) vec3 = projection(p, camera, rx, ry) if (-screen.get_width() < vec3.x < screen.get_width() * 2 and -screen.get_height() * 1 < vec3.y < screen.get_height() * 1.5): z += vec3.z points2d.append(pygame.Vector2(*vec3.xy)) if vec3_cloud is not None: if (-screen.get_width() < vec3_cloud.x < screen.get_width() * 2 and -screen.get_height() * 1 < vec3_cloud.y < screen.get_height() * 1.5): zn += vec3_cloud.z clouds2d.append(pygame.Vector2(*vec3_cloud.xy)) if len(points2d) > 2: dz = z c = [min(max(0, dz * 2) + self.color[0], 255), min(max(0, dz * 2) + self.color[1], 255), min(max(0, dz * 2) + self.color[2], 255)] if dz > 5: pygame.gfxdraw.filled_polygon(screen, points2d, c) if self.perlin_depth > 2 and len(clouds2d) > 2 and zn > 5: pygame.gfxdraw.filled_polygon(screen, clouds2d, (min(255 - 10 * self.perlin_depth, 255), min(255 - 10 * self.perlin_depth, 255), min(255 - 10 * self.perlin_depth, 255)))
def putMeshLab(real_image, s, bldg_info=gml_parser.parse('DA12_3D_Buildings_Merged.gml'), bldg_id=False, buildings=parse_buildings_info(), f=1): R, T, intrinsics = extract_rotation_translation_intrinsics(s) euler = conversion.rotationMatrixToEulerAngles(R) coord = collision.collision_check(-T.T[0], euler, bldg_info, step=10) print('coord', coord) if bldg_id: coord = bldg_id assert coord import matplotlib.pyplot as plt p = projection.projection(bldg_info[coord]['polygons'], R, -T.T[0], *intrinsics) p = cv2.resize( p, (0, 0), fx=f, fy=f ) # Hardcoded only for current meshlab workaround due to different intrinsics. Unnecessary for real examples dst = matching.ssd_match(real_image, p) txt = buildings[coord][1] + '\n' + buildings[coord][-1] fig = plt.figure() fig.text(0.5, 0.008, txt, ha='center') plt.axis('off') plt.imshow(dst, cmap='gray') plt.show()
def draw(self, screen: pygame.Surface, camera: pygame.Vector3, rx: int, ry: int): vec3 = projection(self.points[0], camera, rx, ry) if (-screen.get_width() < vec3.x < screen.get_width() * 2 and -screen.get_height() * 1 < vec3.y < screen.get_height() * 1.5): c = [ min(max(0, vec3.z * 2) + self.color[0], 255), min(max(0, vec3.z * 2) + self.color[1], 255), min(max(0, vec3.z * 2) + self.color[2], 255) ] if vec3.z > 0: pygame.draw.circle(screen, c, vec3.xy, 30, 10)
def inv_permutation(perImg, chaos_system): # Use chen system generate mapping rule print("generating mapping rule...") dim3d = calc_dim(perImg) rule = mappingRule(chaos_system, dim3d) # Project pixel image to bit array perBitArray = projection(perImg, dim3d) # mapping according to mapping rule print("image permuting...") srcBitArray = inv_mapping(perBitArray, rule) # project bit array to pixel image plainImg = inv_projection(srcBitArray, perImg.mode) return plainImg
def renderer(newTemplate2x4, classifier): print("Entering Renderer") testProjection = projection() numLines = len(newTemplate2x4.x) / 2 print(numLines) m = numLines n = numLines + 1 while (numLines >= 0): print("inside while: " + str(numLines)) m = +1 n = +1 if (classifier == 3): testProjection.drawCircle(newTemplate2x4) else: testProjection.draw(newTemplate2x4, m, n) numLines = -1 testProjection.display()
def draw(self, screen: pygame.Surface, camera: pygame.Vector3, rx: int, ry: int, k_rx: int = None) -> None: points2d = [] z = 0 for p in self.points: vec3 = projection(p, camera, rx, ry, True, k_rx) if (-screen.get_width() < vec3.x < screen.get_width() * 2 and -screen.get_height() < vec3.y < screen.get_height() * 2): z += vec3.z points2d.append(pygame.Vector2(*vec3.xy)) if len(points2d) > 2: pygame.draw.polygon(screen, 'white', points2d, 3) pygame.gfxdraw.filled_polygon(screen, points2d, self.color)
def prediction_model(number_of_camera, number, net, bounding_box): # time1=time.time() points = np.zeros([number * number * number, 3]) set_points(bounding_box, number, points) projection_points = np.zeros( [number_of_camera, number * number * number, 2]) pamt = np.zeros([number_of_camera, 3, 4]) for i in range(number_of_camera): pamt[i, :, :] = np.loadtxt("Camera" + str(camera[i]) + ".Pmat.cal") projection_points[i, :, :] = projection.projection( points, pamt[i, :, :], number * number * number) with torch.no_grad(): inputs = torch.tensor(projection_points) inputs = inputs.to(device) # print(time.time()-time1) outputs = net(photo, inputs) return (outputs, points)
def color_points(photo, points, pamt, normals, model): # np.save('points',points) # print(photo[0,0,800,600]) # points_temp=points.copy() site = np.loadtxt('camera_site.txt') print(pamt.shape[0]) direction = np.zeros((points.shape[0], pamt.shape[0], 3)) time1 = time.time() for i in range(points.shape[0]): for j in range(pamt.shape[0]): direction[i, j, :] = site[j, :] - points[i, :] projection_points = np.zeros((pamt.shape[0], points.shape[0], 2)) # print(pamt.shape[0]) for i in range(pamt.shape[0]): projection_points[i, :, :] = projection.projection( points, pamt[i, :, :], points.shape[0]) weight = np.zeros((points.shape[0], pamt.shape[0])) # point_list=[] # projection_points_list=[] # weight_list=[] time1 = time.time() wight_points(points, normals, pamt, direction, weight) print(12234235234243, time.time() - time1) print(points.shape) # weight=np.array(weight_list) # projection_points=np.array(projection_points_list).transpose(1,0,2) # points=np.array(point_list) print(points.shape, projection_points.shape, weight.shape) # print(len(point_list)) color = np.zeros((points.shape[0], 3)) color_points_color(pamt, photo, points, projection_points, color, weight) point_and_color = np.zeros((points.shape[0], 6)) point_and_color[:, 0:3] = points point_and_color[:, 3:6] = color.astype(int) np.savetxt( './color_points/train_point_and_color' + str(model) + "_" + ".txt", point_and_color) return color
def color_points(photo, points, pamt, normals): np.save('points', points) site = camera_site(pamt.copy()) np.savetxt('camera_site.txt', site) color = np.zeros((points.shape[0], 3)) direction = np.zeros((points.shape[0], pamt.shape[0], 3)) for i in range(points.shape[0]): for j in range(pamt.shape[0]): direction[i, j, :] = site[j, :] - points[i, :] projection_points = np.zeros((pamt.shape[0], points.shape[0], 2)) # print(pamt.shape[0]) for i in range(pamt.shape[0]): projection_points[i, :, :] = projection.projection( points, pamt[i, :, :], points.shape[0]) weight = np.zeros((points.shape[0], pamt.shape[0])) for i in range(points.shape[0]): sum = 0 for j in range(pamt.shape[0]): # print(normals[i,:],direction[i,j,:]) if np.dot(normals[i, :], normals[i, :]) == 0: # print(111111) weight[i, j] = 0 else: weight[i, j] = np.dot( normals[i, :], direction[i, j, :]) / np.sqrt( np.dot(normals[i, :], normals[i, :])) / np.sqrt( np.dot(direction[i, j, :], direction[i, j, :])) if weight[i, j] < 0: weight[i, j] = 0 sum = sum + weight[i, j] for j in range(pamt.shape[0]): if sum > 0: weight[i, j] = weight[i, j] / sum else: weight[i, j] = 0 color_points_color(points, projection_points, color, weight) # print(OK) np.save('color_1', color) return color
def prediction_model(number_of_camera, number, net, bounding_box): # time1=time.time() points = np.zeros([number * number * number, 3]) set_points(bounding_box, number, points) projection_points = np.zeros( [number_of_camera, number * number * number, 2]) pamt = read_cal(36) for i in range(number_of_camera): projection_points[i, :, :] = projection.projection( points, pamt[camera[i], :, :], number * number * number) with torch.no_grad(): inputs = torch.tensor(projection_points) inputs = inputs.to(device) # print(time.time()-time1) outputs = net(photo, inputs) print(1234242434, torch.cuda.max_memory_allocated()) return (outputs, points)
def permutation(srcImg, chaos_system): # Use chen system generate mapping rule print("generating mapping rule...") t_start = t.default_timer() ''' Change HERE to modify use new dimension alg whether or not''' #dim3d = calc_dim(srcImg) dim3d = [srcImg.size[0], srcImg.size[1], mode_to_bpp[srcImg.mode]] rule = mappingRule(chaos_system, dim3d) # Project pixel image to bit array srcBitArray = projection(srcImg, dim3d) # mapping according to mapping rule print("image permuting...") perBitArray = mapping(srcBitArray, rule) # project bit array to pixel image perImg = inv_projection(perBitArray, srcImg.mode) t_end = t.default_timer() print("Eclipse time = %f" % (t_end - t_start)) return perImg
def plot_projections(): # Underreporting # ============== # If valid format for under-reporting ... if ut.is_float(request.form["not_reported_pc"]) and \ float(request.form["not_reported_pc"])>= 0: under_rep_rate = float(request.form["not_reported_pc"])/100.0 last_notif = session['sel_data']['notif'][-1] under_report = max(under_rep_rate*(last_notif)/(1 - under_rep_rate), U) # If they do not estimate to improve it ... if request.form["start-fix-report"] == "no": # Equivalent to have no under-reporting, hence 0.0 improve = False # boolean: no improvement under_report = 0.0 # initial value start_report = None # start year for improvement end_report = None # end year for improvement final_under_report = 0.0 # final value improvement_pc = 0 # If it is already improving elif request.form["start-fix-report"] == "already": start_report = session['sel_data']['times'][-1][0] improve = True # boolean: yes improvement # If it will start improve at some point else: if request.form["year-report-start"] == '----': return render_template("error.html", error=e.error_year_1()) start_report = int(request.form["year-report-start"]) improve = True # If it will be fixed at some point if request.form["report-fixed"] == "yes-year" and improve: if request.form["year-report-fix"] == '----': return render_template("error.html", error=e.error_year_2()) end_report = int(request.form["year-report-fix"]) final_under_report = U improvement_pc = 100 # If it will be fixed at the end of the projection elif request.form["report-fixed"] == "yes" and improve: end_report = (session['sel_data']['times'][-1][0] + session['length_years']) final_under_report = U improvement_pc = 100 # If it will not be completely fixed elif request.form["report-fixed"] == "no" and improve: improvement_pc = int(request.form["not_reported_final_pc"][:-1]) final_under_report = max(U, improvement_pc*under_report/100.0) end_report = (session['sel_data']['times'][-1][0] + session['length_years']) # If inconsistent input ... if end_report < start_report: return render_template("error.html", error=e.error_inconsistent()) if final_under_report > under_report: return render_template("error.html", error=e.error_inconsistent_2()) else: # If not a valid format for underreporting ... return render_template("error.html", error=e.error_reporting()) # Active case finding # =================== # If they planned it ... if request.form['case-finding'] == 'yes': # If input format is not correct ... if (not ut.is_float(request.form['found_min'])) or (not ut.is_float(request.form['found_max'])): return render_template("error.html", error=e.error_found_cases()) found_min_abs = float(request.form['found_min']) found_max_abs = float(request.form['found_max']) # If input is inconsistent ... if found_min_abs > found_max_abs: return render_template("error.html", error=e.error_input_finding()) # If a time window was given consistently ... if (request.form['start_finding'] != '----' and request.form['end_finding'] != '----' and (int(request.form['end_finding']) >= int(request.form['start_finding']))): start_finding = int(request.form['start_finding']) end_finding = int(request.form['end_finding']) else: return render_template("error.html", error=e.error_time_finding()) # If they did not plan it ... else: found_min_abs = 0 found_max_abs = 0 start_finding = None end_finding = None # Health care access # ================== # If they estimate an improvement ... if not session['subnational'] and request.form['healthcare'] == 'yes': # If input format is not correct ... if ((not ut.is_float(request.form['improve_hc'])) or float(request.form['improve_hc']) < 0): return render_template("error.html", error=e.error_invalid_hc()) # change to rate format improve_hc = float(request.form['improve_hc'])/100.0 # If no improvement ... else: improve_hc = 0 # Incidence decline # ================= # Read input if given correctly if (ut.is_float(request.form['exp_decline_min']) and ut.is_float(request.form['exp_decline_max'])): exp_dec_min = - float(request.form['exp_decline_min'])/100.0 exp_dec_max = - float(request.form['exp_decline_max'])/100.0 # If invalid format ... else: return render_template("error.html", error=e.error_fmt_dec()) # If inconsistent input ... if exp_dec_min > 0 or exp_dec_max > 0 or exp_dec_min < exp_dec_max: return render_template("error.html", error=e.error_inconsistent_dec()) # Compute the projections # ======================= proj_times, exp_smooth, est_notif_min, est_notif_max, figdata = \ pr.projection(session['sel_data'], session['pop'], length_project = session['length'], periods=session['periods'], prev_100_k=session['prev_100_k'], under_report=under_report, final_under_report=final_under_report, start_report=start_report, end_report=end_report, found_min=found_min_abs, found_max=found_max_abs, start_finding=start_finding, end_finding=end_finding, improve_hc=improve_hc, exp_dec_min=exp_dec_min, exp_dec_max=exp_dec_max) parameters = ut.parameter_list(under_rep_rate*100, improvement_pc, start_report, end_report, found_min_abs, found_max_abs, start_finding, end_finding, improve_hc*100, exp_dec_min*100, exp_dec_max*100, subnational=session['subnational']) # List population estimates to compute absolute notif pop = [] for t in proj_times: year = int(t[0]) #times are in fmt (year, period) pop.append(session['pop']['%d' %year]) # Compute absolute numbers for notifications est_abs_notif_min = [int(est_notif_min[i] * pop[i] / 10.0**5) for i in range(len(proj_times))] est_abs_notif_max = [int(est_notif_max[i] * pop[i] / 10.0**5) for i in range(len(proj_times))] # Prepare the data to display #exp_smooth = [round(float(v), 2) for v in exp_smooth] #est_notif_min = [round(float(v), 2) for v in est_notif_min] #est_notif_max = [round(float(v), 2) for v in est_notif_max] # Years as they will displayed in the tables if session['periods'] == 1: years, _ = zip(*proj_times) else: years = ["%d - %d" %(y, p) for (y, p) in proj_times] # Display time series to_display = zip(session['sel_data']['times'], session['sel_data']['abs_notif']) # Prepare empty rows for all years and then fill them hist = {y: [' ' for p in range(session['periods'])] for y in range(to_display[0][0][0], to_display[-1][0][0]+1)} for t, n in to_display: hist[t[0]][t[1]-1] = n #column headers if session['periods'] == 1: columns = ['Notifications'] elif session['periods'] == 4: columns = ['%d' %i for i in range(1,5)] elif session['periods'] == 12: columns = ['%d' %i for i in range(1,13)] if session['init_detected_val']==None: return render_template("plot_projections.html", parameters=parameters, country=session['country'], fig=figdata, exp_smooth=exp_smooth, est_abs_notif_min=est_abs_notif_min, est_abs_notif_max=est_abs_notif_max, hist=hist, columns=columns, years=years, no_mdr=(session['manual'] or session['init_detected_val']==None)) #MDR #=== # If input given in correct format if ut.is_float(request.form['detect']): # Convert to rates detected_fin = float(request.form['detect'])/100.0 # If inconsistent input ... if detected_fin > 1 or detected_fin < 0: return render_template("error.html", error=e.error_bad_detected()) else: return render_template("error.html", error=e.error_invalid_fmt_detected()) parameters.append(('Detected MDR-TB cases at the end of the projection', '%1.f%%' %(detected_fin*100))) # Projections for MDR notifications # ================================= mdr_min, mdr_max = pr.mdr_projection(proj_times, est_abs_notif_min, est_abs_notif_max, init_detected=session['init_detected_val']/100.0, detected_fin=detected_fin, prob_re=session['p_ret_rel'], prob_new=session['p_new'], prob_mdr_re=session['prob_mdr_re'], prob_mdr_new=session['prob_mdr_new']) # Prepare for display mdr_min = [int(v) for v in mdr_min] mdr_max = [int(v) for v in mdr_max] # Display return render_template("plot_projections.html", parameters=parameters, mdr_min=mdr_min, mdr_max=mdr_max, hist=hist, columns=columns, country=session['country'], fig=figdata, exp_smooth=exp_smooth, est_abs_notif_min=est_abs_notif_min, est_abs_notif_max=est_abs_notif_max, years=years, manual=session['manual'])
##image_names = sorted(glob.glob("../data/back up data/03_20_2019/images/*.png")) size = len(coord_names) print(size) zeros = len(str(size)) for i in range(size): image = cv2.imread(image_names[i],0) image_shape = image.shape data = np.loadtxt(coord_names[i],delimiter = ' ') coords = data[:,0:3] radii = data[:,-1] part_num = data.shape[0] image_coords = np.zeros((part_num,2)) for j in range(part_num): coord = coords[j,] radius = radii[j] image_coords[j,:] = projection((coord)) image_coords_name = folder + "/image_coords/" + '0'*(zeros-len(str(i))) + str(i) + '.txt' ## image_coords_name = "../data/back up data/03_20_2019/image_coords/" + '0'*(zeros-len(str(i))) + str(i) + '.txt' with open(image_coords_name, 'wb') as f: np.savetxt(f,image_coords,fmt="%d",delimiter = ' ')
number_sum=0 step=0.7*step optimizer = optim.Adam(net.parameters(), lr=step) pamt=np.zeros([number_of_camera,3,4]) projection_points=np.zeros([number_of_camera,points.shape[0],2]) pamt=read_cal(36) new_points=np.copy(points) points[:,1]=-new_points[:,2] points[:,2]=new_points[:,1] for i in range(number_of_camera): print(camera[i]) projection_points[i,:,:]=projection.projection(points,pamt[camera[i],:,:],number) photo=torch.empty(number_of_camera,3,resolution_x,resolution_y) for i in range(number_of_camera): photo[i,:]=torch.tensor(np.transpose(plt.imread(r"D:\data\PVHM_0-9999\rendered_images\{}_{}_{}x{}.png".format(model,camera[i],resolution_x,resolution_y))).astype(float))[0:3] show_image(r"D:\data\PVHM_0-9999\rendered_images\{}_{}_{}x{}.png".format(model,camera[i],resolution_x,resolution_y),projection_points[i,:,:]) ticks1 = time.time() running_loss = 0.0 photo=photo.to(device) inputs=torch.tensor(projection_points) inputs = inputs.to(device)
number_sum = number_sum + number if number_sum > 100000: print(number_sum) number_sum = 0 step = 0.7 * step optimizer = optim.Adam(net.parameters(), lr=step) pamt = np.zeros([number_of_camera, 3, 4]) projection_points = np.zeros( [number_of_camera, points.shape[0], 2]) #计算空间点在照片上的投影 for i in range(number_of_camera): print(camera[i]) pamt[i, :, :] = np.loadtxt("Camera" + str(camera[i]) + ".Pmat.cal") projection_points[i, :, :] = projection.projection( points, pamt[i, :, :], number) photo = torch.empty(number_of_camera, 3, 1600, 1200) for i in range(number_of_camera): photo[i, :] = torch.tensor( np.transpose( plt.imread( "C:/Users/liuzhenye/Desktop/Project2/data/RENDER/anim_" + str(number_of_anim) + "/model_" + str(model) + "_anim_" + str(number_of_anim) + "/cameras_cam0" + str(camera[i]) + "/alpha_00" + str(number_of_photo) + "1.png")).astype(float)) ticks1 = time.time()
size = len(boundary_list) - batch_size * (number_of_batch - 1) # time1=time.time() points = np.zeros([number2 * number2 * number2 * size, 3]) for i in range(size): set_points( boundary_list[batch * batch_size + i], number2, points[i * number2 * number2 * number2:(i + 1) * number2 * number2 * number2, :]) projection_points = np.zeros( [number_of_camera, number2 * number2 * number2 * size, 2]) pamt = np.zeros([number_of_camera, 3, 4]) for i in range(number_of_camera): pamt[i, :, :] = np.loadtxt("Camera" + str(camera[i]) + ".Pmat.cal") projection_points[i, :, :] = projection.projection( points, pamt[i, :, :], number2 * number2 * number2 * size) with torch.no_grad(): inputs = torch.tensor(projection_points) inputs = inputs.to(device) output = net(photo, inputs) output = np.array(output) # output=np.zeros([number2*number2*number2*size,2]) # print(output.shape) labels_temp = np.zeros([number2 * number2 * number2, 2]) for m in range(size): i = range_list[batch * batch_size + m][0] j = range_list[batch * batch_size + m][1] k = range_list[batch * batch_size + m][2] prediction_model_label(
size = len(coord_names) print(size) zeros = len(str(size)) for i in range(size): image = cv2.imread(image_names[i],0) image_shape = image.shape data = np.loadtxt(coord_names[i],delimiter = ' ') coords = data[:,0:3] radii = data[:,-1] part_num = data.shape[0] image_coords = np.zeros((part_num,2)) for j in range(part_num): coord = coords[j,] radius = radii[j] temp_coord = projection((coord)) temp_coord[1] = 1023 - temp_coord[1] image_coords[j,:] = temp_coord image_coords_name = folder + "/image_coords/" + '0'*(zeros-len(str(i))) + str(i) + '.txt' ## image_coords_name = "../data/back up data/03_20_2019/image_coords/" + '0'*(zeros-len(str(i))) + str(i) + '.txt' with open(image_coords_name, 'wb') as f: np.savetxt(f,image_coords,fmt="%d",delimiter = ' ')
size = len(coord_names) for i in range(size): image = cv2.imread(image_names[i], 0) image_shape = image.shape data = np.loadtxt(coord_names[i], delimiter=' ') coords = data[:, 0:3] radii = data[:, -1] print("********************************") for coord, radius in zip(coords, radii): #coord = np.array([0,0,0]).astype(int) #print("coords is", coord) image_coord = projection((coord)) print("projected coord is ", image_coord) ## cv2.circle(image, image_coord, 10, 255, -1) ## cv2.circle(image, (image_coord[0],image_coord[1]), int(radius*2), (255,0,0), 1) ## cv2.circle(image, (image_shape[1] - 1 - image_coord[0],image_coord[1]), ## int(radius*2), (0,0,255), 1) cv2.circle(image, (image_coord[0], image_coord[1]), int(radius * 4), (255, 0, 0), 1) ## cv2.circle(image, (639, 539), int(radius * 4), (255, 0, 0), 1) cv2.namedWindow(str(i), cv2.WINDOW_AUTOSIZE) cv2.imshow(image_names[i], image) cv2.waitKey(0) cv2.destroyAllWindows()
with open('pages.pickle', 'rb') as f: pages = pickle.load(f) #targets = np.zeros((len(classes),1)) #training = np.zeros((len(classes),997)) targets = np.zeros((10, 2)) training = np.zeros((10, 997)) cpt = 0 # size nb_examples, data = training.shape print("hpc_low/-"+pages[5]+".pgm") x_test = np.zeros((1,997)) x_test[:][0] = proj.projection(cv2.imread("hpc_low/-"+pages[5]+".pgm")) y_test = np.zeros((1,2)) y_test[0][int(classes[5])] = 1 for i in range(40, 50): print("Working on page : "+pages[i]+", class : "+str(classes[i])) img = cv2.imread("hpc_low/-"+pages[i]+".pgm") training[:][cpt] = proj.projection(img) targets[cpt][int(classes[i])] = 1 cpt += 1 model = Sequential() # Dense(64) is a fully-connected layer with 64 hidden units.