Virtual Mouse Project
조회 수: 5 (최근 30일)
이전 댓글 표시
Hey everyone, I'm doing a virtual mouse project by controlling the mouse pointer on the computer screen using a webcam to track movement of my hand n some mouse clicking event. I have to learn matlab from scratch n I've tried doing as possible as I can but still can't produce the right codes or thru simulink. Can anyone really help me on this bcuz I'm kinda desperate right now n I'm really don't know what I'm suppose to do next. If anyone can give me the codes or simulink models, that would be really helpful, thank u..
댓글 수: 7
Walter Roberson
2012년 4월 12일
You can only compile function .m, not script .m . Add a "function" line to your .m file.
답변 (9개)
Matt Kindig
2012년 4월 4일
Controlling the mouse pointer is actually a bit difficult, as you need to use the Java Robot class (it's not a Matlab function per se). I'm not even sure how you would access this via Simulink.
댓글 수: 1
Walter Roberson
2012년 4월 4일
Example Java Robot use of keyboard: http://www.mathworks.com/matlabcentral/answers/5259-how-to-simulate-keyboard-key-inputs
The Solution that Matt shows above has an example of mouse control.
You could use a MATLAB Function block to access this kind of code; you would create the robot for the initialization phase and give commands to the robot based upon the run-time input signals.
Teja Muppirala
2012년 4월 4일
MATLAB can move the mouse around:
x = 500;
y = 600;
set(0,'PointerLocation',[x y]);
But, I think you do need the Java Robot to make a click.
댓글 수: 1
Walter Roberson
2012년 4월 4일
Unless you can figure out which object you are over and locate its callback function and activate it, passing in a suitable "event" structure to represent right-click, shift-click etc.
Syahrul Fikri
2012년 4월 7일
댓글 수: 2
Walter Roberson
2012년 4월 7일
x = bc(1);
y = bc(2);
and then use the technical solution Matt referred to.
vaibhav mathur
2012년 4월 7일
put the value of red object's centroid in the [x y] mat. and set(0,'PointerLocation',[x y]); and the pointer moves according to centroid may be it work good luck!
댓글 수: 0
Syahrul Fikri
2012년 4월 8일
댓글 수: 4
vidit virmani
2013년 2월 19일
hey.... i feel lucky to find this page and the above discussion.... because i am too working on the same project of controlling mouse by color detectin methods.... i used the same code to detect a color.. i used blue instead of red.. i planned to execute the clicking events by manipulating the distance calculated between my finger and the thumb(both covered with a blue tape).. how can i do that....?? . . %% import java.awt.Robot; import java.awt.event.*; mouse = Robot; mouse.mouseMove(bc(1), bc(2)); mouse.mousePress(InputEvent.BUTTON2_MASK); mouse.mouseRelease(InputEvent.BUTTON2_MASK); %% do i have to use this code directly with the color detection code(as u have stated in above comment) or some prerequisites are to b done to interface java with MATLAB..?? please guide me for i am a new matlab user...
Aakash
2015년 1월 13일
Hi, could you please tell me how the clicking is done here...please...!! thanks..!
vidit virmani
2013년 2월 21일
@syahrul fikri : i used your code and its working... the mouse pointer moves and also clicks, but the problems i faced are..... 1) i dont know how the clicking operation is being executed.... does it executes when pointer is stable on a folder for some specified time or when another color is detected by the system?...... 2) if i move my hand to right , the pointer moves left and vice versa..... how to reverse that....... 3)if the camera resolution is less than the resolution of the screen, whole screen is not covered with this system.... how to eliminate this?..... 4)if i want to detect two different colors and execute clicking operations by manipulating the distance between the colors, how can i do that..?? please help....
댓글 수: 1
Rajshekar
2013년 4월 24일
@vidit: 2) this is normal mirror concept: hence the pointer position shall have the formula of [1024-x, 780-Y] where x and y are the original positions in your code. the numbers 1024 AND 780 SORT OF RESOLUTION OF YOUR SCREEN.It depends on your screen resolution.
Rajshekar
2013년 4월 24일
Hey i tried to check this interesting thing: i used java robot.was able to move pointer and click as well. But there is this thing : when i right clicked a block in simulink(ofcourse by java robot), menu drop down appeared as normal; in the next lines of codes, i meant to position cursor on one of the menu item so i tried to reposition and use right click to select the menu item. But by the time these lines were to execute, the menu was not visible and hence the menu item cannot be selected
i think the menu items disappears when next lines of codes starts execution because the script window activates.
Do you know how to avoid this disappearance of the menu.
댓글 수: 0
cpe111
2014년 12월 5일
Hey can you help me, please ? my project is how to control mouse by face , I have done face with nose and eyes detection , but I don't know how to control the cursor movements and clicking ! any help please ! because my matlab knowledge is so weak !
Thank you .
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!