码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • [Python]黑色背景白色块滑动视频


    黑色背景白色块滑动视频,单帧效果如下:
    在这里插入图片描述

    配置参数

    1920 1080 400 400 300 60 1920x1080.avi

    import numpy as np
    import cv2 as cv
    import os
    import sys
    
    width = 1920
    height = 1080
    rect_szx = 400
    rect_szy = 300
    sz_y_init = 400
    fps = 24
    
    width = int(sys.argv[1])
    height = int(sys.argv[2])
    sz_y_init = int(sys.argv[3])
    rect_szx = int(sys.argv[4])
    rect_szy = int(sys.argv[5])
    fps = int(sys.argv[6])
    file_name = sys.argv[7]
    
    # 创建指定宽高、3通道、像素值都为0的图像
    img = np.zeros((height, width, 3), np.uint8)
    st_x = 0
    st_y = 0
    sz_x = 0
    sz_y = 0
    videoWriter = cv.VideoWriter(file_name, cv.VideoWriter_fourcc('X', 'V', 'I', 'D'), fps, (width, height))
    
    for j in range(0, 5):
        for i in range(0, width + rect_szx, 20):
            if i < rect_szx:
                st_x = 0
                st_y = sz_y_init
                sz_x = i
                sz_y = rect_szy
            if i >= rect_szx and i < width:
                st_x = i - rect_szx
                st_y = sz_y_init
                sz_x = rect_szx
                sz_y = rect_szy
            if i >= width and i < width + rect_szx:
                st_x = i - rect_szx
                st_y = sz_y_init
                sz_x = width - st_x
                sz_y = rect_szy
            # print(st_x, ":", (st_x + sz_x))
            # print(st_y, ":", (st_y + sz_y))
            img_dst = img.copy()
            img_dst[st_y : (st_y + sz_y),st_x : (st_x + sz_x),0] = 255
            img_dst[st_y : (st_y + sz_y),st_x : (st_x + sz_x),1] = 255
            img_dst[st_y : (st_y + sz_y),st_x : (st_x + sz_x),2] = 255
    
            videoWriter.write(img_dst)
            # cv.imwrite("test.jpg", img_dst)
    
            # cv.imshow("black", img_dst)
            # cv.waitKey(30)
            # cv.destroyAllWindows()
        videoWriter.write(img)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
  • 相关阅读:
    mysql中的str_to_date 函数
    stm32(GD32,apm32),开优化后需要特别注意的地方
    Java面试题-Java核心基础-第一天(基础概念与常识)
    防汛救援便携式应急通信系统解决方案
    SpringBoot项目入门: IDEA 创建SpringBoot项目
    Linux 抓包还不会?这篇文章赶紧收藏
    Java面试题大全带答案
    典型海洋环境观测数据产品应用现状及对我国的启示
    企业电子招标采购系统源码Spring Boot + Mybatis + Redis + Layui + 前后端分离 构建企业电子招采平台之立项流程图
    mac上的yolo
  • 原文地址:https://blog.csdn.net/w_weixiaotao/article/details/133814770
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号