gigertron
YaBB Newbies
Offline
Posts: 13
Yet another webcam question
Mar 24th , 2009, 6:18am
I've got video capture and ftp connection working, but the upload fails for some reason. I don't know how to debug why... not sure if it's that my local dir isn't specified right or if there's some other thing. Here's the code. I'm able to connect to my site and get the dir listing, so I know THAT much works. /** ftp taken from http://processinghacks.com/hacks:ftp @author Mark Hill */ FTPClient ftp; import processing.video.*; Capture cam; // Populate these variables with the necessary info. String host = "website.com"; String username = "mrguy"; String password = "888888888"; String remotePath = ""; String localPath = "C:/Users/Duck/Documents/Processing/FTPthinger"; int frameCount=1; void setup () { size(320,240); cam = new Capture(this, 320,240); frameRate(1); } void draw() { // every so often, upload a pic if (cam.available() == true) { cam.read(); //image(cam, 0,0); // The following does the same, and is faster when just drawing the image // without any additional resizing, transformations, or tint. set(0,0, cam); } println ("Frames left until upload: " + frameCount); if(frameCount-- < 1) { frameCount=10; upload(); saveFrame("capture.jpg"); } } void upload() { try { ftp = new FTPClient(); // set up client ftp.setRemoteHost(host); FTPMessageCollector listener = new FTPMessageCollector(); ftp.setMessageListener(listener); // connect println ("Connecting"); ftp.connect(); // login println ("Logging in"); ftp.login(username, password); // set up passive ASCII transfers println ("Setting up passive, ASCII transfers"); ftp.setConnectMode(FTPConnectMode.PASV); ftp.setType(FTPTransferType.ASCII); // get directory and print it to console println ("Directory before put:"); String[] files = ftp.dir(".", true); for (int i = 0; i < files.length; i++) println (files[i]); // copy file to server println ("Putting file"); ftp.setType(FTPTransferType.BINARY); ftp.put("capture.jpg", "capture.jpg"); // get directory and print it to console println ("Directory after put"); files = ftp.dir(".", true); for (int i = 0; i < files.length; i++) println (files[i]); // Shut down client println ("Quitting client"); ftp.quit(); String messages = listener.getLog(); println ("Listener log:"); println(messages); println ("upload complete"); } catch (Exception e) { println ("upload failed"); } }