Windows設備信息獲取:(攝像頭,聲卡為例)Qt,WindowsAPI對比說明(2)

      網友投稿 1022 2022-05-30

      Windows設備信息獲取:(攝像頭,聲卡為例)Qt,WindowsAPI對比說明

      補充說明

      問題

      QT攝像頭相關信息獲取(分辨率,圖像格式)

      WindowsAPI,win10,win7不兼容問題

      兼容代碼

      解決方案

      其他相關

      補充說明

      在上一篇文檔中,文檔末尾提到了,win10,win7兼容問題,QCamera未發現的問題,這里都做一下說明。

      問題

      QCameraInfo問題

      在QAudioDeviceInfo中,DeviceName()直接打印,即

      foreach(const QAudioDeviceInfo &deviveInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) { qDebug() << "InputDeviceName:" << deviveInfo.deviceName(); }

      1

      2

      3

      4

      打印結果。

      InputDeviceName: "立體聲混音 (Realtek High Definition Audio)"

      1

      在QCamerInfo中,打印結果如下

      QList cameras = QCameraInfo::availableCameras(); foreach(const QCameraInfo &cameraInfo, cameras) { qDebug() << "CameraInfo:-deviceName()" <

      1

      2

      3

      4

      打印的是設備路徑,不是我們想要的設備名稱,后來我去看官方文檔說明:

      CameraInfo:-deviceName() "@device:pnp:\\?\usb#vid_046d&pid_0843&mi_00#6&86ea809&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"

      1

      說明如下:

      返回的是攝像頭的驅動名稱,這是唯一的機器可識別的ID號,和是人類不能識別的。

      **QString QCameraInfo::deviceName() const** Returns the device name of the camera This is a unique ID to identify the camera and may not be human-readable.

      1

      2

      3

      4

      后來繼續看文檔,看到一個這函數

      description(),返回的是人類可識別的描述。

      QString QCameraInfo::description() const Returns the human-readable description of the camera.

      1

      2

      后將幾個函數打印出來看。

      QList cameras = QCameraInfo::availableCameras(); foreach(const QCameraInfo &cameraInfo, cameras) { qDebug() << "CameraInfo:-description()" << cameraInfo.description(); qDebug() << "CameraInfo:-deviceName()" <

      1

      2

      3

      4

      5

      6

      打印結果如下:

      CameraInfo:-description() "Logitech Webcam C930e" CameraInfo:-deviceName() "@device:pnp:\\?\usb#vid_046d&pid_0843&mi_00#6&86ea809&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global" CameraInfo:-defaultCamera() "QCameraInfo(deviceName=@device:pnp:\\?\usb#vid_046d&pid_0843&mi_00#6&86ea809&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global, position=UnspecifiedPosition, orientation=0)"

      1

      2

      3

      我然后去查看了一下QAudioDeviceInfo的文檔說明

      QAudioDeviceInfo::deviceName(),說到,這個函數,返回音頻驅動,人類可識別的名稱。

      QString QAudioDeviceInfo::deviceName() const Returns the human readable name of the audio device. Device names vary depending on the platform/audio plugin being used. They are a unique string identifier for the audio device. eg. default, Intel, U0x46d0x9a4

      1

      2

      3

      4

      5

      QT攝像頭相關信息獲取(分辨率,圖像格式)

      捎帶,又看了一下其他函數。

      攝像頭驅動名稱已經拿到,還有攝像頭支持圖像格式,分辨率

      函數如下:

      QList mResSize = {};//分辨率List 定義 QList cameras = QCameraInfo::availableCameras(); foreach(const QCameraInfo &cameraInfo, cameras) { qDebug() << "CameraInfo:-description()" << cameraInfo.description(); QCamera mCamera(cameraInfo); mCamera.start(); QList mList = mCamera.supportedViewfinderPixelFormats();//圖像格式 mResSize = mCamera.supportedViewfinderResolutions(); foreach (QSize msize, mResSize) { qDebug()<

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      Format_YUYV Format_Jpeg //圖像格式 //分辨率如下 QSize(160, 120) QSize(176, 144) QSize(320, 180) QSize(320, 240) QSize(352, 288) QSize(424, 240) QSize(480, 270) QSize(640, 360) QSize(640, 480) QSize(800, 448) QSize(848, 480) QSize(800, 600) QSize(960, 540) QSize(1024, 576) QSize(1280, 720) QSize(1600, 896) QSize(1920, 1080) QSize(2304, 1296) QSize(2304, 1536)

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      相關功能函數:

      注意使用時,先打開攝像頭,并且攝像頭打開成功,才能獲取到這些信息。

      QList QCamera::supportedViewfinderResolutions(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const

      1

      QList QCamera::supportedViewfinderPixelFormats(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const

      1

      其他函數還有。

      QList QCamera::supportedViewfinderFrameRateRanges(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const QList QCamera::supportedViewfinderSettings(const QCameraViewfinderSettings &settings = QCameraViewfinderSettings()) const

      1

      2

      WindowsAPI,win10,win7不兼容問題

      HID,調用的時候,打印發現

      Win10下,攝像頭類為

      Camera

      1

      Win7下,攝像頭類為

      Image

      1

      所以函數在識別的判斷的時候,判斷不到。

      音頻類同理,

      QT庫,我在win10下安裝,編譯的,在Win7下使用不了,同理。在調用windows底層API時,判斷條件不一樣,所以不兼容。

      GUID,屬性,隨后測試結果給說明。

      兼容代碼

      隨后,寫好之后貼上來。

      /****更新/

      解決方案并不是代碼原因而是一些依賴庫的的問題,詳細解決方案見下文。

      解決方案

      Qt 有一個官方打包依賴庫文件的工具,windeployqt.exe,在 Qt bin 目錄下,以我的為例。

      C:\Qt\Qt5.8.0.8\msvc2013\bin

      1

      使用方法。

      C:\Qt\Qt5.8.0.8\msvc2013\bin>windeployqt -h Usage: windeployqt [options] [files] Qt Deploy Tool 5.8.0 The simplest way to use windeployqt is to add the bin directory of your Qt installation (e.g. ) to the PATH variable and then run: windeployqt If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH variable. If your application uses Qt Quick, run: windeployqt --qmldir Options: -?, -h, --help Displays this help. -v, --version Displays version information. --dir Use directory instead of binary directory. --libdir Copy libraries to path. --plugindir Copy plugins to path. --debug Assume debug binaries. --release Assume release binaries. --pdb Deploy .pdb files (MSVC). --force Force updating files. --dry-run Simulation mode. Behave normally, but do not copy/update any files. --no-plugins Skip plugin deployment. --no-libraries Skip library deployment. --qmldir Scan for QML-imports starting from directory. --no-quick-import Skip deployment of Qt Quick imports. --no-translations Skip deployment of translations. --no-system-d3d-compiler Skip deployment of the system D3D compiler. --compiler-runtime Deploy compiler runtime (Desktop only). --no-compiler-runtime Do not deploy compiler runtime (Desktop only). --webkit2 Deployment of WebKit2 (web process). --no-webkit2 Skip deployment of WebKit2. --json Print to stdout in JSON format. --angle Force deployment of ANGLE. --no-angle Disable deployment of ANGLE. --no-opengl-sw Do not deploy the software rasterizer library. --list

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      53

      54

      55

      56

      57

      簡單的說,因為沒有配置系統變量,所以需要進入 windeployqt.exe所在目錄下,即

      cd C:\Qt\Qt5.8.0.8\msvc2013\bin

      1

      打包命令如下:

      windeployqt

      1

      即,你需要打包的exe全路徑

      windeployqt /path/file.exe

      1

      運行結果,如下

      C:\Qt\Qt5.8.0.8\msvc2013\bin>windeployqt E:-Pccamer\DesConsole\build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\debug\app\file.exe E:-Pccamer\DesConsole\build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\debug\app\PCCamer.exe 32 bit, debug executable Adding Qt5Svg for qsvgicond.dll Skipping plugin qtvirtualkeyboardplugind.dll due to disabled dependencies. Direct dependencies: Qt5Core Qt5Multimedia Qt5Widgets All dependencies : Qt5Core Qt5Gui Qt5Multimedia Qt5Network Qt5Widgets To be deployed : Qt5Core Qt5Gui Qt5Multimedia Qt5Network Qt5Svg Qt5Widgets Warning: Cannot find Visual Studio installation directory, VCINSTALLDIR is not set. Updating Qt5Cored.dll. Updating Qt5Guid.dll. Updating Qt5Multimediad.dll. Updating Qt5Networkd.dll. Updating Qt5Svgd.dll. Updating Qt5Widgetsd.dll. Updating libGLESV2d.dll. Updating libEGLd.dll. Updating D3Dcompiler_47.dll. Updating opengl32sw.dll. Patching Qt5Cored.dll... Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/audio. Updating qtaudio_windowsd.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/bearer. Updating qgenericbearerd.dll. Updating qnativewifibearerd.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/iconengines. Updating qsvgicond.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/imageformats. Updating qgifd.dll. Updating qicnsd.dll. Updating qicod.dll. Updating qjpegd.dll. Updating qsvgd.dll. Updating qtgad.dll. Updating qtiffd.dll. Updating qwbmpd.dll. Updating qwebpd.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/mediaservice. Updating dsengined.dll. Updating qtmedia_audioengined.dll. Updating wmfengined.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/platforms. Updating qwindowsd.dll. Creating directory E:/9-Pccamer/DesConsole/build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug/debug/app/playlistformats. Updating qtmultimedia_m3ud.dll. Creating E:-Pccamer\DesConsole\build-DesConsole-Desktop_Qt_5_8_0_MSVC2013_32bit-Debug\debug\app\translations... Creating qt_ca.qm... Creating qt_cs.qm... Creating qt_de.qm... Creating qt_en.qm... Creating qt_fi.qm... Creating qt_fr.qm... Creating qt_he.qm... Creating qt_hu.qm... Creating qt_it.qm... Creating qt_ja.qm... Creating qt_ko.qm... Creating qt_lv.qm... Creating qt_pl.qm... Creating qt_ru.qm... Creating qt_sk.qm... Creating qt_uk.qm...

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      40

      41

      42

      43

      44

      45

      46

      47

      48

      49

      50

      51

      52

      Windows設備信息獲取:(攝像頭,聲卡為例)Qt,WindowsAPI對比說明(2)

      53

      54

      55

      56

      57

      58

      59

      60

      61

      打包完的目錄結構如下。

      即可打包完成,不兼容問題,就這樣解決了。

      其他相關

      從目錄結構上來看,可能其他系統不兼容的問題,是由于,audio,mediaservice,imageformats,playlistformats幾個目錄下的文件缺失導致的。

      建議,也算個人經驗吧,以后打包Qt可執行程序時盡量使用官方打包軟件。

      API Qt Windows

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:一個來自“天府之國”的邀約
      下一篇:vuepress和pages搭建專業的博客
      相關文章
      亚洲a无码综合a国产av中文| 亚洲日本VA午夜在线影院| 亚洲熟女精品中文字幕| 亚洲色图.com| 久久亚洲精品成人av无码网站| 精品久久香蕉国产线看观看亚洲| 亚洲一区二区精品视频| 在线精品亚洲一区二区三区| 国产成人毛片亚洲精品| 在线观看亚洲成人| 中文字幕久久亚洲一区 | 亚洲一区二区三区四区视频| 亚洲精品无码久久久久久久| 综合自拍亚洲综合图不卡区| 亚洲综合亚洲国产尤物| 亚洲成综合人影院在院播放| 亚洲乱码日产精品BD在线观看| 亚洲一区中文字幕在线观看| 亚洲国产日韩综合久久精品| 亚洲偷偷自拍高清| 亚洲精品无码你懂的| 国产成人精品久久亚洲高清不卡| 国产成人综合亚洲绿色| 亚洲男女内射在线播放| 国产亚洲精品免费视频播放| 亚洲国产无套无码av电影| 亚洲爆乳无码专区| 亚洲视频欧洲视频| 国产精品亚洲片在线va| 亚洲日韩一区二区一无码| 亚洲色偷偷综合亚洲AV伊人蜜桃 | 亚洲午夜久久久影院| 亚洲va中文字幕无码久久不卡| 亚洲AV日韩AV永久无码下载| 亚洲黄色三级视频| 亚洲情A成黄在线观看动漫软件 | 亚洲第一二三四区| 国产精品亚洲一区二区麻豆| mm1313亚洲国产精品无码试看| 亚洲伊人成无码综合网 | 亚洲av再在线观看|