“Python membaca bingkai video” Kode Jawaban

Ekstrak bingkai dari Video Python

import cv2
video_name = "name.mp4" # or any other extension like .avi etc
vidcap = cv2.VideoCapture(video_name)
success,image = vidcap.read()
count = 0
while success:
  cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file      
  success,image = vidcap.read()
  print('Read a new frame: ', success)
  count += 1
MonsterBoy

Python membaca bingkai video

import cv2
vidcap = cv2.VideoCapture('Compton.mp4')
success,image = vidcap.read()
count = 0
success = True
while success:
  success,image = vidcap.read()
  cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file
  if cv2.waitKey(10) == 27:                     # exit if Escape is hit
      break
  count += 1
Red Team

cara menyimpan bingkai dalam bentuk video di opencv python

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        frame = cv2.flip(frame,0)


        out.write(frame)

        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break
cap.release()

out.release()

cv2.destroyAllWindows()
Annoying Albatross

Jawaban yang mirip dengan “Python membaca bingkai video”

Pertanyaan yang mirip dengan “Python membaca bingkai video”

Lebih banyak jawaban terkait untuk “Python membaca bingkai video” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya