V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  stebest  ›  全部回复第 1 页 / 共 33 页
回复总数  655
1  2  3  4  5  6  7  8  9  10 ... 33  
47 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
如果还是希望用 opencv video capture 处理,1.可以将视频流使用虚拟摄像头输出,用 opencv 打开即可。
2.使用流媒体协议,opencv video capture 应该也直接支持。
3.使用 videogear 的 netgear ,一个比较简单的例子,具体可以去看文档
server end

```
# import required libraries
from vidgear.gears import VideoGear
from vidgear.gears import NetGear

# open any valid video stream(for e.g `test.mp4` file)
stream = VideoGear(source="test.mp4").start()

# Define Netgear Server with default parameters
server = NetGear()

# loop over until KeyBoard Interrupted
while True:

try:

# read frames from stream
frame = stream.read()

# check for frame if Nonetype
if frame is None:
break

# {do something with the frame here}

# send frame to server
server.send(frame)

except KeyboardInterrupt:
break

# safely close video stream
stream.stop()

# safely close server
server.close()
```

client end

```
# import required libraries
from vidgear.gears import NetGear
import cv2


# define Netgear Client with `receive_mode = True` and default parameter
client = NetGear(receive_mode=True)

# loop over
while True:

# receive frames from network
frame = client.recv()

# check for received frame if Nonetype
if frame is None:
break

# {do something with the frame here}

# Show output window
cv2.imshow("Output Frame", frame)

# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break

# close output window
cv2.destroyAllWindows()

# safely close client
client.close()
```
47 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
不过实际上还是会在本地创建文件,video capture 本身不支持直接从 memory 中读取,如果是自己控制数据流,用一个迭代器或者生成器把每一帧转 cv mat 就可以
47 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
@Haku 如果只是希望在内存中方便读取,使用 tmpfile import tempfile
import cv2

my_video_bytes = download_video_in_memory()

with tempfile.NamedTemporaryFile() as temp:
temp.write(my_video_bytes)

video_stream = cv2.VideoCapture(temp.name)

# do your stuff.
47 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
@stebest 挺简单的,给个示例吧 import numpy as np
import cv2 as cv
import io

image_stream = io.BytesIO()
image_stream.write(connection.read(image_len))
image_stream.seek(0)
file_bytes = np.asarray(bytearray(image_stream.read()), dtype=np.uint8)
img = cv.imdecode(file_bytes, cv.IMREAD_COLOR)
47 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
额,这个倒是跟视频没啥关系,不就是想用 bytesIO 嘛。
2022-09-27 10:50:06 +08:00
回复了 stebest 创建的主题 求职 虚拟人系统研发实习生招聘
@kizunai 不是 hh ,你有兴趣也可以做一个
2022-09-27 09:28:14 +08:00
回复了 stebest 创建的主题 求职 C++后台开发工程师招聘
@whi147 也有精通的人,不过确实,不用精通,但有能独立完成项目的能力
2021-03-25 15:01:29 +08:00
回复了 baifei 创建的主题 程序员 除了程序员,还有多少人做坚持写独立博客、原创博客?
荒废了一年,又重新买了域名准备开门了。
https://dfine.tech
2020-11-05 11:32:23 +08:00
回复了 lambdafate 创建的主题 程序员 有没有简洁的博客主题推荐一下
2020-09-29 16:28:15 +08:00
回复了 PlanZ 创建的主题 推广 中秋佳节,送六盒好吃的港版月饼!
分子子
2020-09-16 16:57:38 +08:00
回复了 stebest 创建的主题 C++ 关于 CMAKE 的链接库
@Huelse 大概明白了,谢谢
2020-09-16 16:53:23 +08:00
回复了 stebest 创建的主题 C++ 关于 CMAKE 的链接库
@Huelse 就是以前的代码生成的库,如果是动态的,然后你编译的时候需要调用,同时包含其头文件。然后生成的库被别人调用的时候也还是要包含你之前包含的头文件和链接库么?
2020-08-27 17:46:17 +08:00
回复了 calmzhu 创建的主题 程序员 在线代写各种 shell 小脚本:我就想看看都有哪些好玩的需求
@aheadlead xxd 命令直接转
2020-08-24 09:50:08 +08:00
回复了 bigbyto 创建的主题 程序员 改了下 gitalk,增加了匿名评论功能
这样就创建了很多无意义的僵尸号,是不是有点浪费资源。
利用 github 存储评论可以算正当使用,但这个不停的创建无意义的小号,就算滥用了吧?点匿名评论时候切换到别的评论系统,我觉得还是挺方便的,我自己也是这样,感觉效果还行。
2020-08-19 16:38:49 +08:00
回复了 KalaSearch 创建的主题 程序员 如何用 Gatsby 打造你的完美博客 - 初始设置秒开和一键部署
阁子
https://newdee.cf
个人博客
欢迎友链
2020-08-19 16:05:41 +08:00
回复了 stebest 创建的主题 FFmpeg 关于 FFmpeg 的问题
@lamy 确实是这个问题,谢谢,解决了
2020-08-18 17:18:00 +08:00
回复了 fox0001 创建的主题 Android 为什么 ADUI 这么难用,某米手机还是卖得那么好?
不明白这个帖子的意义 @livid
又是引战
2020-08-06 10:03:28 +08:00
回复了 Milicense 创建的主题 Podcast 求推荐你们的宝藏播客
还以为自荐博客,看了一下原来是眼花了
2020-07-17 10:13:10 +08:00
回复了 stebest 创建的主题 互联网 有没有什么办法
@xiaodingdang337 谢谢,昨天弄了很久已经解决了,都删掉了,,,虽然必须得下他们的 APP 才提供注销账户功能。。。
1  2  3  4  5  6  7  8  9  10 ... 33  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5476 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 45ms · UTC 01:34 · PVG 09:34 · LAX 18:34 · JFK 21:34
Developed with CodeLauncher
♥ Do have faith in what you're doing.