PDA

View Full Version : why is QCameraImageCapture always not ready windows 7?



josentop
24th July 2014, 14:07
When I use QCamera and QCameraImageCapture to take image, I can get the picture in Camera's viewfinder, but can't take image due to QCameraImageCapture's isReadyForCapture always return false. Please see my code pice:
......
QList<QByteArray> cameraDevice = QCamera::availableDevices();
camera = new QCamera(cameraDevice[1]);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->setViewfinder(imageCap);
camera->start();

imageCapture = new QCameraImageCapture(camera);
imageCapture->setCaptureDestination(QCameraImageCapture::Capture ToBuffer);
......
if (!imageCapture->isAvailable())
{
qDebug() << "QCameraImageCapture isn't available!";
return;
}

camera->searchAndLock();
if (camera->state() == QCamera::ActiveState)
{
if (imageCapture->isReadyForCapture())
{
imageCapture->capture();
testLog->append(tr("image captured!"));
}
else
{
s = tr("QCameraImageCapture is ") + imageCapture->errorString();
testLog->append(s);
}
}
else testLog->append(tr("Camera isn't at ActiveState!"));

camera->unlock();
........

The code worked well in OSX, but can't work in window7.
Any one can help? thanks

d_stranz
24th July 2014, 17:24
camera = new QCamera(cameraDevice[1]);

Do you want the first camera? That will be this one:


camera = new QCamera(cameraDevice[0]);

Do you have more than one camera on your PC? The QCamera instance you are creating using cameraDevice[1] is probably invalid, which is why it is never ready for capture.

josentop
27th July 2014, 17:14
I tried your suggestion but it is worse than cameraDevice[1] due to viewfinder became black. When use cameraDevice[1], viewfinder can output monitor video.