Commit a65ec9f1 authored by luroth's avatar luroth
Browse files

.

parent 01e7b473
......@@ -21,7 +21,7 @@ from osgeo import gdalnumeric
import time
#from shapely.iterops import intersects
queue = Queue()
#queue = Queue()
def rotation_matrix(axis, theta):
axis = np.asarray(axis)
......@@ -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)
if intersects is not None:
queue.put("yep")
count = queue.qsize()
#queue.put("yep")
count = 0#queue.qsize()
if verbose:
t_found = time.time()- t_start
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)
if count % 20 == 0:
print("{} / {} done".format(count, total))
#if count % 50 == 0:
# print("{} / {} done".format(count, total))
return intersects
else:
index_list = np.argsort(plane_delta_dist)
process_planes(index_list, plane_normales, plane_points, line_vector, line_point, 10000)
index_list = np.argsort(plane_delta_dist)[0:10000]
intersects = process_planes(index_list, plane_normales, plane_points, line_vector, line_point)
if intersects is not None:
queue.put("yep")
#queue.put("yep")
count = 0#queue.qsize()
if verbose:
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)
return intersects
else:
queue.put("nop")
#queue.put("nop")
count = 0#queue.qsize()
if verbose:
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)
return [np.nan, np.nan, np.nan]
def process_planes(index_list, plane_normales, plane_points, line_vector, line_point, limit=None):
count = 0
def process_planes(index_list, plane_normales, plane_points, line_vector, line_point):
for plane_index in index_list:
count += 1
# get plane normale and point
plane_normal = plane_normales[plane_index]
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
if hit:
return intersect_point.tolist()
else:
if limit is not None and count>limit:
return None
else:
pass
pass
return None
def main(argv):
......@@ -353,8 +350,8 @@ def main(argv):
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])
while not queue.empty():
queue.get()
#while not queue.empty():
# 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)
......@@ -387,8 +384,8 @@ def main(argv):
#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 = np.array(ground_pixel_coords)
while not queue.empty():
queue.get()
#while not queue.empty():
# 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))
print("\ncalculating view angles")
......@@ -464,4 +461,4 @@ def main(argv):
if __name__ == "__main__":
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