Как создать второе окно на том же видео с Google Colab - PullRequest
0 голосов
/ 30 октября 2019

Я работаю над проектом, связанным с обнаружением лиц в Google Colab. Я загрузил видео в мой Colab, и он обнаружил все лица. Но я хочу обрезать все лица и показать их во втором окне, но в том же видео. Вот код, который нужно загрузить и обнаружить лица в видео:

# An array to hold the locations of faces that are detected on individual frames
face_locations = []

# A counter to keep track of the number of frames processed
count = 1

# Loop through all the frames in the video
while True:
  # Read the video to retrieve individual frames. 'frame' will reference the inidivdual frames read from the video.
  ret, frame = input_video.read()

  # Check the 'ret' (return value) to see if we have read all the frames in the video to exit the loop
  if not ret:
    print('Processed all frames')
    break

  # Convert the image (frame) to RGB format as by default Open CV uses BGR format. 
  # This conversion is done as face_recognition and other libraries usually use RGB format.
  rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

  # Get the coordinates in the image where a face is detected. Use the model 'cnn' after greater accuracy.
  face_locations = face_recognition.face_locations(rgb_frame, model='cnn')

  # Loop through the face locations array and draw a rectangle around each face that is detected in the frame
  for top, right, bottom, left in face_locations:
    cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)

  # Write the frame to the output vide0
  video_writer.write(frame)
  video_writer.write(face)

  #video_writer.write(face)

  # Print for every 50 frames processed
  if(count % 50 == 0):
    print('Processed', count, 'frames')

  count += 1

# Release to close all the resources that we have opened for reading and writing video
input_video.release()
video_writer.release()
cv2.destroyAllWindows()```

Can anyone help me please.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...