A camera problem.
-
@JonB said in A camera problem.:
@jenya7
What is "not physically allocated", and why do you get an exception on what?There is a basic example at https://doc.qt.io/qt-5/qcameraviewfinder.html
Did you test whether just this code might work for you?You also ought check those
m_camera->isCaptureModeSupported(...)
I mentioned, else you are whistling in the wind....bool supported = m_camera->isCaptureModeSupported(QCamera::CaptureStillImage);
Yes. It's supported.
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
Is it normal? -
@jenya7
OK, but why not try the example from the docs, in a standalone test program? Not going to say it again..... -
@JonB said in A camera problem.:
@jenya7
OK, but why not try the example from the docs, in a standalone test program? Not going to say it again.....It runs on Windows machine. Have to arrange some camera....
-
@jenya7 said in A camera problem.:
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
Where do you see it and where do you create camera object? Can you please post relevant code?
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
Where do you see it and where do you create camera object? Can you please post relevant code?
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
This way it works without errorsQCameraViewfinder *v_finder; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { v_finder = new QCameraViewfinder(this); v_finder->show(); ui->setupUi(this); ui->textEditTerminalTx->installEventFilter(this); } void Camera::setCamera(const QCameraInfo &cameraInfo) { //........................ m_camera->setViewfinder(v_finder); //............................ }
Is it OK?
-
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
Where do you see it and where do you create camera object? Can you please post relevant code?
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
This way it works without errorsQCameraViewfinder *v_finder; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { v_finder = new QCameraViewfinder(this); v_finder->show(); ui->setupUi(this); ui->textEditTerminalTx->installEventFilter(this); } void Camera::setCamera(const QCameraInfo &cameraInfo) { //........................ m_camera->setViewfinder(v_finder); //............................ }
Is it OK?
@jenya7 said in A camera problem.:
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
And what was the result?!
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
At the time your
Camera::setCamera()
is called, hasv_finder = new QCameraViewfinder(this);
been executed yet? If not thenv_finder
inm_camera->setViewfinder(v_finder)
will benullptr
.... -
@jenya7 said in A camera problem.:
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
And what was the result?!
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
At the time your
Camera::setCamera()
is called, hasv_finder = new QCameraViewfinder(this);
been executed yet? If not thenv_finder
inm_camera->setViewfinder(v_finder)
will benullptr
....@JonB said in A camera problem.:
@jenya7 said in A camera problem.:
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
And what was the result?!
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
At the time your
Camera::setCamera()
is called, hasv_finder = new QCameraViewfinder(this);
been executed yet? If not thenv_finder
inm_camera->setViewfinder(v_finder)
will benullptr
....m_camera->setViewfinder(v_finder) is executed first
-
@JonB said in A camera problem.:
@jenya7 said in A camera problem.:
I put a break point in the MainWindow constructor and Camera constructor and see which hits the first.
And what was the result?!
I see the Camera object is created before MainWindow::MainWindow(QWidget *parent) constructor.
At the time your
Camera::setCamera()
is called, hasv_finder = new QCameraViewfinder(this);
been executed yet? If not thenv_finder
inm_camera->setViewfinder(v_finder)
will benullptr
....m_camera->setViewfinder(v_finder) is executed first
-
@jenya7
Then obviously it is not the right place to putm_camera->setViewfinder(v_finder);
.... You cannot execute that line until bothm_camera
&v_finder
have been initialized, so move it somewhere suitable. -
It seems your code is largely based on the Camera Example; is that correct? Does that example work for you unmodified?
-
It seems your code is largely based on the Camera Example; is that correct? Does that example work for you unmodified?
@mchinand said in A camera problem.:
It seems your code is largely based on the Camera Example; is that correct? Does that example work for you unmodified?
It's a widget based example. I removed all widget related stuff cause I don't have all these controls for camera operating in my app. I control the camera with commands I type in a terminal.
-
@mchinand said in A camera problem.:
It seems your code is largely based on the Camera Example; is that correct? Does that example work for you unmodified?
It's a widget based example. I removed all widget related stuff cause I don't have all these controls for camera operating in my app. I control the camera with commands I type in a terminal.
-
@jenya7 Come on, the question is whether this example works with your camera or not! Can't you simply try that?
@jsulm said in A camera problem.:
@jenya7 Come on, the question is whether this example works with your camera or not! Can't you simply try that?
I'll try tomorrow. I have to get a camera.
well...in the original example I press on Capture Photo and it stays inactive forever.
-
How can I pass a default camera instance to use it later?
In camera.hclass Camera : public QMainWindow { Q_OBJECT public: Camera(); void Camera::setCamera(const QCameraInfo &cameraInfo); const QCameraInfo* default_camera; }
in camera.cpp in a constructor
if (cameraInfo == QCameraInfo::defaultCamera()) { default_camera = new QCameraInfo(cameraInfo ); videoDeviceAction->setChecked(true); }
in main.cpp
g_camera.SetCamera(g_camera.default_camera );
I get
error: reference to type 'const QCameraInfo' could not bind to an lvalue of type 'const QCameraInfo *' -
@jsulm said in A camera problem.:
@jenya7 Come on, the question is whether this example works with your camera or not! Can't you simply try that?
I'll try tomorrow. I have to get a camera.
well...in the original example I press on Capture Photo and it stays inactive forever.
@jenya7 said in A camera problem.:
I'll try tomorrow. I have to get a camera.
wait!
how do you expect the state to change to a ready for capture == true, when you have no camera connected that could be used ?
-
@jenya7 said in A camera problem.:
I'll try tomorrow. I have to get a camera.
wait!
how do you expect the state to change to a ready for capture == true, when you have no camera connected that could be used ?
@J-Hilk said in A camera problem.:
@jenya7 said in A camera problem.:
I'll try tomorrow. I have to get a camera.
wait!
how do you expect the state to change to a ready for capture == true, when you have no camera connected that could be used ?
It's connected. The constructor detects it - "dev/video0".
I just wonted to try the original example on Windows. my app is running on Linux.
-
@jenya7
Then obviously it is not the right place to putm_camera->setViewfinder(v_finder);
.... You cannot execute that line until bothm_camera
&v_finder
have been initialized, so move it somewhere suitable.@JonB said in A camera problem.:
@jenya7
Then obviously it is not the right place to putm_camera->setViewfinder(v_finder);
.... You cannot execute that line until bothm_camera
&v_finder
have been initialized, so move it somewhere suitable.I resolved the issue. Now I get
Ready for capture: true
But on takeImage
QWidget::paintEngine: Should no longer be called
CameraBin warning: "Resource busy or not available."