2015年7月30日 星期四

[EV3]NXTCam-v4簡介

    NXTCam是一個即時的影像處理模組,具有內建處理器,並符合NXT標準輸入埠通訊協定的視覺模組。這個介面提供了NXTCam所見高階的、已處理的影像資料。此處理過的資料包含影像中物件的座標,在循線追蹤模式,它的資料包含了線段的座標圖、物件顏色、物件的數量、座標與線段的區塊座標系統


NXTCam並非送出原始影像到NXT,以USB線連接NXTCam電腦,可透過NXTCamView軟體檢視所見的圖像,透過USB埠傳輸給電腦的解析度可達176*144像素顏色影像。


NXTCam模組規格表
最大消耗電力
42mA at 4.7V
像素
88*144pixel
取樣速率
30fps
調整焦距
追蹤物件
最多可八個物件(須由使用者定義八個不同的顏色)


I2C使用的腳位為:SDA(1)GND(2)SCL(3)+5V(4)列出了暫存器位置與設置的指令。
 NXTCam模組I2C功能指令表
Commands
Action
ASCII
Hex
A
0x41
Sort tracked objects by size
B
0x42
Select Object tracking mode
C
0x43
Write to image sensor Registers
Use CAUTION when using command C since this can stop NXTCam from working properly. In case this happens, please power off your NXTCam and power it on again.
D
0x44
Disable Tracking
E
0x45
Enable Tracking
G
0x47
Get the Color map from NXTCam Engine
H
0x48
Read data from the image sensor Registers
I
0x49
Illumination on (Future)
L
0x4C
Select Line tracking mode
N
0x4E
Set ADPA mode ON (setting stored in NVRAM)
O
0x4F
Set ADPA mode Off (default) (setting stored in
NVRAM)
P
0x50
Ping NXTCam Engine
R
0x52
Reset NXTCam Engine
S
0x53
Send the color map to NXTCam Engine
T
0x54
Illumination Off
U
0x55
Sort tracked objects by color
V
0x56
Get NXTCam Engine firmware version No, Read resulting string at 0x42 (12 bytes).
X
0x58
Do not Sort tracked objects
J
0x4A
Lock tracking buffer
Tracking is going on continuously, and while you read buffer may be updated by the tracking engine.  You can issue this command to Lock the buffer updates. After issuing this command allow 25 milliseconds for any updates in progress to finish. Then read the tracking information.
K
0x4B
Unlock tracking buffer.
If you had locked the buffer before reading, ensure to unlock it after you are done reading.




NXTCam模組I2C暫存器位置表
Register
Read
Write
Comments
0x00-0x07
Software version (Vn.nn)
-

0x08-0x0f
Vendor Id mndsnsrs
-

0x10-0x17
Device ID NXTCam
-





0x41
-
Command
This register is command register.  A
command written here will be executed.
0x42
Number of objects detected
-
Shows how many objects are being tracked. Zero indicates that there are no objects being tracked.
0x43
1st object color
-
This is the first object color as per the sorting method selected.
0x441
1st object - X upper left

Upper left X coordinate of first object
0x45
1st object - Y upper left

Upper left Y coordinate of first object
0x46
1st object - X lower right

Lower right X coordinate of first object
0x472
1st object - Y lower right

Lower right Y coordinate of first object
0x48
2nd object color


0x49-0x4C
2nd object co-ordinates


0x4D
3rd object color


0x4E-0x51
3rd object co-ordinates


0x52
4th object color


0x53-0x56
4th object co-ordinates


0x57
5th object color


0x58-0x5B
5th object co-ordinates


0x5C
6th object color


0x5D-0x60
6th object co-ordinates




    焦距部分,NXTCam鏡頭設置2~4英尺之間為最佳的焦距,此鏡頭可自由旋轉,本身較緊防止意外地轉動與焦點晃動,輕輕地轉動支架鏡頭即可,不可太過用力,否則可能損壞鏡頭。
        內建自動暫停,一旦跟蹤模式開始,程式內讀取NXTCam的對象9秒內必須有動作,如果9秒內沒有動作,跟蹤模式會自動停止。
        NXTCam被設計在正常白光的環境下操作,影像擷取偏向紅色,很有可能外界光源與紅光有關,可以試著調整紅光讓影像處理更加精準,進一步的操作可以透過I2C暫存器來改變顏色增益、亮度和NXTCam的對比度。
        NXTCam的像素是88X144 NXTCam有兩種模式─物件追蹤模式(Object tracking mode)與循線模式(Line following mode)。使用物件追蹤模式時,NXTCam會將物體看作一個大方塊,並傳回方塊左上角與右下角的xy座標,我們只要經由簡單的換算便可以得知物體概略位置,而NXTCam最多可以同時追蹤八個不同的物體。在使用循線模式時,NXTCam會將物體切割成好幾個線段,並傳回每個線段兩個端點的xy座標