Сохранение двух управляемых видео с веб-камеры с использованием OpenCV - PullRequest
1 голос
/ 06 октября 2019

Я хотел бы сохранить два видео одновременно, используя python. как это YoloV2, Yolo 9000, SSD Mobilenet, более быстрое сравнение NasNet с RCNN , я не уверен, что он сохранил их одновременно или нет, вероятно, он использовал другую программу для их оценки.

Могу ли я сделать это с помощью Python?

это мой код, я сохранил два видео отдельно

import cv2
import numpy as np
from imutils.video import FPS
# capturing video through webcam
import time

fourcc = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G') #Define the codec and create VideoWriter object
fourcc1 = cv2.VideoWriter_fourcc('M', 'J', 'P', 'G') #Define the codec and create VideoWriter object
out = cv2.VideoWriter('colors.avi', fourcc, 20.0, (640, 480))
out1 = cv2.VideoWriter('colors1.avi', fourcc1, 20.0, (640, 480))
cap = cv2.VideoCapture(0)
#video dimension in python-opencv
width = cap.get(3)  # float
height = cap.get(4) # float
print width,height
time.sleep(2.0)
while(1):
    _, img = cap.read()
    if _ is True:
        hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    else:
        continue

    red_lower = np.array([136,87,111],np.uint8)
    red_upper = np.array([180,255,255],np.uint8)
    red = cv2.inRange(hsv, red_lower, red_upper)

    kernal = np.ones((5, 5), "uint8")

    red = cv2.dilate(red, kernal)
    res_red = cv2.bitwise_and(img, img, mask = red)

    (_, contours, hierarchy)=cv2.findContours(red, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    for pic, contour in enumerate(contours):
        area = cv2.contourArea(contour)
        if(area > 300):
            x, y, w, h = cv2.boundingRect(contour)
            img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
            cv2.putText(img, "Red Colour", (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255))


    out.write(res_red)
    out1.write(img)
    cv2.imshow("Color Tracking", img)
    cv2.imshow("Color Tracking1", res_red)
    if cv2.waitKey(10) & 0xFF == ord('q'):
        cap.release()
        cv2.destroyAllWindows()
        break

выход: два видео

enter image description here

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