利用jupyter实现字幕识别
第一步:安装Tesseract
mac端在终端输入
brew install tesseract
第二步:按照间隔进行字幕抽帧识别
import pytesseract
import cv2
import numpy as np
from scipy import stats
import os
import matplotlib.pyplot as plt
if __name__=='__main__':
path="20210701.mp4"
print(path)
cap=cv2.VideoCapture(path)
frame_count=int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
print(frame_count)
i=0
while i<frame_count:
cap.set(cv2.CAP_PROP_POS_FRAMES, i)
_, frame = cap.read(i)
if i==48:
cv2.imwrite('20210701.jpg',frame)
shape = frame.shape
print(shape)
#cv2.imshow("Frame-1", frame[580:630, 10:1270])
#plt.imshow(frame)
#plt.axis("off")
#plt.show()
img=frame[630:680, 50:1270]
plt.imshow(img)
plt.axis("off")
p