We are about to switch to a new forum software. Until then we have removed the registration on this forum.
im looking to click on the draw window when is open and click on a face but without using the mouse to do so, it be better if processing had a voice recognition library but since im yet to come across such sketch i like to simulate a mouse click with a given screen x&y coord'n
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture video;
OpenCV opencv;
void setup() {
size(640, 480);
video = new Capture(this, 640/2, 480/2, "360HD Hologen");
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(0, 255, 0);
strokeWeight(1);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
}
Answers
http://docs.Oracle.com/javase/8/docs/api/java/awt/Robot.html#mousePress-int-
https://forum.Processing.org/two/discussions/tagged/robot
@GotToLoop thanks for your time, listen is there a link more specific to making a mouse left click simulation happen? this is all i need really,
this is what i got and lol im lost, i know this is a whole diff code but im moving kinda fast as im finding new way to do what i need done so this code is better because even if there was no face i can just click on the screen it self and that would be just fine and easy to adapt i guess VS if im only looking for a face to click on then i be fucked if i came across multiple faces "then what ? " so i think for now i just need to get familiar with this simulators first
this code though it is not compiling
You can't have functions defined inside others. Move mousePress and moveMove outside the draw function.
You java.awt.Robot object is called robot, but mousePress() doesn't have the object there. So its:
robot.mousePress();
The InputEvent.BUTTON1_MASK is just an integer. It tells mousePress which button to click.
In order to use InputEvet, you need to include it also.
import java.awt.event.InputEvent;
Look at this function I made which minimizes a maximized window and returns the mouse to the center of the screen:
thanks! i got it now, now one last thing ....if i want to call this function in the middle of another function, how do i call this func and then after the move and click has been done close that func and still remain on the original function prior to calling the simulate func?
i would like to call it via serial 'meaning assign a string so that i can initiate that simulate click' from visualStudio using serial port.
i mean i know how to write the whole serial part what i mean is that i dont know the structure require to have face detection on and while is on i would call via serial the simulate click function .
then after the SimClk() do its thing exit(); but not exit() the facedetect or any other function that was running prior to SimClk(), basically i dont want processing to ever end because he point is that i wont be in reach of the pc to click run again
@quark i mean i know how to write the whole serial part what i mean is that i dont know the structure require to have face detection on and while is on i would call via serial the simulate click function .