A camera problem.
-
@jenya7 said in A camera problem.:
and I get the same exception on
viewfinderPage = new QWidget();You get same crash if you instanciate a QWidget?
Then something is really broken in your setup.
Can you build and execute a simple Qt widget application?@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
and I get the same exception on
viewfinderPage = new QWidget();You get same crash if you instanciate a QWidget?
Then something is really broken in your setup.
Can you build and execute a simple Qt widget application?actually viewfinderPage is null pointed. I have to create it. I'll try.
-
well...I added in a main window
QCameraViewfinder *m_viewfinder = new QCameraViewfinder(this);
and then in camera class
camera->setViewfinder(m_viewfinder );
But still get the message - "Image Capture Error: Camera not ready"
I get it on
m_imageCapture->capture();
When I try to go into capture() - I can't - the source unavailable, can not debug it to see why m_imageCapture decides the camera isn't ready. -
According to https://doc.qt.io/qt-5/qcamera.html#State-enum :
In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.
So capture should not be called right after start.
After calling start, you should asynchronously wait until the state turns to Active before performing any capturing. -
According to https://doc.qt.io/qt-5/qcamera.html#State-enum :
In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.
So capture should not be called right after start.
After calling start, you should asynchronously wait until the state turns to Active before performing any capturing.@Bonnie said in A camera problem.:
According to https://doc.qt.io/qt-5/qcamera.html#State-enum :
In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.
So capture should not be called right after start.
After calling start, you should asynchronously wait until the state turns to Active before performing any capturing.so I did
void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); while (m_imageCapture->isReadyForCapture() == false) ; m_isCapturingImage = true; m_imageCapture->capture(); m_camera->unlock(); }
it's never ready. never gets out of while.
-
Hi,
Your tight loop does not allow Qt's event loop to run. You should either use an event loop to "block" the execution or properly implement this through signals and slots.
-
Hi,
Your tight loop does not allow Qt's event loop to run. You should either use an event loop to "block" the execution or properly implement this through signals and slots.
@SGaist said in A camera problem.:
Hi,
Your tight loop does not allow Qt's event loop to run. You should either use an event loop to "block" the execution or properly implement this through signals and slots.
OK. Did so
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture); void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); // while (m_imageCapture->isReadyForCapture() == false) ; //m_isCapturingImage = true; //m_imageCapture->capture(); //m_camera->unlock(); } void Camera::IsReadyForCapture() { m_isCapturingImage = true; m_imageCapture->capture(); m_camera->unlock(); }
It never happens.
-
@SGaist said in A camera problem.:
Hi,
Your tight loop does not allow Qt's event loop to run. You should either use an event loop to "block" the execution or properly implement this through signals and slots.
OK. Did so
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture); void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); // while (m_imageCapture->isReadyForCapture() == false) ; //m_isCapturingImage = true; //m_imageCapture->capture(); //m_camera->unlock(); } void Camera::IsReadyForCapture() { m_isCapturingImage = true; m_imageCapture->capture(); m_camera->unlock(); }
It never happens.
@jenya7 said in A camera problem.:
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture);
Did this go through without complaint? I am "surprised", as
QCameraImageCapture::isReadyForCapture()
is not a signal, would have thoughtconnect()
would barf on that.... Try using void QCameraImageCapture::readyForCaptureChanged(bool ready) signal? -
@jenya7 said in A camera problem.:
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture);
Did this go through without complaint? I am "surprised", as
QCameraImageCapture::isReadyForCapture()
is not a signal, would have thoughtconnect()
would barf on that.... Try using void QCameraImageCapture::readyForCaptureChanged(bool ready) signal?@JonB said in A camera problem.:
@jenya7 said in A camera problem.:
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture);
Did this go through without complaint? I am "surprised", as
QCameraImageCapture::isReadyForCapture()
is not a signal, would have thoughtconnect()
would barf on that.... Try using void QCameraImageCapture::readyForCaptureChanged(bool ready) signal?did so
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::ReadyForCaptureChanged); void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); } void Camera::ReadyForCaptureChanged(bool ready) { m_isCapturingImage = true; m_imageCapture->capture(); m_camera->unlock(); }
never get into ReadyForCaptureChanged
-
@JonB said in A camera problem.:
@jenya7 said in A camera problem.:
connect(m_imageCapture.data(), &QCameraImageCapture::isReadyForCapture, this, &Camera::IsReadyForCapture);
Did this go through without complaint? I am "surprised", as
QCameraImageCapture::isReadyForCapture()
is not a signal, would have thoughtconnect()
would barf on that.... Try using void QCameraImageCapture::readyForCaptureChanged(bool ready) signal?did so
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::ReadyForCaptureChanged); void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); } void Camera::ReadyForCaptureChanged(bool ready) { m_isCapturingImage = true; m_imageCapture->capture(); m_camera->unlock(); }
never get into ReadyForCaptureChanged
@jenya7 said in A camera problem.:
never get into ReadyForCaptureChanged
Sure? How did you verify that?
-
@jenya7 said in A camera problem.:
never get into ReadyForCaptureChanged
Sure? How did you verify that?
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
never get into ReadyForCaptureChanged
Sure? How did you verify that?
I set a break point inside. I see it goes into takeImage but never gets to ReadyForCaptureChanged
Now I don't get any errors but it prints
Starting camera without viewfinder available
Is it OK? -
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
never get into ReadyForCaptureChanged
Sure? How did you verify that?
I set a break point inside. I see it goes into takeImage but never gets to ReadyForCaptureChanged
Now I don't get any errors but it prints
Starting camera without viewfinder available
Is it OK? -
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
never get into ReadyForCaptureChanged
Sure? How did you verify that?
I set a break point inside. I see it goes into takeImage but never gets to ReadyForCaptureChanged
Now I don't get any errors but it prints
Starting camera without viewfinder available
Is it OK? -
@jenya7
maybe its a typical object lifetime problem.where does your
Camera
instance exist/live ? -
@J-Hilk said in A camera problem.:
@jenya7
maybe its a typical object lifetime problem.where does your
Camera
instance exist/live ?It's a global object. I call it's methods from a command line parser object.
-
@jenya7
Just to make sure, what happens in your code after you call yourtakeImage()
? Do you allow the main event loop to run, or do you have other code which does not?@JonB said in A camera problem.:
@jenya7
Just to make sure, what happens in your code after you call yourtakeImage()
? Do you allow the main event loop to run, or do you have other code which does not?well..I guess it's running, cause my command lines parser reacts and process my commands.
-
@J-Hilk said in A camera problem.:
@jenya7 soooo, inside main() ?
actually for debug purposes I instantiated it in other module - command line parser, but it's static and never goes out of scope.
-
static
thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.
@J-Hilk said in A camera problem.:
static
thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.
I mean it it's created without static attribute, but i's not locally allocated.
-
@J-Hilk said in A camera problem.:
static
thats actually forbidden, no QObject based object must be created before the QCoreApplication instance. Static objects will be created before the QCoreApplication instance.
I mean it it's created without static attribute, but i's not locally allocated.
-
If I only could drill down to the cause of
"Image Capture Error: Camera not ready"
What makes it not ready for m_imageCapture...@jenya7
I know nothing about cameras and captures, so no idea about causes. I will say your definition ofvoid Camera::ReadyForCaptureChanged(bool ready)
is wrong, since it does not examine theready
parameter value. But if you say it's never hit that is moot.