landino
YaBB Newbies
Offline
Posts: 2
Re: Control mouse coordinates
Reply #9 - Apr 6th , 2010, 12:39pm
I have been running into an error trying to run code in processing, I 'm getting the error message "Cannot find a class or type named Robot ". I don't have too much experience with java so I'm guessing my problem may be from me overlooking something that should be obvious. I'm attempting to create a FTIR setup using openCV and have had great results so far except for using the robot class. I appreciate any help or advice. Thanks! [code]// FTIR Multitouch Server // Kyle Doerksen. IDEO. 2008 /* This blobThreshold is overwritten by the calibration XML file, so this is only for initial use */ float blobThreshold=0.12; /* Set this to true if you're using a fisheye lens */ boolean doFisheyeCorrect = false; /* This is the threshold of how far a blob can move before it is considered a new blob. This is actually the square of the number of pixels moved, so in this case 30^2 = 900. */ int distanceThreshold = 900; import proxml.*; // library for xml read write (used for configuration files import processing.net.*; // used for network connectivity -- sends finger co-ordinates over a socket import blobDetection.*; // used for interpreting webcam image import JMyron.*; // used for camera connectivity JMyron m; //a camera PFont font; // need a font if we're going to use text Server touchServer; // server object to handle communication of touch events int MINIMUM_DRAW=1; // allows multiple levels of graphical verbosity. int NORMAL_DRAW=2; // once everything is dialed in, minimum_draw level should be used. int MAX_DRAW=3; int drawLevel=MAX_DRAW; // higher drawing levels provide more useful information but slow down the execution. // Perspective correction int HEIGHT=768; int WIDTH=1024; int edgeDistance=250; // these are the points used for calibration double calX[] = { edgeDistance,WIDTH/2,WIDTH-edgeDistance,WIDTH-edgeDistance,WIDTH-edgeDistance,WI DTH/2,edgeDistance,edgeDistance}; double calY[] = { edgeDistance,edgeDistance,edgeDistance,HEIGHT/2,HEIGHT-edgeDistance,HEIGHT-edgeD istance,HEIGHT-edgeDistance,HEIGHT/2}; double measuredX[] = { 0,0,0,0,0,0,0,0}; double measuredY[] = { 0,0,0,0,0,0,0,0}; int nCalPoints =8; // must be equal to the length of the above arrays perspectiveCorrection cal = new perspectiveCorrection(); int calibrating=-1; // cursors boolean mouseEmulation=false; // generates mouse messgages and clicks if true. TuiCursorList cursorList=new TuiCursorList(); Exception e; // Video Capture/Blob Detection stuff: BlobDetection theBlobDetection; // this handles blob tracking PImage img; // the current frame from the webcam PImage bgimg; // the background image boolean newFrame=false; int oldnBlobs; XMLInOut xmlInOut; void setup() { font = loadFont("CourierNew36.vlw"); textFont(font); // strangely, because our xmlEvent function is part of the PerspectiveCorrection class // we pass cal as the second parameter to this constructor to indicate where to look for that xmlEvent function xmlInOut = new XMLInOut(this, cal); size(WIDTH, HEIGHT); // Size of applet imageMode(CORNER); m = new JMyron();//make a new instance of the object m.start(320,240);//start a capture at 320x240 m.findGlobs(0);//disable the intelligence to speed up frame rate // BlobDetection // img which will be sent to detection (a smaller copy of the cam frame); img = new PImage(320,240); bgimg = new PImage(img.width, img.height); theBlobDetection = new BlobDetection(img.width, img.height); theBlobDetection.setPosDiscrimination(true); cal.readCalibration(xmlInOut); // will detect bright areas whose luminosity > blobThreshold; theBlobDetection.setThreshold(blobThreshold); touchServer = new Server(this, 11000); } float startTime; void draw() { m.update();//update the camera view if(drawLevel>=NORMAL_DRAW){ background(0,0,0); } m.imageCopy(img.pixels); if(frameCount==12) // waits twelve frames for things to stabilize and then captures the background image. { bgimg.copy(img,0,0,img.width, img.height,0,0,img.width, img.height); fastblur(bgimg,2); } fastblur(img, 2); // fast blur filters out some spatial noise. // background subtraction Diff(img,bgimg); // calculates the difference between the image and the original background image theBlobDetection.computeBlobs(img.pixels); if(drawLevel==MAX_DRAW) { img.updatePixels(); image(img,0,0,width,height); drawBlobsAndEdges(true,true); } int nBlobs = theBlobDetection.getBlobNb(); Blob myBlob; Point correctedPoint = new Point(); float r, r_corrected; float theta; float x_cor, y_cor; int i; CursorObject curObject; for(i=0;i<nBlobs;i++) { myBlob = th