猫史档案馆


【Python作品分享】python5-4-6-4

用户:浮躁的月见草nCBZ浮躁的月见草nCBZ查看:0 回复:0 评论:0 创建时间:2022-12-31T12:10:45


【作品展示】

center_image

 

【作品介绍】

寻找小球轨迹

 

【作品源代码】

import numpy as np
import cv2
cap = cv2.VideoCapture('ball.mp4')
ret,frame = cap.read()

background = frame.copy()

path = np.zeros(background.shape,dtype=np.uint8)

height,width = background.shape[0],background.shape[1]
while ret:
    diff = abs(frame - background)
    choices = diff > 20
    for h_idx in range(height):
        for w_idx in range(width):
            if all(choices[h_idx,w_idx]):
                path[h_idx,w_idx] = [255,255,255]
    cv2.imshow('path',path)
    ret,frame = cap.read()
    if cv2.waitKey(10) == ord('q'):
        break
cv2.waitKey(0)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页