initial
This commit is contained in:
34
timestamp_frame.py
Normal file
34
timestamp_frame.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import cv2
|
||||
import pytesseract
|
||||
import re
|
||||
|
||||
pytesseract.pytesseract.tesseract_cmd = r'/usr/bin/tesseract'
|
||||
|
||||
def salva_frame(video_path):
|
||||
# Apri il video
|
||||
cap = cv2.VideoCapture(video_path)
|
||||
|
||||
# Controlla se il video è stato aperto correttamente
|
||||
if not cap.isOpened():
|
||||
print("Errore nell'apertura del video")
|
||||
return
|
||||
|
||||
while(cap.isOpened()):
|
||||
# Leggi un frame
|
||||
ret, frame = cap.read()
|
||||
|
||||
if not ret:
|
||||
break
|
||||
|
||||
text = pytesseract.image_to_string(frame)
|
||||
timestamp = re.search(r'\d{2}-\d{2}-\d{4}\s\d{2}:\d{2}:\d{2}', text)
|
||||
if timestamp:
|
||||
print(timestamp.group())
|
||||
break
|
||||
|
||||
# Rilascia il video capture
|
||||
cap.release()
|
||||
|
||||
# Esegui il programma
|
||||
video_path = "/home/alex/Scaricati/2024_08_11_14_55_26.MP4" # Sostituisci con il percorso del tuo video
|
||||
salva_frame(video_path)
|
||||
Reference in New Issue
Block a user