A camera problem.
-
@jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.
-
@jsulm said in A camera problem.:
@jenya7 I think you will also need to install GStreamer plug-ins. On Linux Qt uses GStreamer for multimedia.
when I run
dpkg -l | grep gstreamer
I see gstreamer installed.@jenya7 said in A camera problem.:
I see gstreamer installed
What exactly is installed? There are many GStreamer plug-ins which may be needed.
-
@jenya7 said in A camera problem.:
I see gstreamer installed
What exactly is installed? There are many GStreamer plug-ins which may be needed.
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
I see gstreamer installed
What exactly is installed? There are many GStreamer plug-ins which may be needed.
this is the list
ii gstreamer1.0-alsa:armhf 1.14.4-2+deb10u1 armhf GStreamer plugin for ALSA ii gstreamer1.0-gtk3:armhf 1.14.4-1+rpt1+deb10u1 armhf GStreamer plugin for GTK+3 ii gstreamer1.0-libav:armhf 1.15.0.1+git20180723+db823502-2+deb10u1 armhf libav plugin for GStreamer ii gstreamer1.0-omx 1.14.4-1+rpt1 armhf GStreamer OpenMAX plugins ii gstreamer1.0-omx-rpi 1.14.4-1+rpt1 armhf OpenMax plugins for GStreamer ii gstreamer1.0-omx-rpi-config 1.14.4-1+rpt1 armhf OpenMax plugins for GStreamer ii gstreamer1.0-plugins-bad:armhf 1.14.4-1+rvt+deb10u2 armhf GStreamer plugins from the "bad" set ii gstreamer1.0-plugins-base:armhf 1.14.4-2+deb10u1 armhf GStreamer plugins from the "base" set ii gstreamer1.0-plugins-good:armhf 1.14.4-1+rpt1+deb10u1 armhf GStreamer plugins from the "good" set ii gstreamer1.0-x:armhf 1.14.4-2+deb10u1 armhf GStreamer plugins for X11 and Pango ii libgstreamer-gl1.0-0:armhf 1.14.4-2+deb10u1 armhf GStreamer GL libraries ii libgstreamer-plugins-bad1.0-0:armhf 1.14.4-1+rvt+deb10u2 armhf GStreamer libraries from the "bad" set ii libgstreamer-plugins-base1.0-0:armhf 1.14.4-2+deb10u1 armhf GStreamer libraries from the "base" set ii libgstreamer1.0-0:armhf 1.14.4-1 armhf Core GStreamer libraries and elements ii libreoffice-avmedia-backend-gstreamer 1:6.1.5-3+rpi1+deb10u7+rpt1 armhf GStreamer backend for LibreOffice
I really don't know if it's a complete list or a right version.
-
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
I see gstreamer installed
What exactly is installed? There are many GStreamer plug-ins which may be needed.
this is the list
ii gstreamer1.0-alsa:armhf 1.14.4-2+deb10u1 armhf GStreamer plugin for ALSA ii gstreamer1.0-gtk3:armhf 1.14.4-1+rpt1+deb10u1 armhf GStreamer plugin for GTK+3 ii gstreamer1.0-libav:armhf 1.15.0.1+git20180723+db823502-2+deb10u1 armhf libav plugin for GStreamer ii gstreamer1.0-omx 1.14.4-1+rpt1 armhf GStreamer OpenMAX plugins ii gstreamer1.0-omx-rpi 1.14.4-1+rpt1 armhf OpenMax plugins for GStreamer ii gstreamer1.0-omx-rpi-config 1.14.4-1+rpt1 armhf OpenMax plugins for GStreamer ii gstreamer1.0-plugins-bad:armhf 1.14.4-1+rvt+deb10u2 armhf GStreamer plugins from the "bad" set ii gstreamer1.0-plugins-base:armhf 1.14.4-2+deb10u1 armhf GStreamer plugins from the "base" set ii gstreamer1.0-plugins-good:armhf 1.14.4-1+rpt1+deb10u1 armhf GStreamer plugins from the "good" set ii gstreamer1.0-x:armhf 1.14.4-2+deb10u1 armhf GStreamer plugins for X11 and Pango ii libgstreamer-gl1.0-0:armhf 1.14.4-2+deb10u1 armhf GStreamer GL libraries ii libgstreamer-plugins-bad1.0-0:armhf 1.14.4-1+rvt+deb10u2 armhf GStreamer libraries from the "bad" set ii libgstreamer-plugins-base1.0-0:armhf 1.14.4-2+deb10u1 armhf GStreamer libraries from the "base" set ii libgstreamer1.0-0:armhf 1.14.4-1 armhf Core GStreamer libraries and elements ii libreoffice-avmedia-backend-gstreamer 1:6.1.5-3+rpi1+deb10u7+rpt1 armhf GStreamer backend for LibreOffice
I really don't know if it's a complete list or a right version.
@jenya7 said in A camera problem.:
or a right version
That depends on the Qt version you're using.
Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help. -
@jenya7 said in A camera problem.:
or a right version
That depends on the Qt version you're using.
Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
or a right version
That depends on the Qt version you're using.
Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.I found it out! It's not enough to install library
sudo apt-get install qtmultimedia5-dev
One should add plugins also
sudo apt-get install libqt5multimedia5-pluginsNow it founds the camera. But how do I refer to it later on? There are no fields like name or id or something
at least on debug levelavailableCameras <1 items> QList<QCameraInfo> [0] @0x1027c8 QCameraInfo d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int availableCameras@1 <optimized out> cameraInfo @0x1027c8 QCameraInfo & d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int cameraInfo@1 @0x1027c8 QCameraInfo & d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int QCameraInfo::defaultCamera() QCameraInfo d QSharedPointer<QCameraInfoPrivate> data @0x111438 QCameraInfoPrivate weakref 1 int strongref 1 int
-
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
or a right version
That depends on the Qt version you're using.
Try to also install gstreamer1.0-plugins-ugly, but I don't know whether this will help.I found it out! It's not enough to install library
sudo apt-get install qtmultimedia5-dev
One should add plugins also
sudo apt-get install libqt5multimedia5-pluginsNow it founds the camera. But how do I refer to it later on? There are no fields like name or id or something
at least on debug levelavailableCameras <1 items> QList<QCameraInfo> [0] @0x1027c8 QCameraInfo d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int availableCameras@1 <optimized out> cameraInfo @0x1027c8 QCameraInfo & d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int cameraInfo@1 @0x1027c8 QCameraInfo & d @0x1027c8 QSharedPointer<QCameraInfoPrivate> data @0x10cd88 QCameraInfoPrivate weakref 2 int strongref 2 int QCameraInfo::defaultCamera() QCameraInfo d QSharedPointer<QCameraInfoPrivate> data @0x111438 QCameraInfoPrivate weakref 1 int strongref 1 int
@jenya7 said in A camera problem.:
There are no fields like name or id or something
There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName
-
@jenya7 said in A camera problem.:
There are no fields like name or id or something
There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName
@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
There are no fields like name or id or something
There is: https://doc.qt.io/qt-5/qcamerainfo.html#deviceName
I see. Thank you. I'll try to get it going.
-
something eluding me
To take a shotvoid Camera::takeImage()
Then on
connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage);
void Camera::processCapturedImage(int requestId, const QImage& img) { Q_UNUSED(requestId); QImage scaledImage = 100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); ui->lastImagePreviewLabel->setPixmap(QPixmap::fromImage(scaledImage)); // Display captured image for 4 seconds. displayCapturedImage(); QTimer::singleShot(4000, this, &Camera::displayViewfinder); }
But where the image actually stored?
-
Hi,
Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.
-
Hi,
Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.
@SGaist said in A camera problem.:
Hi,
Unless you configure the capture to capture to file, its just going to be in the buffer. You can still save it yourself though.
How do I do that? I see m_imageCapture but no property or method to set a path to a file.
And where the buffer located? -
The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.
-
The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.
@SGaist said in A camera problem.:
The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.
After
g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage); g_camera.takeImage();
Nothing happens. I didn't get to
void Camera::processCapturedImage(int requestId, const QImage& img)
or
void Camera::imageSaved(int id, const QString &fileName)
How do I know where is the image (if it was taken at all)?
-
@SGaist said in A camera problem.:
The buffer just means it's in memory. You'll get a frame to process and then it's up to you to save it.
After
g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage); g_camera.takeImage();
Nothing happens. I didn't get to
void Camera::processCapturedImage(int requestId, const QImage& img)
or
void Camera::imageSaved(int id, const QString &fileName)
How do I know where is the image (if it was taken at all)?
@jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable -
@jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable@jsulm said in A camera problem.:
@jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailablethis is what I have
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture); connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage); connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved); connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error), this, &Camera::displayCaptureError);
-
@jsulm said in A camera problem.:
@jenya7 Did you connect a slot to https://doc.qt.io/qt-5/qcamera.html#errorOccurred to see whether you get any errors? Same for https://doc.qt.io/qt-5/qcameraimagecapture.html#error-1
You can get the cptured image using this signal: https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailablethis is what I have
connect(m_imageCapture.data(), &QCameraImageCapture::readyForCaptureChanged, this, &Camera::readyForCapture); connect(m_imageCapture.data(), &QCameraImageCapture::imageCaptured, this, &Camera::processCapturedImage); connect(m_imageCapture.data(), &QCameraImageCapture::imageSaved, this, &Camera::imageSaved); connect(m_imageCapture.data(), QOverload<int, QCameraImageCapture::Error, const QString &>::of(&QCameraImageCapture::error), this, &Camera::displayCaptureError);
@jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?
-
@jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?
@jsulm said in A camera problem.:
@jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?
I did in Camera::setCamera
connect(m_imageCapture.data(), &QCameraImageCapture::imageAvailable, this, &Camera::ImageAvailable);
and then
void Camera::ImageAvailable(int id, const QVideoFrame &frame) { qDebug() << id; //qDebug() << frame->???; }
I also added
void Camera::displayCameraError() { //QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString()); qDebug() << "Camera Error: " + m_camera->errorString() + "\n"; } void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString) { Q_UNUSED(id); Q_UNUSED(error); qDebug() << "Image Capture Error: " + errorString; m_isCapturingImage = false; }
and when I do
g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage); g_camera.takeImage();
I get
"Image Capture Error: Camera not ready"
How can I know a reason why the camera isn't ready?
-
@jsulm said in A camera problem.:
@jenya7 So, what about trying https://doc.qt.io/qt-5/qcameraimagecapture.html#imageAvailable ?
I did in Camera::setCamera
connect(m_imageCapture.data(), &QCameraImageCapture::imageAvailable, this, &Camera::ImageAvailable);
and then
void Camera::ImageAvailable(int id, const QVideoFrame &frame) { qDebug() << id; //qDebug() << frame->???; }
I also added
void Camera::displayCameraError() { //QMessageBox::warning(this, tr("Camera Error"), m_camera->errorString()); qDebug() << "Camera Error: " + m_camera->errorString() + "\n"; } void Camera::displayCaptureError(int id, const QCameraImageCapture::Error error, const QString &errorString) { Q_UNUSED(id); Q_UNUSED(error); qDebug() << "Image Capture Error: " + errorString; m_isCapturingImage = false; }
and when I do
g_camera.SetCaptureMode(QCamera::CaptureMode::CaptureStillImage); g_camera.takeImage();
I get
"Image Capture Error: Camera not ready"
How can I know a reason why the camera isn't ready?
@jenya7 Did you call
camera->setCaptureMode(QCamera::CaptureStillImage); camera->start(); //on half pressed shutter button camera->searchAndLock(); //on shutter button pressed imageCapture->capture();
like shown in https://doc.qt.io/qt-5/qcameraimagecapture.html ?
-
@jenya7 Did you call
camera->setCaptureMode(QCamera::CaptureStillImage); camera->start(); //on half pressed shutter button camera->searchAndLock(); //on shutter button pressed imageCapture->capture();
like shown in https://doc.qt.io/qt-5/qcameraimagecapture.html ?
@jsulm said in A camera problem.:
@jenya7 Did you call
camera->setCaptureMode(QCamera::CaptureStillImage); camera->start(); //on half pressed shutter button camera->searchAndLock(); //on shutter button pressed imageCapture->capture();
like shown in https://doc.qt.io/qt-5/qcameraimagecapture.html ?
I thought
void Camera::takeImage() { m_isCapturingImage = true; m_imageCapture->capture(); }
handles all this, kinda higher layer that wraps all together.
and what is
//on half pressed shutter button
//on shutter button pressed
I don't have any buttons. my app is not widget controlled. all commands issued from a command line.
I took a widget camera example (from Examples) and removed all UI related staff. -
@jsulm said in A camera problem.:
@jenya7 Did you call
camera->setCaptureMode(QCamera::CaptureStillImage); camera->start(); //on half pressed shutter button camera->searchAndLock(); //on shutter button pressed imageCapture->capture();
like shown in https://doc.qt.io/qt-5/qcameraimagecapture.html ?
I thought
void Camera::takeImage() { m_isCapturingImage = true; m_imageCapture->capture(); }
handles all this, kinda higher layer that wraps all together.
and what is
//on half pressed shutter button
//on shutter button pressed
I don't have any buttons. my app is not widget controlled. all commands issued from a command line.
I took a widget camera example (from Examples) and removed all UI related staff.@jenya7 said in A camera problem.:
I don't have any buttons.
These comments simply tell you that these methods simulate these buttons.
So, yes you have to set the capture mode, start the camera, call searchAndLock and then capture. -
@jenya7 said in A camera problem.:
I don't have any buttons.
These comments simply tell you that these methods simulate these buttons.
So, yes you have to set the capture mode, start the camera, call searchAndLock and then capture.@jsulm said in A camera problem.:
@jenya7 said in A camera problem.:
I don't have any buttons.
These comments simply tell you that these methods simulate these buttons.
So, yes you have to set the capture mode, start the camera, call searchAndLock and then capture.I changed to
void Camera::takeImage() { m_camera->start(); m_camera->searchAndLock(); m_isCapturingImage = true; m_imageCapture->capture(); }
I still have
"Image Capture Error: Camera not ready"
Do I need to set a Viewfinder?
I commented out those lines//QCameraViewfinder *v_finder = new QCameraViewfinder(); //v_finder->setFixedSize(240, 320); //v_finder->show(); //v_finder->setAttribute(Qt::WA_NoSystemBackground); //m_camera->setViewfinder(v_finder);
cause I get an exception on
QCameraViewfinder *v_finder = new QCameraViewfinder();