Skip to content

Commit

Permalink
fix bugs for making folder
Browse files Browse the repository at this point in the history
  • Loading branch information
musimab committed Mar 28, 2022
1 parent bbe8dc0 commit 111a747
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
29 changes: 4 additions & 25 deletions extract_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ def ocrOutput(self, img, bbox):
if(self.ocr_method == "Tesseract"):
ocr_output = self.tesserctOcr(img, bbox)

elif (self.ocr_method == "Keras"):
ocr_output = self.kerasOcr(img, bbox)

elif (self.ocr_method == "Easy"):
ocr_output = self.easyOcr(img, bbox)

else:
print("Select Keras Easy or Tesseract")
print("Select Easy or Tesseract")
return

return ocr_output
Expand All @@ -93,6 +90,8 @@ def cropRoi(self, img, bbox):
crop_img = self.denoiseImage(crop_img)

self.crop_img.append(crop_img)
if not os.path.exists("outputs/target_crops/"):
os.makedirs("outputs/target_crops/")
crop_name = "outputs/target_crops/" + str(info) +".jpg"
plt.imsave(crop_name,crop_img)
self.crop_img_names.append(crop_name)
Expand Down Expand Up @@ -129,27 +128,7 @@ def tesserctOcr(self,img, bbox):

return TesseractOcrInfo

"""
def kerasOcr(self,img, bbox):
self.cropRoi(img, bbox)
images = [keras_ocr.tools.read(img) for img in self.crop_img_names]
prediction_groups = self.pipeline.recognize(images)
for info, img_region in zip(KerasOcrInfo, prediction_groups):
new_text = ""
if(len(img_region) == 1):
for text, box in img_region:
KerasOcrInfo[info] = text
else:
for text, box in img_region:
new_text = text + new_text
KerasOcrInfo[info] = new_text
return KerasOcrInfo
"""

def denoiseImage(self, img):
"""
if denoise is available make denosing
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def getBoxRegions(regions):
predicted_mask = model.predict(txt_heat_map)

orientation_angle = utlis.findOrientationofLines(predicted_mask.copy())
print("orientation_angle is ", orientation_angle)
print("Orientation of Tc ID Card is {} ".format(orientation_angle))

if ( abs(orientation_angle) > ORI_THRESH ):

print("absulute orientation_angle is greater than {}".format(ORI_THRESH) )
print("Absulute orientation_angle is greater than {}".format(ORI_THRESH) )

final_img = utlis.rotateImage(orientation_angle, final_img)

Expand Down

0 comments on commit 111a747

Please sign in to comment.