Class WebCam

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byWebCam
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, javax.swing.RootPaneContainer, java.io.Serializable, vxp.VideoListener, javax.swing.WindowConstants, java.awt.event.WindowListener
Direct Known Subclasses:
MotionDetectorCam, SoundCam, SubCam

public class WebCam
extends javax.swing.JFrame
implements java.awt.event.WindowListener, vxp.VideoListener, java.awt.event.KeyListener, java.awt.event.MouseListener

Author:
DanO This is a sample class that students can extend to create interesting web cams
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void cleanUp()
          You always need to clean up
 void ftp_utility(java.lang.String localPath, java.lang.String localFilename, java.lang.String serverLogin, java.lang.String serverPassword, java.lang.String serverAddress, java.lang.String serverPath, java.lang.String serverFilename)
          This does not work with secure ftp but if you have a regular ftp server it will
 float getAmountOfChange(int _threshold)
           
 java.util.ArrayList getChangeRects(int _threshold)
          Homework someone should write this by modifying the above
 java.lang.String getTimeString()
          For giving your picture and arbitraty title
 void grabPicture(java.awt.image.BufferedImage _ff)
          Grabs a frame and then puts it into a bufferedImage.
 void grabReference()
          This stores the current frame for future reference.
 void initVideo()
          This cranks up the video by creating a pixelSource object.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
          This is a method that you promised to have as a KeyListener.
 void keyTyped(java.awt.event.KeyEvent e)
           
static void main(java.lang.String[] Args)
          The is the entry point for your program You will definitely want to override this and then get out of it as soon as possible
 void makeJPegFile(java.awt.image.BufferedImage bi, java.lang.String pathname, java.lang.String filename, float quality)
          Turn a bufferedImage into a jpeg.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void newFrame()
          This is the method that pixel source uses to tell you that a new frame is ready.
 void paint(java.awt.Graphics g)
          This gets called everytime you repaint the screen.
 void postFileToITP(java.lang.String _localPath, java.lang.String _localFilename, java.lang.String _pathname, java.lang.String _filename)
          This connects with a php script (see below) that takes in a picture and puts it somewhere on itp.nyu.edu.
 void put(java.lang.String s)
          This is a convenience because hate typing "System.out.println" In this way you can rewrite java to your tastes.
 void update(java.awt.Graphics g)
          This overrides the update method of JFrame which gets called on repaint.
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
          This is a method that you promised to have as a WindowListener.
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Method Detail

initVideo

public void initVideo()
This cranks up the video by creating a pixelSource object. It also subscribes to the video listener, of course I would have to have previously promised to implement a VideoListener and then implement "newFrame" You might consider overriding this if you want a different kind of video object or don't want to subscribe to the notification service.


main

public static void main(java.lang.String[] Args)
The is the entry point for your program You will definitely want to override this and then get out of it as soon as possible


cleanUp

public void cleanUp()
You always need to clean up


newFrame

public void newFrame()
This is the method that pixel source uses to tell you that a new frame is ready. You have to have this if you want to implement a VideoListener

Specified by:
newFrame in interface vxp.VideoListener

update

public void update(java.awt.Graphics g)
This overrides the update method of JFrame which gets called on repaint. The reason I don't like JFrames is because it clears the screen (which I don't need) and creates flicker doing it. I redo the method with a paint but no clear


paint

public void paint(java.awt.Graphics g)
This gets called everytime you repaint the screen. You would want to override this if you want anything but side by side pictures


put

public void put(java.lang.String s)
This is a convenience because hate typing "System.out.println" In this way you can rewrite java to your tastes.


windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
This is a method that you promised to have as a WindowListener.

Specified by:
windowClosing in interface java.awt.event.WindowListener

grabPicture

public void grabPicture(java.awt.image.BufferedImage _ff)
Grabs a frame and then puts it into a bufferedImage.


grabReference

public void grabReference()
This stores the current frame for future reference.


keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
This is a method that you promised to have as a KeyListener. For homework you might try to replace the last part with different input than a keystroke

Specified by:
keyReleased in interface java.awt.event.KeyListener

makeJPegFile

public void makeJPegFile(java.awt.image.BufferedImage bi,
                         java.lang.String pathname,
                         java.lang.String filename,
                         float quality)
Turn a bufferedImage into a jpeg.


getAmountOfChange

public float getAmountOfChange(int _threshold)

getChangeRects

public java.util.ArrayList getChangeRects(int _threshold)
Homework someone should write this by modifying the above


ftp_utility

public void ftp_utility(java.lang.String localPath,
                        java.lang.String localFilename,
                        java.lang.String serverLogin,
                        java.lang.String serverPassword,
                        java.lang.String serverAddress,
                        java.lang.String serverPath,
                        java.lang.String serverFilename)
This does not work with secure ftp but if you have a regular ftp server it will


getTimeString

public java.lang.String getTimeString()
For giving your picture and arbitraty title


postFileToITP

public void postFileToITP(java.lang.String _localPath,
                          java.lang.String _localFilename,
                          java.lang.String _pathname,
                          java.lang.String _filename)
This connects with a php script (see below) that takes in a picture and puts it somewhere on itp.nyu.edu. You can supply your directory for example /home/netid/public_html/bla but you have to change the permissions of your bla folder to be world writable. This is dubious so I might shut it down after this week.


windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener