Skip to content

Commit

Permalink
Update take-screenshot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
IlNonoP authored Aug 29, 2024
1 parent cab272e commit 6d0556c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Source/take-screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
import pytesseract
from datetime import datetime

#set data from LibreRecall.conf
file_config = open('LibreRecall.conf', 'r')
data_config = file_config.readlines()
image_directory = data_config[2].split('"', 1)[1]
image_directory = image_directory.split('"', 1)[0]
print(image_directory)


os.makedirs(os.path.dirname("static/images/"), exist_ok=True)
os.makedirs(os.path.dirname(image_directory), exist_ok=True)



os.system('while xset q | grep -q "Monitor is Off"; do sleep 1; done') #solo se è sbloccato

# Esegui lo screenshot
os.system("flameshot full --path static/images --delay 0")
# Esegui lo screenshot
comando = "flameshot full --path {} --delay 0".format(image_directory)
os.system(comando)



# OCR dell'immagine catturata
image_path = 'static/images/screen.png'
image_path = '{}/screen.png'.format(image_directory)
ocr_text = pytesseract.image_to_string(Image.open(image_path))
ocr_text = ocr_text.lower()
# print(ocr_text)
Expand All @@ -28,8 +35,8 @@
name_txt = f"{timestamp}.txt"

# Rinomina lo screenshot catturato
os.system(f"mv {image_path} static/images/{name_png}")
os.system(f"mv {image_path} {image_directory}/{name_png}")
# Scrivi il testo OCR su un file di testo
with open(f"static/images/{name_txt}", 'w') as file:
with open(f"{image_directory}{name_txt}", 'w') as file:
file.write(ocr_text)

0 comments on commit 6d0556c

Please sign in to comment.