QML调用android摄像头,Qt QML Camera to C++ QImage on Android

本文介绍了两种在Qt QML中调用Android摄像头的方法。第一种是使用QAbstractVideoFilter和QVideoFilterRunnable,但不适用于实时应用,因为需要从OpenGL纹理读取数据。第二种方法是利用QVideoProbe,直接在C++侧处理QVideoFrame,适合实时需求。通过QML与C++交互,可以获取并处理摄像头的原始图像数据,但无法将处理后的帧返回到QML展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1) Yes, it is possible. I´ve come around two ways to do it.

Using QAbstractVideoFilter alongside with QVideoFilterRunnable classes (QT 5.5 only! ) which are plain great. They were developed specifically for this case scenario, and are pretty easy to use.

There are a few good examples on the web using it:

The downside to this approach is, like was said here , is that on Android devices the QVideoFrame pointer doesnt has raw pixel data, instead, it has an OpenGL Texture which need to be read back (the second example I posted has a workaround solving this), thus making this approach not realy good for real time purposes IMHO.

What I ended up using to solve this problem was the QVideoProbe class.

First you have to name the instance of your QML camera:

Camera {

id: camera

objectName: "qrCameraQML"

}

Then you get this instance from C++ side, som

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值