A camera problem.
-
I want to work with a camera on my board.
I include in a pro fileQT += multimedia multimediawidgets
But when I include
#include <QMediaService> #include <QMediaRecorder> #include <QCameraViewfinder> #include <QCameraInfo> #include <QMediaMetaData>
I get - file not found on all these files.
It happens on Linux installation, on Windows it's OK.Should I install additional libraries on Linux?
-
I want to work with a camera on my board.
I include in a pro fileQT += multimedia multimediawidgets
But when I include
#include <QMediaService> #include <QMediaRecorder> #include <QCameraViewfinder> #include <QCameraInfo> #include <QMediaMetaData>
I get - file not found on all these files.
It happens on Linux installation, on Windows it's OK.Should I install additional libraries on Linux?
-
@JonB said in A camera problem.:
@jenya7 How did you do the Linux installation, did you include the multimedia libraries?
this is a log
sudo apt-get update
sudo apt-get upgrade//Buster
sudo apt-get install qt5-default
//Bullseye
//sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
sudo apt-get install qtcreator
sudo apt-get install qtdeclarative5-dev
sudo apt-get install qtconnectivity5-dev //for bluetooth
sudo apt-get install qtbase5-examples
sudo apt-get install qtbase5-doc-html
To upgrade
sudo apt-get install qt5-qmake
//for Debian ?
qtbase5-dev
qtchooser
qt5-qmake
qtbase5-dev-toolsCan't see explicit multimedia installation? should I add? how it would be?
-
@JonB said in A camera problem.:
@jenya7 How did you do the Linux installation, did you include the multimedia libraries?
this is a log
sudo apt-get update
sudo apt-get upgrade//Buster
sudo apt-get install qt5-default
//Bullseye
//sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools
sudo apt-get install qtcreator
sudo apt-get install qtdeclarative5-dev
sudo apt-get install qtconnectivity5-dev //for bluetooth
sudo apt-get install qtbase5-examples
sudo apt-get install qtbase5-doc-html
To upgrade
sudo apt-get install qt5-qmake
//for Debian ?
qtbase5-dev
qtchooser
qt5-qmake
qtbase5-dev-toolsCan't see explicit multimedia installation? should I add? how it would be?
-
@jenya7
After typingapt-get install
followed byqt
orqt5
did you press the Tab key (twice)? -
This is my constructor
Camera::Camera(QObject *parent) : QObject(parent) { //Camera devices: QActionGroup *videoDevicesGroup = new QActionGroup(this); videoDevicesGroup->setExclusive(true); const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras(); for (const QCameraInfo &cameraInfo : availableCameras) { QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup); videoDeviceAction->setCheckable(true); videoDeviceAction->setData(QVariant::fromValue(cameraInfo)); if (cameraInfo == QCameraInfo::defaultCamera()) videoDeviceAction->setChecked(true); } connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice); setCamera(QCameraInfo::defaultCamera()); }
On availableCameras I get <0 items>.
If I check the camera is alive
raspistill -o Desktop/image.jpg
it appears and I see a snapshot on the desktop.Does the library work with a Raspberry Pi camera at all? May be I'm beating a dead horse?
-
This is my constructor
Camera::Camera(QObject *parent) : QObject(parent) { //Camera devices: QActionGroup *videoDevicesGroup = new QActionGroup(this); videoDevicesGroup->setExclusive(true); const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras(); for (const QCameraInfo &cameraInfo : availableCameras) { QAction *videoDeviceAction = new QAction(cameraInfo.description(), videoDevicesGroup); videoDeviceAction->setCheckable(true); videoDeviceAction->setData(QVariant::fromValue(cameraInfo)); if (cameraInfo == QCameraInfo::defaultCamera()) videoDeviceAction->setChecked(true); } connect(videoDevicesGroup, &QActionGroup::triggered, this, &Camera::updateCameraDevice); setCamera(QCameraInfo::defaultCamera()); }
On availableCameras I get <0 items>.
If I check the camera is alive
raspistill -o Desktop/image.jpg
it appears and I see a snapshot on the desktop.Does the library work with a Raspberry Pi camera at all? May be I'm beating a dead horse?
-
@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