Skip to content

Commit 9bf1906

Browse files
committed
work in progress
1 parent da1c467 commit 9bf1906

File tree

3 files changed

+5
-69
lines changed

3 files changed

+5
-69
lines changed

dls_barcode/scan/with_geometry/geometry_scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _merge_frame_into_plate(self):
113113
# If one of the barcodes matches the previous frame and is aligned in the same slot, then we can
114114
# be fairly sure we are dealing with the same plate. Copy all of the barcodes that we read in the
115115
# previous plate over to their slot in the new plate. Then read any that we haven't already read.
116-
self._plate_scan.new_frame(self._geometry, self._barcodes)
116+
self._plate_scan.new_frame(self._frame_img, self._geometry, self._barcodes)
117117

118118
def _find_common_barcode(self, geometry, barcodes):
119119
""" Determine if the set of finder patterns has any barcodes in common with the existing plate.
@@ -138,7 +138,7 @@ def _find_common_barcode(self, geometry, barcodes):
138138
continue
139139

140140
# Read the barcode
141-
new_bc.perform_read()
141+
new_bc.perform_read(self._frame_img)
142142

143143
if not new_bc.is_valid():
144144
continue

dls_barcode/scan/with_geometry/plate_scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _new_slot_frame(self, slot):
4949
#cv2.imshow("Slot image", slot_image.img)
5050
#cv2.waitKey(0)
5151

52-
slot_scanner = SlotScanner(self._frame_img, slot, barcode, self._force_deep_scan, self.radius_avg, self.brightness_threshold)
52+
slot_scanner = SlotScanner(self._frame_img, slot, barcode, self.radius_avg, self.brightness_threshold)
5353
slot_scanner.scan_slot()
5454

5555
def _calculate_average_radius(self):

dls_barcode/scan/with_geometry/slot_scanner.py

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33
import logging
44
import math
55

6-
from dls_barcode.datamatrix import DataMatrix, Locator
76
from dls_barcode.plate.slot import Slot
87

98

109
class SlotScanner:
1110
FRAMES_BEFORE_DEEP = 3
1211

13-
def __init__(self, image, slot, barcode, force_deep_scan, radius_avg, brightness_threshold):
12+
def __init__(self, image, slot, barcode, radius_avg, brightness_threshold):
1413
self._log = logging.getLogger(".".join([__name__]))
1514

1615
self.image = image
1716
self.slot = slot
1817
self.barcode = barcode
19-
self._force_deep_scan = force_deep_scan
2018

2119
self.radius_avg = radius_avg
2220
self.side_avg = self.radius_avg * (2 / math.sqrt(2))
@@ -50,67 +48,5 @@ def scan_slot(self):
5048
# Clear any previous (empty/unread) result
5149
self.slot.set_no_result()
5250

53-
#if self._should_do_deep_scan():
54-
# self._perform_deep_contour_slot_scan()
55-
# self._perform_square_slot_scan()
56-
5751
def _should_do_deep_scan(self):
58-
return self._force_deep_scan or self.slot.total_frames >= self.FRAMES_BEFORE_DEEP
59-
60-
def _perform_deep_contour_slot_scan(self):
61-
if self.slot.state() != Slot.VALID:
62-
barcode = self.deep_scan()
63-
if not self._force_deep_scan and barcode:
64-
barcode.perform_read(self.image)
65-
self.slot.set_barcode(barcode)
66-
67-
def _perform_square_slot_scan(self):
68-
if self.slot.state() != Slot.VALID:
69-
barcode = self.square_scan()
70-
if barcode is not None:
71-
barcode.perform_read(self.image)
72-
self.slot.set_barcode(barcode)
73-
74-
def deep_scan(self):
75-
if not self._is_slot_worth_scanning():
76-
return []
77-
78-
img = self._slot_image()
79-
fps = list(Locator().locate_deep(img, self.radius_avg))
80-
barcodes = [DataMatrix(fp) for fp in fps]
81-
82-
return barcodes
83-
84-
def square_scan(self):
85-
if not self._is_slot_worth_scanning():
86-
return None
87-
88-
img = self._slot_image()
89-
fp = Locator().locate_square(img, self.side_avg)
90-
91-
barcode = None
92-
if fp is not None:
93-
barcode = DataMatrix(fp)
94-
95-
return barcode
96-
97-
def _slot_image(self):
98-
center = self.slot.barcode_position()
99-
slot_img, _ = self.image.sub_image(center, self.radius_avg * 2)
100-
return slot_img
101-
102-
def _is_slot_worth_scanning(self):
103-
state = self.slot.state()
104-
# center = self.slot.barcode_position()
105-
106-
# If we cant see the slot in the current frame, skip it
107-
#slot_in_frame = self._image_contains_point(center, self.radius_avg / 2) ### ?????
108-
#if not slot_in_frame:
109-
# return False
110-
111-
if state == Slot.VALID or state == Slot.EMPTY:
112-
return False
113-
114-
return True
115-
116-
52+
return self.slot.total_frames >= self.FRAMES_BEFORE_DEEP

0 commit comments

Comments
 (0)