Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qv4l2camera.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qv4l2camera_p.h"
7
8#include <private/qcameradevice_p.h>
9#include <private/qmultimediautils_p.h>
10#include <private/qmemoryvideobuffer_p.h>
11#include <private/qcore_unix_p.h>
12
13#include <qsocketnotifier.h>
14#include <qloggingcategory.h>
15
17
18static Q_LOGGING_CATEGORY(qLcV4L2Camera, "qt.multimedia.ffmpeg.v4l2camera");
19
20static const struct {
22 uint32_t v4l2Format;
23} formatMap[] = {
24 // ### How do we handle V4L2_PIX_FMT_H264 and V4L2_PIX_FMT_MPEG4?
25 { QVideoFrameFormat::Format_YUV420P, V4L2_PIX_FMT_YUV420 },
26 { QVideoFrameFormat::Format_YUV422P, V4L2_PIX_FMT_YUV422P },
27 { QVideoFrameFormat::Format_YUYV, V4L2_PIX_FMT_YUYV },
28 { QVideoFrameFormat::Format_UYVY, V4L2_PIX_FMT_UYVY },
29 { QVideoFrameFormat::Format_XBGR8888, V4L2_PIX_FMT_XBGR32 },
30 { QVideoFrameFormat::Format_XRGB8888, V4L2_PIX_FMT_XRGB32 },
31 { QVideoFrameFormat::Format_ABGR8888, V4L2_PIX_FMT_ABGR32 },
32 { QVideoFrameFormat::Format_ARGB8888, V4L2_PIX_FMT_ARGB32 },
33 { QVideoFrameFormat::Format_BGRX8888, V4L2_PIX_FMT_BGR32 },
34 { QVideoFrameFormat::Format_RGBX8888, V4L2_PIX_FMT_RGB32 },
35 { QVideoFrameFormat::Format_BGRA8888, V4L2_PIX_FMT_BGRA32 },
36 { QVideoFrameFormat::Format_RGBA8888, V4L2_PIX_FMT_RGBA32 },
37 { QVideoFrameFormat::Format_Y8, V4L2_PIX_FMT_GREY },
38 { QVideoFrameFormat::Format_Y16, V4L2_PIX_FMT_Y16 },
39 { QVideoFrameFormat::Format_NV12, V4L2_PIX_FMT_NV12 },
40 { QVideoFrameFormat::Format_NV21, V4L2_PIX_FMT_NV21 },
41 { QVideoFrameFormat::Format_Jpeg, V4L2_PIX_FMT_MJPEG },
42 { QVideoFrameFormat::Format_Jpeg, V4L2_PIX_FMT_JPEG },
44};
45
47{
48 auto *f = formatMap;
49 while (f->v4l2Format) {
50 if (f->v4l2Format == v4l2Format)
51 return f->fmt;
52 ++f;
53 }
55}
56
58{
59 auto *f = formatMap;
60 while (f->v4l2Format) {
61 if (f->fmt == format)
62 return f->v4l2Format;
63 ++f;
64 }
65 return 0;
66}
67
72
74{
75 stopCapturing();
76 closeV4L2Fd();
77}
78
80{
81 return m_active;
82}
83
84void QV4L2Camera::setActive(bool active)
85{
86 if (m_active == active)
87 return;
88 if (m_cameraDevice.isNull() && active)
89 return;
90
93
94 m_active = active;
95 if (m_active)
96 startCapturing();
97 else
98 stopCapturing();
99
101
102 emit activeChanged(active);
103}
104
106{
107 if (m_cameraDevice == camera)
108 return;
109
110 stopCapturing();
111 closeV4L2Fd();
112
113 m_cameraDevice = camera;
115
116 initV4L2Controls();
117
118 if (m_active)
119 startCapturing();
120}
121
123{
124 if (!format.isNull() && !m_cameraDevice.videoFormats().contains(format))
125 return false;
126
128 return true;
129
130 if (m_active) {
131 stopCapturing();
132 closeV4L2Fd();
133
134 initV4L2Controls();
135 startCapturing();
136 }
137
138 return true;
139}
140
142{
143 auto fmt = format;
144 if (fmt.isNull())
145 fmt = findBestCameraFormat(m_cameraDevice);
146
147 if (fmt == m_cameraFormat)
148 return false;
149
151 return true;
152}
153
155{
156 if (mode == focusMode())
157 return;
158
160 if (!focusDist && !m_v4l2Info.rangedFocus)
161 return;
162
163 switch (mode) {
164 default:
166 setV4L2Parameter(V4L2_CID_FOCUS_AUTO, 1);
167 if (m_v4l2Info.rangedFocus)
168 setV4L2Parameter(V4L2_CID_AUTO_FOCUS_RANGE, V4L2_AUTO_FOCUS_RANGE_AUTO);
169 break;
171 setV4L2Parameter(V4L2_CID_FOCUS_AUTO, 1);
172 if (m_v4l2Info.rangedFocus)
173 setV4L2Parameter(V4L2_CID_AUTO_FOCUS_RANGE, V4L2_AUTO_FOCUS_RANGE_MACRO);
174 else if (focusDist)
175 setV4L2Parameter(V4L2_CID_FOCUS_ABSOLUTE, m_v4l2Info.minFocus);
176 break;
178 setV4L2Parameter(V4L2_CID_FOCUS_AUTO, 1);
179 if (m_v4l2Info.rangedFocus)
180 setV4L2Parameter(V4L2_CID_AUTO_FOCUS_RANGE, V4L2_AUTO_FOCUS_RANGE_INFINITY);
181 break;
183 setV4L2Parameter(V4L2_CID_FOCUS_AUTO, 0);
184 setV4L2Parameter(V4L2_CID_FOCUS_ABSOLUTE, m_v4l2Info.maxFocus);
185 break;
187 setV4L2Parameter(V4L2_CID_FOCUS_AUTO, 0);
189 break;
190 }
192}
193
195{
196 int distance = m_v4l2Info.minFocus + int((m_v4l2Info.maxFocus - m_v4l2Info.minFocus) * d);
197 setV4L2Parameter(V4L2_CID_FOCUS_ABSOLUTE, distance);
199}
200
201void QV4L2Camera::zoomTo(float factor, float)
202{
203 if (m_v4l2Info.maxZoom == m_v4l2Info.minZoom)
204 return;
205 factor = qBound(1., factor, 2.);
206 int zoom = m_v4l2Info.minZoom + (factor - 1.) * (m_v4l2Info.maxZoom - m_v4l2Info.minZoom);
207 setV4L2Parameter(V4L2_CID_ZOOM_ABSOLUTE, zoom);
208 zoomFactorChanged(factor);
209}
210
219
221{
222 if (!m_v4l2Info.flashSupported || mode == QCamera::FlashOn)
223 return;
224 setV4L2Parameter(V4L2_CID_FLASH_LED_MODE, mode == QCamera::FlashAuto ? V4L2_FLASH_LED_MODE_FLASH : V4L2_FLASH_LED_MODE_NONE);
226}
227
229{
230 if (m_v4l2Info.flashSupported && mode == QCamera::FlashAuto)
231 return true;
232 return mode == QCamera::FlashOff;
233}
234
236{
237 struct v4l2_queryctrl queryControl;
238 ::memset(&queryControl, 0, sizeof(queryControl));
239 queryControl.id = V4L2_CID_AUTO_WHITE_BALANCE;
240
241 return m_v4l2FileDescriptor && m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl);
242}
243
245{
246 if (!m_v4l2Info.torchSupported || mode == QCamera::TorchOn)
247 return;
248 setV4L2Parameter(V4L2_CID_FLASH_LED_MODE, mode == QCamera::TorchOn ? V4L2_FLASH_LED_MODE_TORCH : V4L2_FLASH_LED_MODE_NONE);
250}
251
253{
254 if (mode == QCamera::TorchOn)
255 return m_v4l2Info.torchSupported;
256 return mode == QCamera::TorchOff;
257}
258
260{
261 if (m_v4l2Info.autoExposureSupported && m_v4l2Info.manualExposureSupported) {
263 return;
264 int value = QCamera::ExposureAuto ? V4L2_EXPOSURE_AUTO : V4L2_EXPOSURE_MANUAL;
265 setV4L2Parameter(V4L2_CID_EXPOSURE_AUTO, value);
267 return;
268 }
269}
270
272{
274 return true;
275 if (m_v4l2Info.manualExposureSupported && m_v4l2Info.autoExposureSupported)
277 return false;
278}
279
281{
282 if ((m_v4l2Info.minExposureAdjustment != 0 || m_v4l2Info.maxExposureAdjustment != 0)) {
283 int value = qBound(m_v4l2Info.minExposureAdjustment, (int)(compensation * 1000),
284 m_v4l2Info.maxExposureAdjustment);
285 setV4L2Parameter(V4L2_CID_AUTO_EXPOSURE_BIAS, value);
287 return;
288 }
289}
290
292{
294 return;
295 setV4L2Parameter(V4L2_CID_ISO_SENSITIVITY_AUTO, iso <= 0 ? V4L2_ISO_SENSITIVITY_AUTO : V4L2_ISO_SENSITIVITY_MANUAL);
296 if (iso > 0) {
297 iso = qBound(minIso(), iso, maxIso());
298 setV4L2Parameter(V4L2_CID_ISO_SENSITIVITY, iso);
299 }
300 return;
301}
302
304{
306 return -1;
307 return getV4L2Parameter(V4L2_CID_ISO_SENSITIVITY);
308}
309
311{
312 if (m_v4l2Info.manualExposureSupported && m_v4l2Info.autoExposureSupported) {
313 int exposure =
314 qBound(m_v4l2Info.minExposure, qRound(secs * 10000.), m_v4l2Info.maxExposure);
315 setV4L2Parameter(V4L2_CID_EXPOSURE_ABSOLUTE, exposure);
316 exposureTimeChanged(exposure/10000.);
317 return;
318 }
319}
320
322{
323 return getV4L2Parameter(V4L2_CID_EXPOSURE_ABSOLUTE)/10000.;
324}
325
333
335{
337
338 int temperature = colorTemperatureForWhiteBalance(mode);
339 int t = setV4L2ColorTemperature(temperature);
340 if (t == 0)
343}
344
346{
347 if (temperature == 0) {
349 return;
350 }
351
353
354 int t = setV4L2ColorTemperature(temperature);
355 if (t)
357}
358
359void QV4L2Camera::readFrame()
360{
361 Q_ASSERT(m_memoryTransfer);
362
363 auto buffer = m_memoryTransfer->dequeueBuffer();
364 if (!buffer) {
365 qCWarning(qLcV4L2Camera) << "Cannot take buffer";
366
367 if (errno == ENODEV) {
368 // camera got removed while being active
369 stopCapturing();
370 closeV4L2Fd();
371 }
372
373 return;
374 }
375
376 auto videoBuffer = new QMemoryVideoBuffer(buffer->data, m_bytesPerLine);
377 QVideoFrame frame(videoBuffer, frameFormat());
378
379 auto &v4l2Buffer = buffer->v4l2Buffer;
380
381 if (m_firstFrameTime.tv_sec == -1)
382 m_firstFrameTime = v4l2Buffer.timestamp;
383 qint64 secs = v4l2Buffer.timestamp.tv_sec - m_firstFrameTime.tv_sec;
384 qint64 usecs = v4l2Buffer.timestamp.tv_usec - m_firstFrameTime.tv_usec;
385 frame.setStartTime(secs*1000000 + usecs);
386 frame.setEndTime(frame.startTime() + m_frameDuration);
387
389
390 if (!m_memoryTransfer->enqueueBuffer(v4l2Buffer.index))
391 qCWarning(qLcV4L2Camera) << "Cannot add buffer";
392}
393
394void QV4L2Camera::setCameraBusy()
395{
396 m_cameraBusy = true;
397 updateError(QCamera::CameraError, QLatin1String("Camera is in use"));
398}
399
400void QV4L2Camera::initV4L2Controls()
401{
402 m_v4l2Info = {};
403 QCamera::Features features;
404
405 const QByteArray deviceName = m_cameraDevice.id();
407
408 closeV4L2Fd();
409
410 const int descriptor = qt_safe_open(deviceName.constData(), O_RDWR);
411 if (descriptor == -1) {
412 qCWarning(qLcV4L2Camera) << "Unable to open the camera" << deviceName
413 << "for read to query the parameter info:"
414 << qt_error_string(errno);
415 updateError(QCamera::CameraError, QLatin1String("Cannot open camera"));
416 return;
417 }
418
419 m_v4l2FileDescriptor = std::make_shared<QV4L2FileDescriptor>(descriptor);
420
421 qCDebug(qLcV4L2Camera) << "FD=" << descriptor;
422
423 struct v4l2_queryctrl queryControl;
424 ::memset(&queryControl, 0, sizeof(queryControl));
425 queryControl.id = V4L2_CID_AUTO_WHITE_BALANCE;
426
427 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
428 m_v4l2Info.autoWhiteBalanceSupported = true;
429 setV4L2Parameter(V4L2_CID_AUTO_WHITE_BALANCE, true);
430 }
431
432 ::memset(&queryControl, 0, sizeof(queryControl));
433 queryControl.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE;
434 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
435 m_v4l2Info.minColorTemp = queryControl.minimum;
436 m_v4l2Info.maxColorTemp = queryControl.maximum;
437 m_v4l2Info.colorTemperatureSupported = true;
439 }
440
441 ::memset(&queryControl, 0, sizeof(queryControl));
442 queryControl.id = V4L2_CID_EXPOSURE_AUTO;
443 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
444 m_v4l2Info.autoExposureSupported = true;
445 }
446
447 ::memset(&queryControl, 0, sizeof(queryControl));
448 queryControl.id = V4L2_CID_EXPOSURE_ABSOLUTE;
449 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
450 m_v4l2Info.manualExposureSupported = true;
451 m_v4l2Info.minExposure = queryControl.minimum;
452 m_v4l2Info.maxExposure = queryControl.maximum;
454 }
455
456 ::memset(&queryControl, 0, sizeof(queryControl));
457 queryControl.id = V4L2_CID_AUTO_EXPOSURE_BIAS;
458 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
459 m_v4l2Info.minExposureAdjustment = queryControl.minimum;
460 m_v4l2Info.maxExposureAdjustment = queryControl.maximum;
462 }
463
464 ::memset(&queryControl, 0, sizeof(queryControl));
465 queryControl.id = V4L2_CID_ISO_SENSITIVITY_AUTO;
466 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
467 queryControl.id = V4L2_CID_ISO_SENSITIVITY;
468 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
470 minIsoChanged(queryControl.minimum);
471 maxIsoChanged(queryControl.minimum);
472 }
473 }
474
475 ::memset(&queryControl, 0, sizeof(queryControl));
476 queryControl.id = V4L2_CID_FOCUS_ABSOLUTE;
477 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
478 m_v4l2Info.minExposureAdjustment = queryControl.minimum;
479 m_v4l2Info.maxExposureAdjustment = queryControl.maximum;
481 }
482
483 ::memset(&queryControl, 0, sizeof(queryControl));
484 queryControl.id = V4L2_CID_AUTO_FOCUS_RANGE;
485 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
486 m_v4l2Info.rangedFocus = true;
487 }
488
489 ::memset(&queryControl, 0, sizeof(queryControl));
490 queryControl.id = V4L2_CID_FLASH_LED_MODE;
491 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
492 m_v4l2Info.flashSupported = queryControl.minimum <= V4L2_FLASH_LED_MODE_FLASH
493 && queryControl.maximum >= V4L2_FLASH_LED_MODE_FLASH;
494 m_v4l2Info.torchSupported = queryControl.minimum <= V4L2_FLASH_LED_MODE_TORCH
495 && queryControl.maximum >= V4L2_FLASH_LED_MODE_TORCH;
496 }
497
498 ::memset(&queryControl, 0, sizeof(queryControl));
499 queryControl.id = V4L2_CID_ZOOM_ABSOLUTE;
500 if (m_v4l2FileDescriptor->call(VIDIOC_QUERYCTRL, &queryControl)) {
501 m_v4l2Info.minZoom = queryControl.minimum;
502 m_v4l2Info.maxZoom = queryControl.maximum;
503 }
504 // zoom factors are in arbitrary units, so we simply normalize them to go from 1 to 2
505 // if they are different
507 maximumZoomFactorChanged(m_v4l2Info.minZoom != m_v4l2Info.maxZoom ? 2 : 1);
508
509 supportedFeaturesChanged(features);
510}
511
512void QV4L2Camera::closeV4L2Fd()
513{
514 Q_ASSERT(!m_memoryTransfer);
515
516 m_v4l2Info = {};
517 m_cameraBusy = false;
518 m_v4l2FileDescriptor = nullptr;
519}
520
521int QV4L2Camera::setV4L2ColorTemperature(int temperature)
522{
523 struct v4l2_control control;
524 ::memset(&control, 0, sizeof(control));
525
526 if (m_v4l2Info.autoWhiteBalanceSupported) {
527 setV4L2Parameter(V4L2_CID_AUTO_WHITE_BALANCE, temperature == 0 ? true : false);
528 } else if (temperature == 0) {
529 temperature = 5600;
530 }
531
532 if (temperature != 0 && m_v4l2Info.colorTemperatureSupported) {
533 temperature = qBound(m_v4l2Info.minColorTemp, temperature, m_v4l2Info.maxColorTemp);
534 if (!setV4L2Parameter(
535 V4L2_CID_WHITE_BALANCE_TEMPERATURE,
536 qBound(m_v4l2Info.minColorTemp, temperature, m_v4l2Info.maxColorTemp)))
537 temperature = 0;
538 } else {
539 temperature = 0;
540 }
541
542 return temperature;
543}
544
545bool QV4L2Camera::setV4L2Parameter(quint32 id, qint32 value)
546{
547 v4l2_control control{ id, value };
548 if (!m_v4l2FileDescriptor->call(VIDIOC_S_CTRL, &control)) {
549 qWarning() << "Unable to set the V4L2 Parameter" << Qt::hex << id << "to" << value << qt_error_string(errno);
550 return false;
551 }
552 return true;
553}
554
555int QV4L2Camera::getV4L2Parameter(quint32 id) const
556{
557 struct v4l2_control control{id, 0};
558 if (!m_v4l2FileDescriptor->call(VIDIOC_G_CTRL, &control)) {
559 qWarning() << "Unable to get the V4L2 Parameter" << Qt::hex << id << qt_error_string(errno);
560 return 0;
561 }
562 return control.value;
563}
564
565void QV4L2Camera::setV4L2CameraFormat()
566{
567 if (m_v4l2Info.formatInitialized || !m_v4l2FileDescriptor)
568 return;
569
571 qCDebug(qLcV4L2Camera) << "XXXXX" << this << m_cameraDevice.id() << m_cameraFormat.pixelFormat()
573
574 v4l2_format fmt = {};
575 fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
576
578 fmt.fmt.pix.width = size.width();
579 fmt.fmt.pix.height = size.height();
581 fmt.fmt.pix.field = V4L2_FIELD_ANY;
582
583 qCDebug(qLcV4L2Camera) << "setting camera format to" << size << fmt.fmt.pix.pixelformat;
584
585 if (!m_v4l2FileDescriptor->call(VIDIOC_S_FMT, &fmt)) {
586 if (errno == EBUSY) {
587 setCameraBusy();
588 return;
589 }
590 qWarning() << "Couldn't set video format on v4l2 camera" << strerror(errno);
591 }
592
593 m_v4l2Info.formatInitialized = true;
594 m_cameraBusy = false;
595
596 m_bytesPerLine = fmt.fmt.pix.bytesperline;
597 m_imageSize = std::max(fmt.fmt.pix.sizeimage, m_bytesPerLine * fmt.fmt.pix.height);
598
599 switch (v4l2_colorspace(fmt.fmt.pix.colorspace)) {
600 default:
601 case V4L2_COLORSPACE_DCI_P3:
603 break;
604 case V4L2_COLORSPACE_REC709:
606 break;
607 case V4L2_COLORSPACE_JPEG:
609 break;
610 case V4L2_COLORSPACE_SRGB:
611 // ##### is this correct???
613 break;
614 case V4L2_COLORSPACE_BT2020:
616 break;
617 }
618
619 v4l2_streamparm streamParam = {};
620 streamParam.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
621
622 streamParam.parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
624 streamParam.parm.capture.timeperframe = { (uint)num, (uint)den };
625 m_v4l2FileDescriptor->call(VIDIOC_S_PARM, &streamParam);
626
627 m_frameDuration = 1000000 * streamParam.parm.capture.timeperframe.numerator
628 / streamParam.parm.capture.timeperframe.denominator;
629}
630
631void QV4L2Camera::initV4L2MemoryTransfer()
632{
633 if (m_cameraBusy)
634 return;
635
636 Q_ASSERT(!m_memoryTransfer);
637
638 m_memoryTransfer = makeUserPtrMemoryTransfer(m_v4l2FileDescriptor, m_imageSize);
639
640 if (m_memoryTransfer)
641 return;
642
643 if (errno == EBUSY) {
644 setCameraBusy();
645 return;
646 }
647
648 qCDebug(qLcV4L2Camera) << "Cannot init V4L2_MEMORY_USERPTR; trying V4L2_MEMORY_MMAP";
649
650 m_memoryTransfer = makeMMapMemoryTransfer(m_v4l2FileDescriptor);
651
652 if (!m_memoryTransfer) {
653 qCWarning(qLcV4L2Camera) << "Cannot init v4l2 memory transfer," << qt_error_string(errno);
654 updateError(QCamera::CameraError, QLatin1String("Cannot init V4L2 memory transfer"));
655 }
656}
657
658void QV4L2Camera::stopCapturing()
659{
660 if (!m_memoryTransfer || !m_v4l2FileDescriptor)
661 return;
662
663 m_notifier = nullptr;
664
665 if (!m_v4l2FileDescriptor->stopStream()) {
666 // TODO: handle the case carefully to avoid possible memory corruption
667 if (errno != ENODEV)
668 qWarning() << "failed to stop capture";
669 }
670
671 m_memoryTransfer = nullptr;
672 m_cameraBusy = false;
673}
674
675void QV4L2Camera::startCapturing()
676{
677 if (!m_v4l2FileDescriptor)
678 return;
679
680 setV4L2CameraFormat();
681 initV4L2MemoryTransfer();
682
683 if (m_cameraBusy || !m_memoryTransfer)
684 return;
685
686 if (!m_v4l2FileDescriptor->startStream()) {
687 qWarning() << "Couldn't start v4l2 camera stream";
688 return;
689 }
690
691 m_notifier =
692 std::make_unique<QSocketNotifier>(m_v4l2FileDescriptor->get(), QSocketNotifier::Read);
693 connect(m_notifier.get(), &QSocketNotifier::activated, this, &QV4L2Camera::readFrame);
694
695 m_firstFrameTime = { -1, -1 };
696}
697
699{
701 result.setColorSpace(m_colorSpace);
702 return result;
703}
704
706
707#include "moc_qv4l2camera_p.cpp"
bool m_active
\inmodule QtCore
Definition qbytearray.h:57
The QCameraDevice class provides general information about camera devices.
bool isNull() const
Returns true if this QCameraDevice is null or invalid.
QList< QCameraFormat > videoFormats
\qmlproperty CameraFormat QtMultimedia::cameraDevice::videoFormats
QByteArray id
\qmlproperty string QtMultimedia::cameraDevice::id
The QCameraFormat class describes a video format supported by a camera device. \inmodule QtMultimedia...
QSize resolution
\qmlproperty size QtMultimedia::cameraFormat::resolution
bool isNull() const noexcept
Returns true if this is a default constructed QCameraFormat.
QVideoFrameFormat::PixelFormat pixelFormat
\qmlproperty enumeration QtMultimedia::cameraFormat::pixelFormat
float maxFrameRate
\qmlproperty real QtMultimedia::cameraFormat::maxFrameRate
The QCamera class provides interface for system camera devices.
Definition qcamera.h:28
WhiteBalanceMode
\value WhiteBalanceAuto Auto white balance mode.
Definition qcamera.h:112
@ WhiteBalanceManual
Definition qcamera.h:114
@ WhiteBalanceAuto
Definition qcamera.h:113
TorchMode
\value TorchOff Torch is Off.
Definition qcamera.h:84
@ TorchOn
Definition qcamera.h:86
@ TorchOff
Definition qcamera.h:85
FocusMode
\value FocusModeAuto Continuous auto focus mode.
Definition qcamera.h:67
@ FocusModeAutoNear
Definition qcamera.h:69
@ FocusModeInfinity
Definition qcamera.h:72
@ FocusModeAutoFar
Definition qcamera.h:70
@ FocusModeAuto
Definition qcamera.h:68
@ FocusModeManual
Definition qcamera.h:73
FlashMode
\value FlashOff Flash is Off.
Definition qcamera.h:77
@ FlashAuto
Definition qcamera.h:80
@ FlashOn
Definition qcamera.h:79
@ FlashOff
Definition qcamera.h:78
ExposureMode
\value ExposureAuto Automatic mode.
Definition qcamera.h:91
@ ExposureManual
Definition qcamera.h:93
@ ExposureAuto
Definition qcamera.h:92
@ CameraError
Definition qcamera.h:63
The QMemoryVideoBuffer class provides a system memory allocated video data buffer.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QCameraFormat findBestCameraFormat(const QCameraDevice &camera) const
void updateError(QCamera::Error error, const QString &errorString)
void maxIsoChanged(int iso)
QCamera::Features supportedFeatures() const
void torchModeChanged(QCamera::TorchMode mode)
void focusModeChanged(QCamera::FocusMode mode)
void exposureCompensationChanged(float compensation)
float focusDistance() const
void whiteBalanceModeChanged(QCamera::WhiteBalanceMode mode)
QCamera::FocusMode focusMode() const
void focusDistanceChanged(float d)
static int colorTemperatureForWhiteBalance(QCamera::WhiteBalanceMode mode)
void maximumZoomFactorChanged(float)
void flashModeChanged(QCamera::FlashMode mode)
void zoomFactorChanged(float zoom)
void colorTemperatureChanged(int temperature)
QVideoFrameFormat frameFormat() const override
void minIsoChanged(int iso)
void exposureModeChanged(QCamera::ExposureMode mode)
void supportedFeaturesChanged(QCamera::Features)
void minimumZoomFactorChanged(float factor)
QCameraFormat m_cameraFormat
void exposureTimeChanged(float speed)
void newVideoFrame(const QVideoFrame &)
void activeChanged(bool)
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
void activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent, QPrivateSignal)
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1246
void zoomTo(float, float=-1.) override
void setManualIsoSensitivity(int) override
void setColorTemperature(int) override
bool isActive() const override
void setFocusMode(QCamera::FocusMode) override
QVideoFrameFormat frameFormat() const override
bool setCameraFormat(const QCameraFormat &format) override
void setTorchMode(QCamera::TorchMode) override
void setFocusDistance(float) override
bool isFocusModeSupported(QCamera::FocusMode mode) const override
void setExposureMode(QCamera::ExposureMode) override
void setActive(bool active) override
bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override
bool isFlashReady() const override
bool resolveCameraFormat(const QCameraFormat &format)
int isoSensitivity() const override
QV4L2Camera(QCamera *parent)
void setExposureCompensation(float) override
void setFlashMode(QCamera::FlashMode) override
bool isFlashModeSupported(QCamera::FlashMode mode) const override
bool isTorchModeSupported(QCamera::TorchMode mode) const override
void setWhiteBalanceMode(QCamera::WhiteBalanceMode) override
bool isExposureModeSupported(QCamera::ExposureMode mode) const override
void setCamera(const QCameraDevice &camera) override
float exposureTime() const override
void setManualExposureTime(float) override
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
PixelFormat
Enumerates video data types.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
QCamera * camera
Definition camera.cpp:19
Combined button and popup list for selecting options.
QString deviceName()
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
static int qt_safe_open(const char *pathname, int flags, mode_t mode=0777)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
Q_DECL_COLD_FUNCTION Q_CORE_EXPORT QString qt_error_string(int errorCode=-1)
#define qWarning
Definition qlogging.h:166
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
QT_BEGIN_NAMESPACE Fraction qRealToFraction(qreal value)
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint id
[7]
GLfloat GLfloat f
GLsizei GLsizei GLfloat distance
GLenum GLuint buffer
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLuint num
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define emit
unsigned int quint32
Definition qtypes.h:50
int qint32
Definition qtypes.h:49
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
uint32_t v4l2FormatForPixelFormat(QVideoFrameFormat::PixelFormat format)
QVideoFrameFormat::PixelFormat fmt
uint32_t v4l2Format
static const struct @731 formatMap[]
QVideoFrameFormat::PixelFormat formatForV4L2Format(uint32_t v4l2Format)
uint32_t v4l2FormatForPixelFormat(QVideoFrameFormat::PixelFormat format)
QV4L2MemoryTransferUPtr makeUserPtrMemoryTransfer(QV4L2FileDescriptorPtr fileDescriptor, quint32 imageSize)
QV4L2MemoryTransferUPtr makeMMapMemoryTransfer(QV4L2FileDescriptorPtr fileDescriptor)
QFrame frame
[0]
bool contains(const AT &t) const noexcept
Definition qlist.h:45
bool autoExposureSupported
bool colorTemperatureSupported
bool manualExposureSupported
bool autoWhiteBalanceSupported
qint32 minExposureAdjustment
qint32 maxExposureAdjustment