-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremovedcode.py
More file actions
69 lines (48 loc) · 1.98 KB
/
Copy pathremovedcode.py
File metadata and controls
69 lines (48 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Alternetive lowner ellipsoid detection code that was removed in the main file
# img1 = cv2.imread('1.jpg')
# img2 = cv2.imread('2.jpg')
# ellipses = []
# plt.figure()
# sys.setrecursionlimit(2000)
# (center, radii, rotation) = find_ellipses('1.jpg','2.jpg')
# draw the ellipse on the image
# lowner.plot_ellipse((center,radii[0],radii[1],rotation))
# plt.show()
# cv2.destroyAllWindows()
# plot ellipsoid
# find enclosing ellipse
# enclosing_ellipse = lowner.welzl(points)
# # plot resulting ellipse
# lowner.plot_ellipse(enclosing_ellipse, str='k--')
# plt.show()
# cv2.destroyAllWindows()
#MULTI CORE IN ANALYZE
def process_image(self,image_path, first_image_path, experiment):
cur_image = experiment + image_path
ellipse = self.find_ellipses(first_image_path, cur_image)
return [ellipse, cur_image]
def main_loop(self, first_image, verbose=False, limit=150, current_dir=os.listdir('/mnt/shared/Permeability/real/'), current_experiment='/mnt/shared/Permeability/real/'):
self.current_images = {}
for image in current_dir:
if image.endswith(".JPG"):
self.current_images[image] = None
self.ellipses = {}
self.images = {}
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = {}
for i, (image, _) in enumerate(self.current_images.items()):
if i < self.l_limit or image == first_image:
continue
if i == limit:
break
future = executor.submit(self.process_image, image, first_image, current_experiment)
futures[image] = future
for i, (image, future) in enumerate(futures.items()):
result = future.result()
self.images[image] = result
self.ellipses[image] = [result[0]]
if verbose:
loaded = cv2.imread(result[1])
loaded = image.resize(loaded, self.resolution)
self.show_ellipse_image(loaded, result[0])
return self.ellipses, self.images