From daaeaa0362a2092902f78d991bb966ed3fb74ee6 Mon Sep 17 00:00:00 2001 From: Emmanuel Prochasson Date: Tue, 31 Oct 2017 08:25:41 +0800 Subject: [PATCH] Don't crash on files with no Hough lines If no lines are detected, `detect_skew` returns `{"Image File": img_file, "Message": "Bad Quality"}`, which then crashes `deskew` as the key `Estimated Angle` can not be found. Simple fix to propose a default value. --- alyn/deskew.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alyn/deskew.py b/alyn/deskew.py index 029be4f..2c58c80 100755 --- a/alyn/deskew.py +++ b/alyn/deskew.py @@ -22,7 +22,7 @@ def deskew(self): img = io.imread(self.input_file) res = self.skew_obj.process_single_file() - angle = res['Estimated Angle'] + angle = res.get('Estimated Angle', 0) if angle >= 0 and angle <= 90: rot_angle = angle - 90 + self.r_angle