Ubuntu16.04下用luvcview對攝像頭功能調試(一)

Ubuntu16.04下用luvcview對攝像頭功能調試(一)

今天從老師那got了個攝像頭和lucview的源碼包,隨後的幾天裏將用這個工具對攝像頭進行調試,希望能夠在PC上調通(各種功能,如自動白平衡、gamma矯正,自動曝光,增益等),以便後續移植到板子上。。

環境搭建

安裝依賴
 sudo apt-get install debhelper
 sudo apt-get install libsdl1.2-dev
 sudo apt-get install libv4l-dev
 sudo apt-get install pkg-config

將兩個文件夾解壓,進入,命令行執行make

make

報錯1:

... linux/videodev.h : No such file or directory

解決1:

ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h

報錯2:

...fatal error :SDL/SDL.h :沒那個文件或目錄 No such file or directory

解決2:
很明顯有是缺少環境依賴了

apt-get install libsdl1.2-dev

前面一開始不是裝了???(沒裝起難道?)再裝了一次,不報錯了

命令窗口執行

make一下,ok

插上usb攝像頭,插上之前,個人喜歡監測一下日誌消息(方便查看USB的設備的節點映射,產品PID,VID等)

tail -f /var/log/syslog

部分結果顯示

...
Jul 22 13:55:43 lowfree02 kernel: [19028.269735] usb 3-5: new high-speed USB device number 5 using xhci_hcd
Jul 22 13:55:43 lowfree02 kernel: [19028.635065] usb 3-5: New USB device found, idVendor=046d, idProduct=0825
Jul 22 13:55:43 lowfree02 kernel: [19028.635071] usb 3-5: New USB device strings: Mfr=0, Product=0, SerialNumber=2
Jul 22 13:55:43 lowfree02 kernel: [19028.635075] usb 3-5: SerialNumber: 14961B90
Jul 22 13:55:43 lowfree02 kernel: [19028.635901] uvcvideo: Found UVC 1.00 device <unnamed> (046d:0825)
Jul 22 13:55:43 lowfree02 kernel: [19028.726084] uvcvideo 3-5:1.0: Entity type for entity Extension 4 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726088] uvcvideo 3-5:1.0: Entity type for entity Extension 6 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726091] uvcvideo 3-5:1.0: Entity type for entity Extension 7 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726094] uvcvideo 3-5:1.0: Entity type for entity Processing 2 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726096] uvcvideo 3-5:1.0: Entity type for entity Extension 3 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726099] uvcvideo 3-5:1.0: Entity type for entity Camera 1 was not initialized!
Jul 22 13:55:43 lowfree02 kernel: [19028.726350] input: UVC Camera (046d:0825) as /devices/pci0000:00/0000:00:14.0/usb3/3-5/3-5:1.0/input/input12
Jul 22 13:55:45 lowfree02 kernel: [19030.069056] usb 3-5: set resolution quirk: cval->res = 384
Jul 22 13:55:45 lowfree02 mtp-probe: checking bus 3, device 5: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-5"
Jul 22 13:55:45 lowfree02 mtp-probe: bus: 3, device: 5 was not an MTP device
Jul 22 13:55:45 lowfree02 systemd-udevd[27428]: Process '/usr/sbin/alsactl -E HOME=/run/alsa restore 1' failed with exit code 99.
Jul 22 13:55:45 lowfree02 pulseaudio[2078]: [pulseaudio] source.c: Default and alternate sample rates are the same.
Jul 22 13:55:45 lowfree02 rtkit-daemon[1032]: Supervising 3 threads of 1 processes of 1 users.
Jul 22 13:55:45 lowfree02 rtkit-daemon[1032]: Successfully made thread 27436 of process 2078 (n/a) owned by '1000' RT at priority 5.
Jul 22 13:55:45 lowfree02 rtkit-daemon[1032]: Supervising 4 threads of 1 processes of 1 users.

在dev/下看看vedio設備節點映設名

ls /dev

在這裏插入圖片描述
然後執行執行程序

# ./luvcview -d /dev/video0 -f yuv -s 640x480

在這裏插入圖片描述下面來看看這些功能能否正常進行


果然有些功能現在是有問題的。。那麼現在得進入源碼裏面去看看到底發生了什麼。。
調試工具就用VScode吧

調試準備

直接用vscode打開再按F5是8行的,得改點東西

報錯3
vscode對話框:

launch:program .... dose not exist

然後可以 直接open launch.json
解決3:
很簡單,進入該文件後將“program”這一行改爲:

"program": "{workspaceFolder}/luvcview",

後面的/luvcview是我make生成的執行文件名稱,這個依照自己生成的名稱修改
然後由於我們執行的時候是帶了參數,所以在緊跟着的下面一行,改爲

"args": ["-d","/dev/video0/","-f","yuv","-s","640x480"],

另外,按ctrl+shift+p打開控制檯,輸入task。。進入configure task,點擊按照模板,再點others,即創建了個task.json
修改

"command":"make"

ok,這下可以在VScode中調試了,
一按F5。。我去,,剛剛都還是呵呵噠。。DEBUGCONSOLE報錯
報錯4

Stopping due to fatal error: NullReferenceException: Object reference not set to an instance of an object

解決4
github裏大家說這是官方bug。。。附上鍊接
https://github.com/Microsoft/vscode-cpptools/issues/2922

有說把launch.json中"externalConsole"值設爲"false"。。無效
找了一圈,,算了重新解壓,用VScode打開,F5,看到左上debug旁邊的齒輪符號有個小紅點,點它,然後可生成一個launch.json,按照前面的進行修改,完畢,F5,ojbk。

*注意: 由於這裏的command 爲make 所以Makefile中在寫gcc或g++編譯命令時注意帶上 -g,否則可能出不來調試信息

如下在這裏插入圖片描述(先打斷點,再make)然後就可以進行調試了
在這裏插入圖片描述接下來的任務:
找到各種功能(前面的曝光、gamma校正、白平衡等)的實現接口,分析攝像頭其他不能(未)實現功能的接口(以及攝像頭本身是否支持這些功能?)

Ubuntu16.04下用luvcview對攝像頭功能調試(二)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章