问题描述
我想知道是否可以使用"opencv"在v4l2设备上进行写操作.我会拍照,使用opencv的功能进行一些小的更改,然后将其发送到v4l2设备上.
I wanted to know if I can use "opencv" to write on a v4l2 device.I would take a picture, apply small changes with the features of opencv, and then send it on a v4l2 device.
我在网上搜索过,但是有很多关于如何从V4L2设备读取信息的示例,但是我对在v4l2上进行书写一无所知.
I searched on the web, but there are a lot of examples on how to read from a V4L2 device, but I found nothing about writing on v4l2.
有人可以帮助我吗?
推荐答案
这个问题已有8个月了,但是如果您仍然需要答案(我想您的操作系统是Linux):
The question is 8 month old, but if you still need an answer (I suppose your OS is Linux):
-
安装
v4l2 loopback
模块
1.1.加载并配置linux: i.e. modprobe.conf: options v4l2loopback video_nr=22,23
1.1. Load and configure it linux: i.e. modprobe.conf: options v4l2loopback video_nr=22,23
使用这样的C++/OpenCV
代码: gist
Use such C++/OpenCV
code: gist
2.1.使用ioctl()调用设置设备
2.1. Setup device using ioctl() call
2.2.将原始RGB数据写入此设备(即/dev/video23
)
2.2. Write raw RGB data to this device (i.e. /dev/video23
)
2.3.将其用作常规的v4l2设备(即网络摄像头或vlc v4l2:///dev/video23
)
2.3. Use it as regular v4l2 device (i.e. webcam or vlc v4l2:///dev/video23
)
更多:您可以将ffmpeg
与v4l2 loopback
结合使用:ffmpeg -f x11grab -r 12 -s 1920x1080 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 -vf 'scale=800:600' /dev/video22
more: You can use ffmpeg
with v4l2 loopback
:ffmpeg -f x11grab -r 12 -s 1920x1080 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 -vf 'scale=800:600' /dev/video22
这篇关于V4l2上的OpenCV输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!