# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/Mastemace/GZAPV_2021/blob/main/P20040/gzapv_05_video.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + id="BM3Y23HObqBr"
import cv2 as cv
from google.colab.patches import cv2_imshow

# + colab={"base_uri": "https://localhost:8080/"} id="L3eei3ihbIS-" outputId="c8382ee3-8a61-4fa2-fb5d-a5062cf3a1c3"
handler = cv.VideoCapture('face.mp4')
chleba = cv.CascadeClassifier('haarcascade_frontalface_default.xml')
out = cv.VideoWriter('video.mp4', cv.VideoWriter_fourcc(*'mp4v'), 25, (1704, 1066))
obliceje_ano = 0
celkem = 0

while(True):
  ret, frame = handler.read()
  if ret==False: break
  obliceje = chleba.detectMultiScale(frame, 1.3, 5)
  if len(obliceje) > 0: obliceje_ano += 1
  celkem += 1
  for (x,y,w,h) in obliceje:
    cv.rectangle(frame, (x,y), (x+w,y+h), (0, 255, 0), 3)
  
out.release()
print(obliceje_ano, ' z ', celkem)

StarcoderdataJupyterScriptsDedupFiltered