Commit ba94d48b authored by rokka's avatar rokka

added device 13

parent 35520255
......@@ -40,101 +40,20 @@ while True:
ret, frame = cap.read()
if ret:
# frame = cv2.imread("/home/r0x/Development/ansprakon-v2/test_images/medisana_bloodsugar_test.png")
flipped = cv2.rotate(frame, cv2.ROTATE_180)
gray = cv2.cvtColor(flipped[182:385, 0:639].copy(), cv2.COLOR_BGR2GRAY)
gray = cv2.cvtColor(frame.copy(), cv2.COLOR_BGR2GRAY)
ret, thresh1 = cv2.threshold(gray, 127, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C)
height, width = thresh1.shape
pts1 = np.float32([[65, 13], [630, 15], [35, 169], [603, 186]])
height, width = gray.shape
pts1 = np.float32([[258, 45], [618, 47], [237, 197], [606, 206]])
pts2 = np.float32([[0, 0], [width, 0], [0, height], [width, height]])
m = cv2.getPerspectiveTransform(pts1, pts2)
warped = cv2.warpPerspective(thresh1, m, (width, height))
warped = cv2.warpPerspective(gray, m, (width, height))
ret, thresh1 = cv2.threshold(warped, 55, 255, cv2.ADAPTIVE_THRESH_MEAN_C)
double_dot_upper = warped[45:72, 315:344].copy()
double_dot_lower = warped[133:164, 317:348].copy()
digits_1_2 = warped[0:200, 0:306].copy()
digits_3_4 = warped[0:202, 354:639].copy()
#
# kernel_1 = np.ones((3, 3), np.uint8)
# warped_dilated = cv2.dilate(warped, kernel_1, iterations=3)
#
# digits_1_2 = warped_dilated[0:154, 0:238].copy()
# digits_3_4 = warped_dilated[1:160, 311:595].copy()
#
# left_points = thresh1[14:160, 13:74].copy()
# right_points = thresh1[20:160, 530:595].copy()
#
# left_points_dilated = cv2.dilate(left_points, kernel_1, iterations=2)
#
# left_point_1 = None
# left_point_2 = left_points_dilated[62:78, 8:33].copy()
# left_point_3 = left_points_dilated[97:124, 8:33].copy()
#
# right_points_dilted = cv2.dilate(right_points, kernel_1, iterations=2)
#
# right_point_1 = right_points_dilted[20:38, 13:36].copy()
# right_point_2 = right_points_dilted[56:74, 21:41].copy()
# right_point_3 = right_points_dilted[95:112, 25:49].copy()
#
# double_dot_lower = thresh1[99:126, 275:307].copy()
# double_dot_upper = thresh1[40:65, 284:309].copy()
#
# border_size = 10
# bordered = cv2.copyMakeBorder(warped_dilated,
# top=border_size,
# bottom=border_size,
# left=border_size,
# right=border_size,
# borderType=cv2.BORDER_CONSTANT,
# value=[255, 255, 255])
#
# systolic_digits = bordered[22:162, 40:327].copy()
# diastolic_digits = bordered[162:304, 100:314].copy()
# heartrate = bordered[307:354, 225:311].copy()
#
# kernel_1 = np.ones((5, 5), np.uint8)
# systolic_digits_dil = cv2.dilate(systolic_digits, kernel_1, iterations=1)
# diastolic_digits_dil = cv2.dilate(diastolic_digits, kernel_1, iterations=1)
#
# kernel_2 = np.ones((3, 3), np.uint8)
# heartrate_dil = cv2.dilate(heartrate, kernel_2, iterations=1)
#
# systolic_digits_dil_bordered = cv2.copyMakeBorder(systolic_digits_dil,
# top=border_size,
# bottom=border_size,
# left=border_size,
# right=border_size,
# borderType=cv2.BORDER_CONSTANT,
# value=[255, 255, 255])
#
# diastolic_digits_dil_bordered = cv2.copyMakeBorder(diastolic_digits_dil,
# top=border_size,
# bottom=border_size,
# left=border_size,
# right=border_size,
# borderType=cv2.BORDER_CONSTANT,
# value=[255, 255, 255])
#
# heartrate_dil_bordered = cv2.copyMakeBorder(heartrate_dil,
# top=border_size,
# bottom=border_size,
# left=border_size,
# right=border_size,
# borderType=cv2.BORDER_CONSTANT,
# value=[255, 255, 255])
# feat_detect_rois = [double_dot_lower, double_dot_upper,
# left_point_2, left_point_3,
# right_point_1, right_point_2, right_point_3]
cv2.imshow("2", warped)
cv2.imshow("2", thresh1)
cv2.imshow("1", frame)
#cv2.imshow("1", double_dot_lower)
#cv2.imshow("2", double_dot_upper)
# cv2.imshow("1", warped_dilated)
cv2.imshow("1", warped)
#cv2.imshow("5", double_dot_upper)
cv2.waitKey(1)
......
......@@ -116,7 +116,6 @@ IDR alarm/radio
return feat_rois
def feat_detect_device_9(feat_rois):
"""
Schneider Microwave
......@@ -154,3 +153,13 @@ Bloodpressure
:return:
"""
return feat_rois
def feat_detect_device_7(feat_rois):
"""
BASETECH piggybank
:param feat_rois:
:return:
"""
return feat_rois
......@@ -455,3 +455,28 @@ Bloodpressure
return bordered
# Device ID 0
def image_device_13(img):
"""
BASETECH piggybank
:param img: the image to process
:return: the processed img
"""
gray = cv2.cvtColor(img.copy(), cv2.COLOR_BGR2GRAY)
height, width = gray.shape
pts1 = np.float32([[258, 45], [618, 47], [237, 197], [606, 206]])
pts2 = np.float32([[0, 0], [width, 0], [0, height], [width, height]])
m = cv2.getPerspectiveTransform(pts1, pts2)
warped = cv2.warpPerspective(gray, m, (width, height))
ret, thresh1 = cv2.threshold(warped, 55, 255, cv2.ADAPTIVE_THRESH_MEAN_C)
cv2.imshow("warped", warped)
cv2.imshow("thresh", thresh1)
cv2.waitKey(1)
return thresh1
\ No newline at end of file
......@@ -308,6 +308,23 @@ Bloodpressure
return results_processed
def process_results_device_13(rois_processed):
"""
Dummy Device
:param rois_processed:
:return:
"""
results_processed = None
digits = re.sub('[^0-9]', '', rois_processed[0][0].rstrip())
temp_result_pattern = re.compile("\d?\d")
return results_processed
def process_results_device_XX(rois_processed):
"""
......
......@@ -481,3 +481,14 @@ BEKO Dishwasher
traywash]
return [ocr_rois, feat_detect_rois]
def roi_device_13(img):
"""
BASETECH piggybank
:param img:
:return:
"""
ocr_rois = [img]
feat_detect_rois = []
return [ocr_rois, feat_detect_rois]
\ No newline at end of file
......@@ -245,3 +245,20 @@ Bloodpressure
]
return [call_ssocr.multicall_ssocr(rois[0], device_ssocr_args), rois[1]]
def ssocr_device_13(rois):
"""
BASETECH piggybank
:param rois:
:return: call of call_ssocr with the ssocr arguments matching the device
"""
device_ssocr_args = [
"-D",
"-r", "7",
"-d", "-1",
"-C",
"-c", "digits"
]
return [call_ssocr.multicall_ssocr(rois[0], device_ssocr_args), rois[1]]
Markdown is supported
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