Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 系統安裝 USB 攝影機驅動程式實戰:以 SPCA5xx 晶片為例

編輯:Linux 教學

前言

在 Linux 系統下使用 USB 攝影機進行影像擷取,關鍵在於核心是否內建對應驅動。若無內建,需自行編譯安裝第三方驅動。本文以 RedHat Enterprise Linux AS 4、中星微 ZC0301 晶片(需 SPCA5xx 驅動)為例,記錄完整編譯安裝流程。

硬體與環境

  • 作業系統:RedHat Enterprise Linux AS 4(完整安裝)
  • 攝影機晶片:ZC0301(SPCA5xx 系列)
  • 核心來源碼:已安裝 kernel-source 或 kernel-devel 套件
  • 編譯工具:gcc、make 等開發套件

驅動程式取得

下載位址:https://mxhaard.free.fr/spca50x/Download/oldrelease/

  • spca5xx-20060501.tar.gz:核心驅動模組
  • spcaview-20050501.tar.gz:使用者空間檢視工具
  • sdl-1.2.12.tar.gz:SPCAView 依賴的 SDL 圖形庫

編譯安裝步驟

1. 安裝 SPCA5xx 核心驅動

# tar zxvf spca5xx-20060501.tar.gz
# cd spca5xx-20060501
# make
# make install

驅動模組將安裝至 /lib/modules/$(uname -r)/kernel/drivers/usb/media/,並自動更新模組相依關係。

2. 安裝 SDL 圖形庫

# tar zxvf sdl-1.2.12.tar.gz
# cd sdl-1.2.12
# ./configure
# make
# make install

預設安裝至 /usr/local/lib,執行 ldconfig 更新動態連結庫快取。

3. 安裝 SPCAView 檢視工具

# tar zxvf spcaview-20050501.tar.gz
# cd spcaview-20050501
# make
# make install

執行檔安裝至 /usr/local/bin/spcaview。

4. 更新 PATH 環境變數

# echo 'export PATH=$PATH:/usr/local/bin' >> /etc/profile
# source /etc/profile

5. 重新開機或手動載入模組

# reboot
# 或
# modprobe spca5xx

影像擷取測試

# spcaview -f yuv -o test.avi
  • -f yuv:指定輸出格式為 YUV
  • -o test.avi:輸出檔案名稱

若畫面正常顯示,即代表驅動安裝成功。

常見問題與解決

問題可能原因解決方案
make 報錯缺少 linux/videodev.h核心來源碼未安裝或版本不符安裝 kernel-devel-$(uname -r),確認 /lib/modules/$(uname -r)/build 指向正確
裝置節點 /dev/video0 不存在驅動未正確載入dmesg | grep spca5xx 檢查核心訊息,確認模組載入無誤
SPCAView 編譯失敗找不到 SDLSDL 未安裝或 pkg-config 路徑錯誤確認 sdl-config --cflags --libs 有輸出,必要時設定 PKG_CONFIG_PATH

現代系統提示

目前主流發行版(Ubuntu 20.04+、CentOS 8+、Debian 10+)核心已內建 gspca 子系統支援大多數 SPCA5xx 晶片,插上即用,無需手動編譯。僅在舊版核心或特殊晶片時才需參考本文流程。

Copyright © Windows教程網 All Rights Reserved