• 实现两个视频同时播放,利用到opencv模块 (线程进程开启)


    (资源与代码同目录下即可不报错)
    # import cv2
    # import numpy
    # import shutil
    # import os
    # import time
    # from multiprocessing import Process
    # class MyProcess(Process):
    # def __init__(self,path,x,y):
    # self.path=path
    # self.x = x
    # self.y = y
    # super().__init__()
    # def run(self):
    # cap = cv2.VideoCapture(self.path)
    # while True:
    # ret, frame = cap.read()
    # print(ret, frame)
    # cv2.namedWindow("frame", 0)
    # cv2.moveWindow("frame",self.x,self.y)
    # cv2.resizeWindow("frame", 720, 405)
    # cv2.imshow('frame', frame)
    # if cv2.waitKey(1) and 0xFF == ord('q'):
    # break
    # cap.release()
    # if __name__ == '__main__':
    # for i in os.listdir(r'H:1-2铅笔视频1.1cp'):
    # p=os.path.join(r'H:1-2铅笔视频1.1cp',i)
    # # print(p)
    # p1=p.replace('cp','fp')
    # # print(p1)
    # shutil.copy2(p,r'C:UserslenovoDesktop1.mp4')
    # shutil.copy2(p1,r'C:UserslenovoDesktop2.mp4')
    # time.sleep(1)
    # t = MyProcess(r'C:UserslenovoDesktop1.mp4',0,0)
    # t1 =MyProcess(r'C:UserslenovoDesktop2.mp4',0,500)
    # t.start()
    # t1.start()
    # t.join()
    # t1.join()
    # os.remove(r'C:UserslenovoDesktop1.mp4')
    # os.remove(r'C:UserslenovoDesktop2.mp4')
    # time.sleep(5)

    # import cv2
    # import numpy
    # import shutil
    # import os
    # import time
    # from threading import Thread
    # def func(path,x,y,name):
    # cap = cv2.VideoCapture(path)
    # while True:
    # ret, frame = cap.read()
    # # print(ret, frame)
    # cv2.namedWindow(name, 0)
    # cv2.moveWindow(name,x,y)
    # cv2.resizeWindow(name, 720, 405)
    # cv2.imshow(name, frame)
    # if cv2.waitKey(1) and 0xFF == ord('q'):
    # break
    # cap.release()
    # # p=input('输入路径')
    # for i in os.listdir(r'H:1-2铅笔视频1.1cp'):
    # p=os.path.join(r'H:1-2铅笔视频1.1cp',i)
    # # print(p)
    # p1=p.replace('cp','fp')
    # # print(p1)
    # shutil.copy2(p,r'C:UserslenovoDesktop1.mp4')
    # shutil.copy2(p1,r'C:UserslenovoDesktop2.mp4')
    # time.sleep(1)
    # t = Thread(target=func,args=(r'C:UserslenovoDesktop1.mp4',0,0,'frame'))
    # t1 = Thread(target=func,args=(r'C:UserslenovoDesktop2.mp4',0,500,'frame1'))
    # t.start()
    # t1.start()
    # t.join()
    # t1.join()
    # os.remove(r'C:UserslenovoDesktop1.mp4')
    # os.remove(r'C:UserslenovoDesktop2.mp4')
    # time.sleep(5)


    # import cv2
    # import numpy
    # import shutil
    # import os
    # import time
    # from threading import Thread
    # class MyThread(Thread):
    # def __init__(self,path,x,y,names):
    # self.path=path
    # self.x = x
    # self.y = y
    # self.names = names
    # super().__init__()
    # def run(self):
    # cap = cv2.VideoCapture(self.path)
    # while True:
    # ret, frame = cap.read()
    # # print(ret, frame)
    # cv2.namedWindow(self.name, 0)
    # cv2.moveWindow(self.name,self.x,self.y)
    # cv2.resizeWindow(self.name, 720, 405)
    # cv2.imshow(self.name, frame)
    # if cv2.waitKey(1) and 0xFF == ord('q'):
    # break
    # cap.release()
    # for i in os.listdir(r'H:1-2铅笔视频1.1cp'):
    # p=os.path.join(r'H:1-2铅笔视频1.1cp',i)
    # # print(p)
    # p1=p.replace('cp','fp')
    # # print(p1)
    # shutil.copy2(p,r'C:UserslenovoDesktop1.mp4')
    # shutil.copy2(p1,r'C:UserslenovoDesktop2.mp4')
    # time.sleep(1)
    # t = MyThread(r'C:UserslenovoDesktop1.mp4',0,0,'frame')
    # t1 =MyThread(r'C:UserslenovoDesktop2.mp4',0,500,'frame1')
    # t.start()
    # t1.start()
    # t.join()
    # t1.join()
    # os.remove(r'C:UserslenovoDesktop1.mp4')
    # os.remove(r'C:UserslenovoDesktop2.mp4')
    # time.sleep(5)
  • 相关阅读:
    MSIL实用指南-一维数组的操作
    MSIL实用指南-给字段、属性、方法、类、程序集加Attribute
    MSIL实用指南-比较运算
    MSIL实用指南-逻辑运算
    MSIL实用指南-位运算
    MSIL实用指南-数学运算
    MSIL实用指南-创建对象
    MSIL实用指南-装箱拆箱
    MSIL实用指南-生成构造函数
    K8S从入门到放弃系列-(5)kubernetes集群之kube-apiserver部署
  • 原文地址:https://www.cnblogs.com/diracy/p/13745891.html
Copyright © 2020-2023  润新知