Commit a65ec9f1 authored by luroth's avatar luroth
Browse files

.

parent 01e7b473
...@@ -21,7 +21,7 @@ from osgeo import gdalnumeric ...@@ -21,7 +21,7 @@ from osgeo import gdalnumeric
import time import time
#from shapely.iterops import intersects #from shapely.iterops import intersects
queue = Queue() #queue = Queue()
def rotation_matrix(axis, theta): def rotation_matrix(axis, theta):
axis = np.asarray(axis) axis = np.asarray(axis)
...@@ -191,37 +191,37 @@ def intersect_line_with_planes_2(plane_normales, plane_points, line_vector, line ...@@ -191,37 +191,37 @@ def intersect_line_with_planes_2(plane_normales, plane_points, line_vector, line
intersects = process_planes(index_list, plane_normales, plane_points, line_vector, line_point) intersects = process_planes(index_list, plane_normales, plane_points, line_vector, line_point)
if intersects is not None: if intersects is not None:
queue.put("yep") #queue.put("yep")
count = queue.qsize() count = 0#queue.qsize()
if verbose: if verbose:
t_found = time.time()- t_start t_found = time.time()- t_start
if verbose: if verbose:
print("{0}: Pixel calculated. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True) print("{0}: Pixel calculated. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True)
if count % 20 == 0: #if count % 50 == 0:
print("{} / {} done".format(count, total)) # print("{} / {} done".format(count, total))
return intersects return intersects
else: else:
index_list = np.argsort(plane_delta_dist) index_list = np.argsort(plane_delta_dist)[0:10000]
process_planes(index_list, plane_normales, plane_points, line_vector, line_point, 10000) intersects = process_planes(index_list, plane_normales, plane_points, line_vector, line_point)
if intersects is not None: if intersects is not None:
queue.put("yep") #queue.put("yep")
count = 0#queue.qsize()
if verbose: if verbose:
t_found = time.time()- t_start t_found = time.time()- t_start
count = queue.qsize() count = 0#queue.qsize()
if verbose: print("{0}: Pixel calculated, full run. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True) if verbose: print("{0}: Pixel calculated, full run. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True)
return intersects return intersects
else: else:
queue.put("nop") #queue.put("nop")
count = 0#queue.qsize()
if verbose: if verbose:
t_found = time.time()- t_start t_found = time.time()- t_start
count = queue.qsize() count = 0#queue.qsize()
print("{0}: Pixel not found. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True) print("{0}: Pixel not found. Times: Init normal: {1}, Approximation: {2}, Add: {3}, Sort: {4}, Intersect: {5}".format(count, t_init_normales, t_approximation, t_add, t_sort, t_found), flush=True)
return [np.nan, np.nan, np.nan] return [np.nan, np.nan, np.nan]
def process_planes(index_list, plane_normales, plane_points, line_vector, line_point, limit=None): def process_planes(index_list, plane_normales, plane_points, line_vector, line_point):
count = 0
for plane_index in index_list: for plane_index in index_list:
count += 1
# get plane normale and point # get plane normale and point
plane_normal = plane_normales[plane_index] plane_normal = plane_normales[plane_index]
plane_point = plane_points[plane_index, [0,1,2]] plane_point = plane_points[plane_index, [0,1,2]]
...@@ -235,10 +235,7 @@ def process_planes(index_list, plane_normales, plane_points, line_vector, line_p ...@@ -235,10 +235,7 @@ def process_planes(index_list, plane_normales, plane_points, line_vector, line_p
if hit: if hit:
return intersect_point.tolist() return intersect_point.tolist()
else: else:
if limit is not None and count>limit: pass
return None
else:
pass
return None return None
def main(argv): def main(argv):
...@@ -353,8 +350,8 @@ def main(argv): ...@@ -353,8 +350,8 @@ def main(argv):
sensor_corner_vectors = sensor_pixels_vectors[corner_index] sensor_corner_vectors = sensor_pixels_vectors[corner_index]
#ground_corner_coords = np.array([intersect_line_with_planes(DEM_normales, DEM_points, sensor_corner_vector, focal_point, corners_global) for sensor_corner_vector in sensor_corner_vectors]) #ground_corner_coords = np.array([intersect_line_with_planes(DEM_normales, DEM_points, sensor_corner_vector, focal_point, corners_global) for sensor_corner_vector in sensor_corner_vectors])
while not queue.empty(): #while not queue.empty():
queue.get() # queue.get()
ground_corner_coords = np.array(Parallel(n_jobs=4)(delayed(intersect_line_with_planes_2)(DEM_normales, DEM_points, sensor_corner_vector, focal_point, corners_global, True) for sensor_corner_vector in sensor_corner_vectors), dtype=np.float64) ground_corner_coords = np.array(Parallel(n_jobs=4)(delayed(intersect_line_with_planes_2)(DEM_normales, DEM_points, sensor_corner_vector, focal_point, corners_global, True) for sensor_corner_vector in sensor_corner_vectors), dtype=np.float64)
...@@ -387,8 +384,8 @@ def main(argv): ...@@ -387,8 +384,8 @@ def main(argv):
#for sensor_pixels_vector in sensor_pixels_vectors: #for sensor_pixels_vector in sensor_pixels_vectors:
# ground_pixel_coords.append(intersect_line_with_planes(DEM_normales, DEM_points, sensor_pixels_vector, focal_point, ground_corner_coords)) # ground_pixel_coords.append(intersect_line_with_planes(DEM_normales, DEM_points, sensor_pixels_vector, focal_point, ground_corner_coords))
#ground_pixel_coords = np.array(ground_pixel_coords) #ground_pixel_coords = np.array(ground_pixel_coords)
while not queue.empty(): #while not queue.empty():
queue.get() # queue.get()
ground_pixel_coords= np.array(Parallel(n_jobs=multiprocessing.cpu_count())(delayed(intersect_line_with_planes_2)(DEM_normales, DEM_points, sensor_pixels_vector, focal_point, ground_corner_coords, False, len(sensor_pixels_vectors)) for sensor_pixels_vector in sensor_pixels_vectors)) ground_pixel_coords= np.array(Parallel(n_jobs=multiprocessing.cpu_count())(delayed(intersect_line_with_planes_2)(DEM_normales, DEM_points, sensor_pixels_vector, focal_point, ground_corner_coords, False, len(sensor_pixels_vectors)) for sensor_pixels_vector in sensor_pixels_vectors))
print("\ncalculating view angles") print("\ncalculating view angles")
...@@ -464,4 +461,4 @@ def main(argv): ...@@ -464,4 +461,4 @@ def main(argv):
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1:]) main(sys.argv[1:])
print("\n============\All photos processed, END\n") print("\n============\nAll photos processed, END\n")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment