While playing with webcams and computer vision is fun in it's own right, I've been thinking about the uses of my these programs, and came to the conclusion that they need to be run on machines that won't be a huge loss if they go missing or get stolen, I have an old Eee pc 701sd lying around that fits the bill nicely. An alternative would be a Raspberry Pi system, with an external webcam, but my budget doesn't extend to that at the moment.
The Xandros that comes on the Eee it is not well suited to development, and is well out of date these days, so I set about finding a new compact distro for it, and settled on Lucid Puppy, a very light weight, compact, ubuntu compatible build that can be run from usb.
I started using the universal installer to make a usb to trial it on - an exercise of it's own, you need to load bios each time, look at the hard drive order, save, then press esc, and choose the usb...
LuPu ran well, quite fluid, despite the dreadful specs of that machine with a external mouse and keyboard, and running a 17" monitor powered by an able-hd (www.able-hd.com) adaptor.
Because of the effort required to boot to USB I chose to install LuPu onto the sdd, removing the previous installs, and have finally got to the point where i can write, and compile c programs, so there is more to come.
A chronicle of my projects and plans, a record for myself, and a way to prevent others from making my mistakes.
Spontaneous projects may provide a path to follow, a dice to roll for your next project, or a place for ideas to grow and spread.
Tuesday, 31 December 2013
New use for old hardwarEee
'Copter update
There hasn't been a lot of progress on the copter over the last few weeks. I did ordered and recieve some more bits and pieces this month, from the international warehouse at Hobby King. I ordered some soldering gear, a few ESCs, and some more connectors, so that I can modify the design to enable the swapping of any and all components if they are damaged following a crash.
The wiring is finished, I need to program the ESC's, but that's about 5 minutes work, and I want to add a few good LEDs from an old headlamp to it on a 5v loom so that it can be flown in the dark. The plan is a single bright LED off the front, another broad beam pointing down, and a pair of red ones on the back rotors.
Still to go is the building of the frame, and to get a new flight controller. They agreed to do it under warranty, but it has been superseded by the KK2.1, which is not yet in the Australian warehouse. After new year I'll ask for credit and get it shipped from the international website.
update 6/1/14:
Just sent the email to them... hopefully I'll get a new board in a week or so
update 10/1/14:
They can't change which model I recieve, so they gave me $32 credit, and I bought the $30 KK2.1(which is now in Australia), plus $9.99 shipping... Not entirely happy, but at least something is happening.
Seemed like they didn't understand that it wouldn't be coming into stock, and that the 2.1 was a new model, despite the fact that I said that in both emails
The wiring is finished, I need to program the ESC's, but that's about 5 minutes work, and I want to add a few good LEDs from an old headlamp to it on a 5v loom so that it can be flown in the dark. The plan is a single bright LED off the front, another broad beam pointing down, and a pair of red ones on the back rotors.
Still to go is the building of the frame, and to get a new flight controller. They agreed to do it under warranty, but it has been superseded by the KK2.1, which is not yet in the Australian warehouse. After new year I'll ask for credit and get it shipped from the international website.
update 6/1/14:
Just sent the email to them... hopefully I'll get a new board in a week or so
update 10/1/14:
They can't change which model I recieve, so they gave me $32 credit, and I bought the $30 KK2.1(which is now in Australia), plus $9.99 shipping... Not entirely happy, but at least something is happening.
Seemed like they didn't understand that it wouldn't be coming into stock, and that the 2.1 was a new model, despite the fact that I said that in both emails
Friday, 13 December 2013
Time capsules and time lapses
Occasionally I use my Contour camera to record time lapses, generally of LAN parties, but the usual clouds and landscapes as well. The only issue with the contour is that the battery life is not great, about 3 hours taking photos every 15 seconds. One solution seemed to be that I could instead use the webcam on my laptop, or another device to record such events.
I also wanted to be able to analyse the images as they were taken so that ones without data could be discarded. This acts like the time capsules in police cars, if something of consequence occurs the computer records the last image, and several into the future on disk. otherwise it discards them.This has potential if i can wire it to an external camera for use at Kambah to track down the vandals, but was mostly just a fun exercise.
I used matlab to do the coding, although i may migrate to another language to create a standalone program.
For once it was easy to program, taking just one evening to get it to a working version, but enough of that. Here's the code:
function Webcam
% acts as an image logger for my hp computer, if anything in the image
% moves substantially, or the mean brightness of any column varies, then it
% takes that picture, and 15 to follow and writes them to a folder with the
% current date.
clc
clear
beep;
vid = videoinput('winvideo',1,'YUY2_640x480');
set(vid,'ReturnedColorSpace','grayscale');
start(vid)
mkdir(date)
go = 1;
beep;
pause(3)
beep;
pause(1)
beep;beep;
OldPic = getsnapshot(vid);
pause(4);
crimcount=1;
while go
pic = getsnapshot(vid);
% comparisons
olMean = mean(OldPic); % list of column means for the old image
NewMean= mean(pic);
% normalise them
olMean = olMean*mean(NewMean)/mean(olMean);
if min(olMean>0.95*NewMean)||min(olMean>1.05*NewMean)
change = 0; % No change from previous image
else
change = 1; % Change from previous image
%figure; imshow(pic);
image = 1; % reset image count
imagename=[date '/culprit' num2str(crimcount),num2str(image,'%02d'),'.jpg'];
imwrite(pic, imagename)
for i = 1:15
pic = getsnapshot(vid);
image = image+1;
imagename=[date '/culprit' num2str(crimcount),num2str(image,'%02d'),'.jpg'];
imwrite(pic, imagename)
pause(2)
end
crimcount=crimcount+1;
end
pause(3);
OldPic = pic;
end
% moves substantially, or the mean brightness of any column varies, then it
% takes that picture, and 15 to follow and writes them to a folder with the
% current date.
clc
clear
beep;
vid = videoinput('winvideo',1,'YUY2_640x480');
set(vid,'ReturnedColorSpace','grayscale');
start(vid)
mkdir(date)
go = 1;
beep;
pause(3)
beep;
pause(1)
beep;beep;
OldPic = getsnapshot(vid);
pause(4);
crimcount=1;
while go
pic = getsnapshot(vid);
% comparisons
olMean = mean(OldPic); % list of column means for the old image
NewMean= mean(pic);
% normalise them
olMean = olMean*mean(NewMean)/mean(olMean);
if min(olMean>0.95*NewMean)||min(olMean>1.05*NewMean)
change = 0; % No change from previous image
else
change = 1; % Change from previous image
%figure; imshow(pic);
image = 1; % reset image count
imagename=[date '/culprit' num2str(crimcount),num2str(image,'%02d'),'.jpg'];
imwrite(pic, imagename)
for i = 1:15
pic = getsnapshot(vid);
image = image+1;
imagename=[date '/culprit' num2str(crimcount),num2str(image,'%02d'),'.jpg'];
imwrite(pic, imagename)
pause(2)
end
crimcount=crimcount+1;
end
pause(3);
OldPic = pic;
end
To reduce processing I used grayscale images. They are compared as a mean value of the same column in each image, with a tolerence of 5%.
This makes it less sensitve than a region, or pixelwise comparison, but given that humans tend to move horizontally, and cover a large portion of a column this seemed like a good option. in addition the movement of the sun is largely vertical, so it should be ignored.
When a detection is made, the program writes the picture to a file, and then takes another 15 at ~2 second intervals, before returning to it's standby mode, looking for changes at 8 second intervals.
The program stores the images in a new folder with todays date, and numbers them #xx for the detection number, with xx being the picture the current sequence.
By running it from dropbox the files can be immediately uploaded to a cloud, allowing an offsite backup, as well as real time notifications. So far it has been running for 4 hours in m room, with 1 good detection, and zero false ones. The undetected ones I have no evidence for, but I suspect they are also absent, this will be ivestigated further this evening.
Subscribe to:
Posts (Atom)