pi@boywhy-pi2:~ $ sudo apt-get install fswebcam
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
pypy-upstream-doc wiringpi
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
fswebcam
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 44.0 kB of archives.
After this operation, 105 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main fswebcam armhf 20140113-1 [44.0 kB]
Fetched 44.0 kB in 1s (35.9 kB/s)
Selecting previously unselected package fswebcam.
(Reading database ... 126790 files and directories currently installed.)
Preparing to unpack .../fswebcam_20140113-1_armhf.deb ...
Unpacking fswebcam (20140113-1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up fswebcam (20140113-1) ...
pi@boywhy-pi2:~ $
拍一張,存成test.jpg (採用預設的解析度,大概是320*240 左右)
fswebcam test.jpg
指定拍照解析度(如果Webcam不支援的話,fswebcam會自動調整成最接近的解析度)
fswebcam -r 1280x720 image2.jpg
訊息大致上長這個樣子,注意 Adjusting resolution from 1024x720 to 640x480. 代表相機不支援1024x720,被強制改成640x480了
pi@boywhy-pi2:~ $ fswebcam -p YUYV -r 1024x720 test.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 1024x720 to 640x480.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Writing JPEG image to 'test.jpg'.
pi@boywhy-pi2:~ $
以上拍照後,相片上都會有個banner寫著拍照時間等等,如果不要的話,可以加上
--no-banner這個參數,相片就不會有多餘的資訊被打上去。
fswebcam -r 1280x720 --no-banner image3.jpg
如果拍照出來是黑黑的一片,注意一下是否有發生如下的訊息
GD Error: gd-jpeg: JPEG library reports unrecoverable error: Not a JPEG file:
俺試了2支Webcam,羅技C310 是OK的,但是C 170 就會出現這個錯誤訊息。
俺查詢了相關資料後,做了一個嘗試,改變 palette format 為YUYV後正常,
推測應該是Webcam硬體支援上的問題。
pi@boywhy-pi2:~ $ fswebcam -p YUYV test.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
Captured frame in 0.00 seconds.
--- Processing captured image...
Writing JPEG image to 'test.jpg'.
pi@boywhy-pi2:~ $
1ENumber of bytes that follow in the advertisement
02Number of bytes that follow in first AD structure
01Flags AD type
1AFlags value 0x1A=000011010
bit 0(OFF) LE LimitedDiscoverableMode
bit 1(ON) LE GeneralDiscoverableMode
bit 2(OFF) BR/EDR NotSupported
bit 3(ON)Simultaneous LE and BR/EDR to SameDeviceCapable(controller)
bit 4(ON)Simultaneous LE and BR/EDR to SameDeviceCapable(Host)1ANumber of bytes that follow in second (andlast) AD structure
FF Manufacturer specific data AD type
4CCompany identifier code LSB
00Company identifier code MSB (0x004C==Apple)02Byte0 of iBeacon advertisement indicator
15Byte1 of iBeacon advertisement indicator
接下去則是UUID(16 byte)、Major (2 byte)、 Minor (2 byte)及 Tx Power等參數
UUID 服務識別碼: 這裡用來區別不同公司不同的系統。
Apple在它們自家的iBeacon服務中定義了 Apple AirLocate 其UUID開頭為
E2C56DB5 、5A4BCFCE 及 74278BDA。
上述的UUID就是採用 E2C56DB5 開頭的一組 Apple AirLocate UUID :
E2 C5 6D B5 DF FB 48 D2 B0 60 D0 F5 A7 10 96 E0
Major ID: 在同樣 UUID 的一群 iBeacon 發射器中為了區隔不同分類
定義以此Major Number (2 byte),例如喜宴會場 A 就定義為0001、會場B就定義0002
mkdir -p work/bluepy cd work/bluepy wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.31.tar.xz tar xvf bluez-5.31.tar.xz cd bluez-5.31 ./configure --disable-systemd
以下這一個指令執行會需要一段時間 make sudo make install