1

According to the documentation, QCameraInfo::availableCameras should return list of available cameras. There's no catch to it according to the docs.

But still, I have two webcams and the array of available cameras is returned empty. What can I do? Is this even in the scope of programming, or does this mean Qt only supports limited subset of webcams?

The OS I'm using right now is Windows 7x64.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
  • Have you tried other software? – eyllanesc Mar 02 '17 at 23:18
  • Yes. I was actually dissatisfied with available timelapse applications so I'm writing my own. But multiple, though not all, programs worked with all my webcams. One webcam is currently used, other not used and available. – Tomáš Zato Mar 02 '17 at 23:20
  • Qt doesn't directly do much with webcams, it defers their handling to a multimedia framework - this might be a set of platform APIs, or a higher level framework. What Qt version are you using? – Kuba hasn't forgotten Monica Mar 03 '17 at 00:30
  • I use Qt 5.6.0. The webcam listing works in other nonQt applications. I made some experiments in javascript before diving in writing C++ application. – Tomáš Zato Mar 03 '17 at 00:39
  • If you disconnect one camera do you still get an empty array? – dtech Mar 03 '17 at 01:41
  • Just tested it, yes, the array is consistently empty. I will try it on another machine, but it seems that I simply overestimated Qt this time. – Tomáš Zato Mar 04 '17 at 01:14

3 Answers3

2

I have this Problem too.Then I read about the example. I found that once you have declared QCamera object.it will return the right info. Like this :`

QCamera *cam = new QCamera;
qDebug()<<QCameraInfo::availableCameras().count();`

I have one camera,so it returns 1 at last;

dayDream
  • 21
  • 2
  • It worked when I imported it for the first time in Python. Then it stopped working. `QCamera()` says "no service found for - "org.qt-project.qt.camera"" – Winand Nov 12 '18 at 21:29
  • oh... at first it worked because I tried it in the same IPython console as the following `opencv` example earlier https://stackoverflow.com/a/606154/1119602 – Winand Nov 12 '18 at 21:36
0

Try to copy the mediaservice plugin folder into your application dir (where the exe resides).

At least that solved this specific problem for me.

0

You need to resolve your dependencies (like Thomas D. mentioned). (take a look at http://doc.qt.io/qt-5/windows-deployment.html )

From yourpathof\Qt\...subdir...\bin

execute

windeployqt.exe --debug YOURPATH\Debug

or

windeployqt.exe YOURPATH\Debug