I think gesture recognition would be more exciting if you could control things in real world with your gestures... So here's how to do it using Arduino. Since it just uses serial communication, this can also be done with some usb to serial adapters....
This simulation actually shows how to control of an led (to get started with) with some clicking over the screen with fingers in the air.....
Click here to download matlab source...
Here's a Demo video....
And here's the arduino code...
//Initializing variables...
int incomingByte = 0;
int led = 12;
int blnk = 0;
int del = 500;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
//Main loop...
if (Serial.available() > 0) {
incomingByte = Serial.read();
switch (incomingByte) {
//ASCII value for 'A'
case 65:
digitalWrite(led,HIGH);
blnk = 0;
break;
case 66:
digitalWrite(led,LOW) ;
blnk = 0;
break;
case 67:
blnk = 1;
break;
}
}
if (blnk==1){
digitalWrite(led,HIGH);
delay(del);
digitalWrite(led,LOW);
delay(del);
}
}
You can also check the following link where you can find library over this....
hi man, thanks for the tutorial.
ReplyDeletethe matlab source code lacks of some other function...
Undefined function 'getCameraInfo' for input arguments of type 'struct.
Would you please upload them too
Hey Taro!! Sorry for that...Use this code as getCameraInfo.m function file
ReplyDeletefunction [camera_name, camera_id, resolution] = getCameraInfo(a)
camera_name = char(a.InstalledAdaptors(end));
camera_info = imaqhwinfo(camera_name);
camera_id = camera_info.DeviceInfo.DeviceID(end);
resolution = char(camera_info.DeviceInfo.SupportedFormats(end));
your project was really superb.....
ReplyDeleteThank you
Deletehi, i'm getting these errors.......:
ReplyDeleteError in getCameraInfo (line 2)
camera_name = char(a.InstalledAdaptors(end));
Error in MatlabArduino (line 17)
[camera_name, camera_id, format] = getCameraInfo(a);
camera_name = char(a.InstalledAdaptors(end));
Deletea.InstalledAdaptors returns the installed camera adapters on your pc.
Check what is returned when you give that command.
Thanks for the reply, i'm using matlab 2015a version.Startech 1.3mp webcam how to check my device adopters.... sir, pls help me out.
ReplyDeleteC:\Program Files\MATLAB\MATLAB Production Server\R2015a\toolbox\imaq\imaqadaptors\kit\test
ReplyDeleteis this the folder contains data regarding my adopters
when i run the .M file in the follwoing location it shows C:\MATLAB\SupportPackages\R2015a\usbwebcams\toolbox\matlab\webcam\supportpackages
ReplyDeletewebcam with properties:
Name: 'STARTEC 1.3MP Webcam'
Resolution: '640x480'
AvailableResolutions: {1x16 cell}
BacklightCompensation: 1
Contrast: 57
Sharpness: 10
Gamma: 3
Brightness: 30
Saturation: 2
Try running these two commands in matlab command window..
ReplyDeletea = imaqhwinfo;
a.InstalledAdaptors
you should get something like this..
a.InstalledAdaptors
ans =
'xxxx' 'xxx'
>> a = imaqhwinfo;
ReplyDeletea.InstalledAdaptors
ans =
'dcam'
is that ok, should i need anything more to install
I think dcam alone is enough...
ReplyDeleteSince, u have only one adaptor installed, used this as getCAmeraInfo function file..
function [camera_name, camera_id, resolution] = getCameraInfo(a)
camera_name = char(a.InstalledAdaptors(1));
camera_info = imaqhwinfo(camera_name);
camera_id = camera_info.DeviceInfo.DeviceID(1);
resolution = char(camera_info.DeviceInfo.SupportedFormats(1));
%note that I have just changed end by 1.
still getting the same error....
ReplyDeleteWarning: No Image Acquisition adaptors found. Image acquisition adaptors may be available as
downloadable support packages. Open Support Package Installer to install additional vendors.
Subscript indices must either be real positive integers or logicals.
Error in getCameraInfo (line 2)
camera_name = char(a.InstalledAdaptors(end));
Error in MatlabArduino (line 18)
[camera_name, camera_id, format] = getCameraInfo(a);
sir, i got finally my thing work.... by installing "win video" drivers..... thanks for your help.... thanks alot....
ReplyDeleteGlad you solved it.. I was going to send you this link http://in.mathworks.com/help/imaq/installing-the-support-packages-for-image-acquisition-toolbox-adaptors.html
ReplyDeletesome how.... i managed to get webcam to run on matlab.... some times i'g getting error like
ReplyDeleteIndex exceeds matrix dimensions.
Error in MatlabArduino (line 80)
bb = round(stats(1).BoundingBox);
The program has its limitations.. The threshold value needs to be adjusted for different environments (lighting). When there is nothing detected after thresholding, size of the stats becomes zero. Hence accesing stats(1) will exceed dimensions.
ReplyDeletewhat changes had to be made if i want to add more devices, like fan tv ac etc.....as a buttons like led and blink
ReplyDeletesir, finally, i've done similar to your project... this is the video link
ReplyDeletehttps://www.youtube.com/watch?v=f5n8XYpAOww
Congrats.. That was great.. :) and don't call me sir.. I have just completed my engineering.. I have also seen your other projects on YouTube.. That were awesome.. Keep making things.. And thanks for sharing :)
Deletethanks for your complements... i'm looking to build a mind controlled home automation system...will take some time to make this thing work.
ReplyDelete