このページでは

QCameraDevice Class

QCameraDevice クラスは、カメラデバイスに関する一般的な情報を提供します。詳細...

ヘッダー: #include <QCameraDevice>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
QML内: cameraDevice

パブリック型

enum Position { UnspecifiedPosition, BackFace, FrontFace }

プロパティ

パブリック関数

QCameraDevice()
QCameraDevice(const QCameraDevice &other)
~QCameraDevice()
QtVideo::Rotation correctionAngle() const
QString description() const
QByteArray id() const
bool isDefault() const
bool isNull() const
QList<QSize> photoResolutions() const
QCameraDevice::Position position() const
QList<QCameraFormat> videoFormats() const
bool operator!=(const QCameraDevice &other) const
QCameraDevice &operator=(const QCameraDevice &other)
bool operator==(const QCameraDevice &other) const

詳細な説明

QCameraDevice は、物理的なカメラデバイスとそのプロパティを表します。

availableCameras() および defaultCamera() 関数を使用することで、システム上で利用可能なカメラを特定できます。これらは QtMultimedia::MediaDevices に含まれています。

QCameraDevice インスタンスは、対応する物理デバイスが切断されたり、その設定が変更されたりした場合でも、そのライフタイムを通じてプロパティを維持します。更新されたプロパティを追跡するには、関連するシグナルが発火した際に、QMediaDevices から QCameraDevice の新しいインスタンスを読み込む必要があります。

この例では、利用可能なすべてのカメラの名前を出力します:

constQList<QCameraDevice>cameras=QMediaDevices::videoInputs();
for(constQCameraDevice&cameraDevice: cameras)
    qDebug() << cameraDevice.description();

QCameraDevice を使用して、QCamera を構築することができます。以下の例では、カメラデバイスの名前がmycamera であるQCamera をインスタンス化しています:

const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &cameraDevice : cameras) {
    if (cameraDevice.description() == "mycamera")
        camera = new QCamera(cameraDevice);
}

また、QCameraDevice を使用すると、説明やシステム上での物理的な位置など、カメラデバイスに関する一般的な情報を取得することもできます。

QCamera myCamera;
QCameraDevice cameraDevice=myCamera.cameraDevice();

if(cameraDevice.position()==QCameraDevice::FrontFace)
    qDebug() << "The camera is on the front face of the hardware system.";
else if(cameraDevice.position()==QCameraDevice::BackFace)
    qDebug() << "The camera is on the back face of the hardware system.";

QCameraも参照してください 。

メンバータイプのドキュメント

enum QCameraDevice::Position

この列挙型は、システムハードウェア上のカメラの物理的な位置を指定します。

定数値説明
QCameraDevice::UnspecifiedPosition0カメラの位置は未指定、または不明です。
QCameraDevice::BackFace1カメラはシステムハードウェアの背面にあります。たとえば、モバイルデバイスでは、画面とは反対側にあることを意味します。
QCameraDevice::FrontFace2カメラはシステムハードウェアの前面にあります。たとえば、モバイルデバイスでは、画面と同じ側にあることを意味します。 前面カメラは、プロパティ `QVideoFrame::mirrored ` が `true` に設定されたビデオフレームを生成します。これは、これらのフレームの表示が垂直軸を中心に反転され、ビデオ出力が鏡像として表示されることを意味しますが、録画では `QVideoFrame::surfaceFormat` で指定された面の変換のみが考慮されます。

position()も参照してください 。

プロパティのドキュメント

[read-only, since 6.7] correctionAngle : const QtVideo::Rotation

カメラのネイティブ向きに対する物理的な回転を補正するために必要な回転角度を返します。つまり、このプロパティは、出力画像がデバイスの画面上でネイティブ向きに正しく表示されるようにするために、画像を時計回りに回転させる必要のある角度を表します。correctionAngle はネイティブの向きを基準としているため、この値はデバイスの向き(縦向き/横向き)を変更しても変化しません。補正角度がゼロ以外になるのは主にAndroidであり、そこではネイティブの向きとカメラの向きがメーカーによって定義されています。

90度の\a補正角を用いた例

この列挙型は Qt 6.7 で導入されました。

アクセス関数:

QtVideo::Rotation correctionAngle() const

[read-only] description : const QString

カメラに関する、人間が理解しやすい説明文を返します。

この文字列を使用して、ユーザーにデバイスを表示します。

アクセス関数:

QString description() const

[read-only] id : const QByteArray

カメラのデバイスIDを返します

これはカメラを識別するための一意のIDであり、人間が読み取れる形式ではない場合があります。

アクセス関数:

QByteArray id() const

[read-only] isDefault : const bool

これがデフォルトのカメラデバイスである場合、true を返します。

アクセス関数:

bool isDefault() const

[read-only] position : const Position

ハードウェアシステム上のカメラの物理的な位置を返します。

アクセス関数:

QCameraDevice::Position position() const

[read-only] videoFormats : const QList<QCameraFormat>

カメラがサポートしている動画形式を返します。

アクセス関数:

QList<QCameraFormat> videoFormats() const

メンバ関数のドキュメント

QCameraDevice::QCameraDevice()

nullカメラデバイスを構築します

QCameraDevice::QCameraDevice(const QCameraDevice &other)

other のコピーを作成します。

[noexcept] QCameraDevice::~QCameraDevice()

QCameraDevice を削除します。

bool QCameraDevice::isNull() const

このQCameraDevice がnullまたは無効な場合、trueを返します。

QList<QSize> QCameraDevice::photoResolutions() const

カメラが静止画の撮影に使用できる解像度のリストを返します。

QImageCaptureも参照してください 。

bool QCameraDevice::operator!=(const QCameraDevice &other) const

この `QCameraDevice ` が `other` と同じデバイスを表していない場合、true を返します。

QCameraDevice &QCameraDevice::operator=(const QCameraDevice &other)

QCameraDevice オブジェクトをother と同じ値に設定します。

bool QCameraDevice::operator==(const QCameraDevice &other) const

この `QCameraDevice ` が `other` と同じデバイスを表している場合、`true` を返します。

QCameraDevice のプロパティの挙動により、すべてのプロパティが等しくない場合でも、2つのQCameraDevice インスタンスが等しいとみなされることがあります。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.