def batch_line_detector_from_edge(edges, edges_more, img_names, min_pixels): i = 0 for edge in edges: print(img_names[i]) lines = image_line_detector.fixed_line_detector(edge, min_pixels[i]) # iii = cv2.imread("images/" + img_names[i]) iii = cv2.imread("test_images/" + img_names[i]) i1, i2 = image_line_detector.find_line_in_image( iii, edges_more[i], lines) # return i1 # cv2.imwrite("processed_lines/" + img_names[i], i1) # cv2.imwrite("processed_lines/1" + img_names[i], edge) cv2.imwrite("p2/" + img_names[i], i1) i = i + 1
def batch_line_detector_from_edge(edges, edges_more, img_names): i = 0 for edge in edges: # print(img_names[i]) lines = image_line_detector.fixed_line_detector(edge, 300) # iii = cv2.imread("test_images/" + img_names[i]) # print(iii.shape) # # lines[1] = [7.5325000e+02, 1.3217305e-01] # print(lines) i1, i2 = image_line_detector.find_line_in_image( iii, edges_more[i], lines) # return i1 cv2.imwrite("processed_image_full_line/6" + img_names[i], i1) cv2.imwrite("processed_image_full_line/5" + img_names[i], edge) i = i + 1
j = j + 1 continue tags = xml_parser.get_tags(xml_trees[j]) img_f = cv2.imread('new_testset_bbox/' + file + '.jpg') for i in range(tags.__len__()): print(file + '-' + str(i) + '.jpg') img = img_f[int(tags[i]['y1']): int(tags[i]['y2']), int(tags[i]['x1']): int(tags[i]['x2'])] # cv2.imwrite("box-0/" + file + '-' + str(i) + '.jpg', img) # edge = enhanced_edge_detector.edge_detector(img, file + '.jpg', 40, 75, 5) # cv2.imwrite("box-3/" + file + '-' + str(i) + '.jpg', edge) edge = cv2.imread('box-3/' + file + '-' + str(i) + '.jpg', 0) lines = image_line_detector.fixed_line_detector(edge, min_pixels[img_num]) # 35kV港隆线16-27号2.MOV_015145.293.jpg # lines = [ # [-4., 2.9321532], # [-28., 2.760167], # [-38., 2.740167], # ] edge_more = cv2.imread('box-1/' + file + '-' + str(i) + '.jpg', 0) i1, i2 = image_line_detector.find_line_in_image(img, edge_more, lines) img_f[int(tags[i]['y1']): int(tags[i]['y2']), int(tags[i]['x1']): int(tags[i]['x2'])] = i1 # cv2.imwrite('box-n/' + file + '-' + str(i) + '.jpg', i1)
def batch_line_detector_from_edge(edges, edges_more, img_names, min_pixels): i = 0 for edge in edges: print(img_names[i]) lines = image_line_detector.fixed_line_detector(edge, min_pixels[i]) # print(lines) # lines[1] = [7.5325000e+02, 1.3217305e-01] # lines = lines[:5] # lines = [[-8.0750000e+02,3.1154127e+00], # [-8.2100000e+02, 3.0717795e+00], # [ 7.9400000e+02, 1.7453292e-02]] # lines = [ # [7.3900000e+02, 3.9269909e-02], # [7.8500000e+02, 0.0000000e+00], # [-8.8700000e+02, 3.0892327e+00] # ] # lines = [[8.9000000e+02, 1.7453292e-02], # [8.7300000e+02, 6.9813170e-02], # [8.6000000e+02, 1.2217305e-01] # ] # lines = [[4.2200000e+02, 5.2359879e-02], # [4.1600000e+02, 1.9198622e-01], # [4.2700000e+02, 1.3962634e-01]] # lines = [[6.7900000e+02, 1.3962634e-01], # [6.9400000e+02, 1.0471976e-01], # [7.0200000e+02, 5.2359879e-02]] # lines = [ # [-6.2600000e+02, 3.0543261e+00], # [6.2900000e+02, 5.2359879e-02], # [6.0900000e+02, 1.3962634e-01] # ] # lines = [[7.8500000e+02, 1.3962634e-01], # [4.3100000e+02, 1.7453292e-02], # [4.1000000e+02, 5.2359879e-02], # [4.1800000e+02, 0.0000000e+00], # [4.2300000e+02, 6.9813170e-02], # [7.6200000e+02, 1.7453292e-01], # [-4.4000000e+02, 3.0892327e+00] # ] # lines = [[-8.2000000e+02, 3.1241393e+00], # [7.2200000e+02, 6.9813170e-02], # [6.3200000e+02, 1.7453292e-01] # ] # lines = [[9.8784375e+02, 7.7448988e-01], # [9.3200000e+02, 8.3775806e-01]] # iii = cv2.imread("images/" + img_names[i]) iii = cv2.imread("test_images/" + img_names[i]) i1, i2 = image_line_detector.find_line_in_image(iii, edges_more[i], lines) # return i1 # cv2.imwrite("processed_lines/" + img_names[i], i1) # cv2.imwrite("processed_lines/1" + img_names[i], edge) cv2.imwrite("p2/" + img_names[i], i1) i = i + 1