displaying images using Parallax''s modified CMUcam
Archiver
Posts: 46,084
Does anyone know how to display images using Parallax's CMUcam for
the Boebot? I know you cannot directly dump an image but I was
thinking that maybe you could do rastor-like approach where you get
the RGB values for window sizes that increment across and down the
entire view window. I am currently trying to do this using the GM
(get the mean color) command and it returns RGB values but they
appear to be the same approximate color value. I am facing the
camera toward a multi brightly colored object and thus should see
some differing values. To view the image, I am taking the straight
RGB values and using Matlab to generate a picture. The code is below
for reference. The code below is for a 4-by-11 box but I have gotten
the same results with a 1-by-1 box.
Any help would be appreciated.
Michael
STAMP CODE********
'{$STAMP BS2p}
'{$PBASIC 2.5}
horiz Var Byte
vert Var Nib
horizvalue var byte
vertvalue var byte
RcvData Var Byte(20)
baud con 240
' Pause 1 second for CMUcam startup
pause 1000
'
Initialization beep
'
output 2
freqout 2, 2000, 2000
' Send "reset" to sync CMUcam and Stamp
serout 10,baud, [noparse][[/noparse]"RS", CR]
GOSUB WaitForACK
pause 1000
' Green LED on
serout 10,baud, [noparse][[/noparse]"L1 1",CR]
GOSUB WaitForACK
pause 100
' Turn on auto adjust for 5 seconds
serout 10,baud, [noparse][[/noparse]"CR 18 44",CR]
GOSUB WaitForACK
pause 100
' Pause 5 seconds for CMUcam to auto adjust to lighting conditions
pause 5000
' Turn off auto adjust
serout 10,baud, [noparse][[/noparse]"CR 18 44 19 33 45 7",CR]
GOSUB WaitForACK
pause 100
' Green LED auto mode
serout 10,baud, [noparse][[/noparse]"L1 2",CR]
GOSUB WaitForACK
pause 100
' Send command - Set poll mode - only sends one return packet -
' of data after each command - reduces data flow
serout 10,baud, [noparse][[/noparse]"PM 1",CR]
GOSUB WaitForACK
pause 100
' Send command - Set raw data mode - also suppress Ack:/Nak: to -
' further reduce serial data
serout 10,baud, [noparse][[/noparse]"RM 3",CR]
pause 100
Main:
pause 1000
debug "Red Green Blue X0 Y0 X1 Y1",CR
' Detect the mean RGB values for the 4x11 box in SW
for vert = 0 to 12 'vertical rastor
vertvalue=11*vert
GOSUB HorizRastor
NEXT
END
HorizRastor:
for horiz=0 to 19
horizvalue=4*horiz
serout 10,baud,[noparse][[/noparse]"SW horizvalue vertvalue (horizvalue+4)
(vertvalue+11)",CR]
GOSUB WaitforACK
serout 10,baud,[noparse][[/noparse]"GM",CR]
serin 9,baud,[noparse][[/noparse]STR RcvData\8]
debug DEC RcvData(2)," ",DEC RcvData(3)," ",DEC RcvData(4)
debug " ",DEC horizvalue," ",DEC vertvalue," "
debug " ",DEC (horizvalue+4)," ", DEC(vertvalue+11),CR
NEXT
RETURN
WaitForACK:
serin 9,baud, 1, Timeout, [noparse][[/noparse]Wait (":")]
Timeout:
RETURN
MATLAB CODE*****The RGB values are input into a text file after
displaying on the debug window
load rastorTWbig.txt
red=rastorTWbig(:,1);
green=rastorTWbig(:,2);
blue=rastorTWbigTWbigTWbigTWbig(:,3);
rpixels=reshape(red,13,20);
gpixels=reshape(green,13,20);
bpixels=reshape(blue,13,20);
rgb=cat(3,rpixels,gpixels,bpixels)
rgb=uint8(rgb);
imagesc(rgb);
the Boebot? I know you cannot directly dump an image but I was
thinking that maybe you could do rastor-like approach where you get
the RGB values for window sizes that increment across and down the
entire view window. I am currently trying to do this using the GM
(get the mean color) command and it returns RGB values but they
appear to be the same approximate color value. I am facing the
camera toward a multi brightly colored object and thus should see
some differing values. To view the image, I am taking the straight
RGB values and using Matlab to generate a picture. The code is below
for reference. The code below is for a 4-by-11 box but I have gotten
the same results with a 1-by-1 box.
Any help would be appreciated.
Michael
STAMP CODE********
'{$STAMP BS2p}
'{$PBASIC 2.5}
horiz Var Byte
vert Var Nib
horizvalue var byte
vertvalue var byte
RcvData Var Byte(20)
baud con 240
' Pause 1 second for CMUcam startup
pause 1000
'
Initialization beep
'
output 2
freqout 2, 2000, 2000
' Send "reset" to sync CMUcam and Stamp
serout 10,baud, [noparse][[/noparse]"RS", CR]
GOSUB WaitForACK
pause 1000
' Green LED on
serout 10,baud, [noparse][[/noparse]"L1 1",CR]
GOSUB WaitForACK
pause 100
' Turn on auto adjust for 5 seconds
serout 10,baud, [noparse][[/noparse]"CR 18 44",CR]
GOSUB WaitForACK
pause 100
' Pause 5 seconds for CMUcam to auto adjust to lighting conditions
pause 5000
' Turn off auto adjust
serout 10,baud, [noparse][[/noparse]"CR 18 44 19 33 45 7",CR]
GOSUB WaitForACK
pause 100
' Green LED auto mode
serout 10,baud, [noparse][[/noparse]"L1 2",CR]
GOSUB WaitForACK
pause 100
' Send command - Set poll mode - only sends one return packet -
' of data after each command - reduces data flow
serout 10,baud, [noparse][[/noparse]"PM 1",CR]
GOSUB WaitForACK
pause 100
' Send command - Set raw data mode - also suppress Ack:/Nak: to -
' further reduce serial data
serout 10,baud, [noparse][[/noparse]"RM 3",CR]
pause 100
Main:
pause 1000
debug "Red Green Blue X0 Y0 X1 Y1",CR
' Detect the mean RGB values for the 4x11 box in SW
for vert = 0 to 12 'vertical rastor
vertvalue=11*vert
GOSUB HorizRastor
NEXT
END
HorizRastor:
for horiz=0 to 19
horizvalue=4*horiz
serout 10,baud,[noparse][[/noparse]"SW horizvalue vertvalue (horizvalue+4)
(vertvalue+11)",CR]
GOSUB WaitforACK
serout 10,baud,[noparse][[/noparse]"GM",CR]
serin 9,baud,[noparse][[/noparse]STR RcvData\8]
debug DEC RcvData(2)," ",DEC RcvData(3)," ",DEC RcvData(4)
debug " ",DEC horizvalue," ",DEC vertvalue," "
debug " ",DEC (horizvalue+4)," ", DEC(vertvalue+11),CR
NEXT
RETURN
WaitForACK:
serin 9,baud, 1, Timeout, [noparse][[/noparse]Wait (":")]
Timeout:
RETURN
MATLAB CODE*****The RGB values are input into a text file after
displaying on the debug window
load rastorTWbig.txt
red=rastorTWbig(:,1);
green=rastorTWbig(:,2);
blue=rastorTWbigTWbigTWbigTWbig(:,3);
rpixels=reshape(red,13,20);
gpixels=reshape(green,13,20);
bpixels=reshape(blue,13,20);
rgb=cat(3,rpixels,gpixels,bpixels)
rgb=uint8(rgb);
imagesc(rgb);