Home › Forums › Fórum Reconhecimento de Textos com OCR e Python › OCR em videos usando o easyOCR, erro no while.
- This topic has 3 replies, 2 voices, and was last updated 11 months, 1 week ago by
Gabriel Alves.
- AuthorPosts
- 20 de September de 2021 at 12:33 #30840
CÓDIGO:
while (cv2.waitKey(1) < 0): conectado, frame = cap.read() if not conectado: break frame = cv2.resize(frame, (video_largura, video_altura)) imagem_cp = frame.copy() reader = Reader(idiomas, gpu=gpu) resultados = reader.readtext(frame) for (caixa, texto, prob) in resultados: te, td, bd, be = coord_caixa(caixa) frame = desenha_caixa(frame, te, bd) frame = fundo_texto(texto, te[0], te[1], frame, fonte, tam_fonte, cor_fundo) frame = escreve_texto(texto, te[0], te[1], frame, fonte, cor_fonte, tam_fonte) if amostra_atual <= amostras_exibir: cv2_imshow(frame) amostra_atual = amostra_atual + 1 saida_video.write(frame) print("Terminou") saida_video.release() cv2.destroyAllWindows() ERRO:
—————————————————————————
error Traceback (most recent call last)
<ipython-input-39-6d97edc97bc8> in <module>() ----> 1 while (cv2.waitKey(1) < 0): 2 conectado, frame = cap.read() 3 4 if not conectado: 5 break
error: OpenCV(4.5.3) /tmp/pip-req-build-fvfwe_ss/opencv/modules/highgui/src/window.cpp:1340: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function ‘cvWaitKey’
21 de September de 2021 at 08:49 #30844Olá Pedro,
Primeiro tente trocar o while (cv2.waitKey(1) < 0): por while (True):
e caso não rode como esperado coloque cv2.waitKey(1) acima de saida_video.write(frame)
Você está rodando direto na sua máquina isso? E seu sistema operacional é Windows? Esse problema pode ocorrer as vezes, se o problema ainda assim continuar a recomendação nesse caso é desinstalar o OpenCV e instalar novamente. Você pode fazer isso através do comando pip
pip uninstall opencv-python
pip install opencv-python
(ou opencv-contrib-python caso esteja usando a versão com +contrib)
Caso não funcione, utilize esses comandos:
pip uninstall opencv-python-headless -y
pip install opencv-python --upgrade
24 de September de 2021 at 12:42 #30917Fiz as alterações recomendadas e funcionou!!! Obrigado
15 de May de 2024 at 22:29 #44898Que ótimo saber que deu certo! Disponha
- AuthorPosts
- You must be logged in to reply to this topic.