stebest

stebest

Nothing is difficult if you give it up
🏢  全栈/管理
V2EX 第 235786 号会员,加入于 2017-06-16 11:07:16 +08:00
根据 stebest 的设置,主题列表被隐藏
二手交易 相关的信息,包括已关闭的交易,不会被隐藏
stebest 最近回复了
45 天前
回复了 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()
```
45 天前
回复了 Haku 创建的主题 Python Python 中如何在内存中优雅地提取视频帧?
不过实际上还是会在本地创建文件,video capture 本身不支持直接从 memory 中读取,如果是自己控制数据流,用一个迭代器或者生成器把每一帧转 cv mat 就可以
45 天前
回复了 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.
45 天前
回复了 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)
45 天前
回复了 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 创建的主题 程序员 有没有简洁的博客主题推荐一下
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1002 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 19:14 · PVG 03:14 · LAX 12:14 · JFK 15:14
Developed with CodeLauncher
♥ Do have faith in what you're doing.