Unsolved Need help with QCameraImageCature
-
Hallo
I try to capture some images with QCameraImageCapture.
It works, but how can i change QCameraImageCapture readytocapture?QObject::connect(m_cap, &QCameraImageCapture::imageCaptured, [=] (int id, QImage img) { Q_UNUSED(id); processImage(addPixmap(QPixmap::fromImage(img))); m_camera->unlock(); }); QObject::connect(m_cap, &QCameraImageCapture::readyForCaptureChanged, [=] (bool state) { qInfo() << "Image state: " << state; if(state == true) { m_camera->searchAndLock(); m_cap->capture(); m_camera->unlock(); } });
This works only for one time after start. How can i change this to run into a loop?
lg Chris
-
Hi,
You can use a QTimer to call your capturing method at regular interval.
-
@SGaist
I try it that way. :) But is it right that the readyForCaptureChanged signal fired once?
When do readyForCaptureChange will fired? Only after camera start and capture become ready?Now i capture after every imageCaptured and check if its ok. Is that also a right way?
QObject::connect(m_cap, &QCameraImageCapture::imageCaptured, [=] (int id, QImage img) { Q_UNUSED(id); QString x = qzx->decodeImage(img); // m_scene->addPixmap(QPixmap::fromImage(img)); if (x.isEmpty()) { if (m_cap->isReadyForCapture()) { m_camera->searchAndLock(); m_cap->capture(); m_camera->unlock(); } } else { ui->textEdit->setText(x); m_scene->addPixmap(QPixmap::fromImage(qzx->encodeData(x))); emit finishedCapture(); } });
It works fine under Linux, but not under Windows. Do you know wich dlls i need?
-
AFAIK, it's normal. It should represent the state of readiness to capture from the camera. Therefore, as long as "nothing changes", the state will not change.
The backends are different between platforms. So some might react a bit differently.
-
@SGaist
Thanks.
Nie i install QTCreator die Windows. I can see that the app crash at QCameraInfo::deviceList without any Message . So i remove the line.
Now it start and the camera light goes on. But the viewfinder will be black.
Is there a better way to use a camera with QT wich worked in Linux, Mac and Windows?LG chris
-
What version of Qt are you using ?
What camera is that ?We have to determine what is going on on your machine.
-
@SGaist
Currently Test
with QT5.11 Linux worked
With QT5.12 Windows 10 black viewfinder real Hardware and Box. Both the same black viewfinder.Camera USB 2.0 Generic one in My Linux Laptop MSI i7 here also run Windows 10 in the VBox
One in my Windows 10 Laptop HPI dont know what Hardware the use.
The oldest QT is 5.6 from ubuntu 16.04. Not testet now.LG chris
-
Does 5.11 work on Windows ?