Camera example problem
Hi everyone !
In the past few weeks i have attempted to modify the "camera" example in QT. My aim is to create a function which is activated when a button is clicked and it is used to take a series of photos in sequential order. Each photo must be divided by a precise interval of time. In order to do this i inserted the imageCapture->capture( "destination ") comand in a for cycle, the problem however is that the function only saves one photo (obviously each photo has a different name). Could anyone explain why, and how to save multiple pictures using a single function.
this is an example of the code (added to camera.cpp) :
camera->searchAndLock(); imageCapture->capture("destination\\Img"+QString::number(i)+".png"); camera->unlock(); // configureImageSettings(); if I add this function , taht it opens an an outside window, the camera takes multiple images, but i have to close the windows every time...but i don't konw why it work in this way }
Hi and welcome to devnet,
From a quick look at the QCameraImageCapture class, the capture call is generally asynchronous so you might be currently asking to capture to "quickly". You should maybe wait until imageSaved has been emitted before trying to capture again.
Hope it helps
Hi thank you very much !
I tried again, but without results.. this time I read this :
It's permissible to call capture() while the camera status is QCamera::ActiveStatus regardless of isReadyForCapture property value.
So i checked my camera status..and it is all the time set to QCamera::UnavailableStatus..I thought it was the reason of my problem...
You should also check QCamera's errorString value
I tryed in a different way and it works..finally :D Thank you very much !!!
this is the code :
int foto=8;//number of pictures
if(Nf==foto)break; camera->searchAndLock(); Im=ui->viewfinder->grab().toImage(); Im.save("destination\\Img"+QString::number(Nf)+".png"); camera->unlock(); Nf++;
delay();// personal function
While working, I'm not sure you are getting the full-scale image