人生如白驹过隙,忽然而已|

云鲸啊

园龄:3年5个月粉丝:5关注:4

opencv笔记-1

演示代码:

import cv2
import pylab
import matplotlib.pyplot as plt
import numpy
#导入对应的包
cap = cv2.VideoCapture(0)#取得对应的摄像头,里面的数字表示不同的设备
fourcc = cv2.VideoWriter_fourcc(*'mp4v')#采用mp4方式才存储,为"m","p","4","v"
vw = cv2.VideoWriter('output.mp4', fourcc, 30, (1920, 1080))# outmp4是文件名字,fourcc是对应方式,30是帧速,1920 1080是分辨率
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        print('can not recive frame,Exiting')
        break
    vw.write(frame)
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
cap = cv2.VideoCapture('F://python//movies//1.mp4')     # 读取视频
fps = int(cap.get(cv2.CAP_PROP_FPS))
size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))-100, int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)))
print(fps, size)
while cap.isOpened():               # 当视频被打开时:
    ret, frame = cap.read()         # 读取视频,读取到的某一帧存储到frame,若是读取成功,ret为True,反之为False
    if ret:                         # 若是读取成功
        cv2.namedWindow('frame', cv2.WINDOW_NORMAL)
        cv2.resizeWindow('frame', size)
        cv2.imshow('frame', frame)  # 显示读取到的这一帧画面
        key = cv2.waitKey(fps)       # 等待一段时间,并且检测键盘输入
        if key == ord('q'):         # 若是键盘输入'q',则退出,释放视频
            cap.release()           # 释放视频
            break
    else:
        cap.release()
cv2.destroyAllWindows()             # 关闭所有窗口
cv2.namedWindow('video', cv2.WINDOW_NORMAL)
cv2.resizeWindow('video', 500, 500)
cap = cv2.VideoCapture('F://python//movies//1.mp4')
fps = int(cap.get(cv2.CAP_PROP_FPS))
size = (int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)),int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))
print('帧速率:', fps)# 帧速率: 30
print('大小:', size) # 大小: (512, 512)
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break
    cv2.imshow('video', frame)
    key = cv2.waitKey(0)
    if key == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
img = cv2.imread(r'1.jpg')
while True:
    cv2.imshow('img', img)
    key = cv2.waitKey(0)
    if key == ord('q'):
        break
    elif key == ord('s'):
        cv2.imwrite('./123.png', img)
cv2.destroyAllWindows()
cv2.namedWindow("new", cv2.WINDOW_NORMAL)
cv2.resizeWindow('new', 1920, 1080)
cv2.imshow('new', 0)
key = cv2.waitKey(0)
while key != ord('q'):
    key = cv2.waitKey(0)
if key == ord('q'):
    print(123)
    cv2.destroyAllWindows()

imageimage

本文作者:云鲸啊

本文链接:https://www.cnblogs.com/yunjing/p/16650765.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   云鲸啊  阅读(18)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 ocean eyes bili
ocean eyes - bili
00:00 / 00:00
An audio error has occurred.

作词 : Finneas O'Connell

作曲 : Finneas O'Connell

I've been watching you

For some time

Can't stop staring

At those ocean eye

Burning cities

And napalm skies

Fifteen flares inside those ocean eyes

Your ocean eyes

No fair

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

I've been walking through

A world gone blind

Can't stop thinking of your diamond mind

Can't stop thinking of your diamond mind

Careful creature

Careful creature

Made friends with time

He left her lonely with a diamond mind

He left her lonely with a diamond mind

And those ocean eyes

And those ocean eyes

No fair

You really know how to make me cry

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I've never fallen from quite this high

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

Those ocean eyes

No fair

No fair

You really know how to make me cry

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I'm scared

I've never fallen from quite this high

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

Those ocean eyes