net.sf.jhawkingcam
Class HawkingCamera

java.lang.Object
  extended by net.sf.jhawkingcam.HawkingCamera

public class HawkingCamera
extends java.lang.Object

API for Hawking cameras. Automatically connects to camera and starts downloading images.

Author:
dillenbu

Constructor Summary
HawkingCamera(java.lang.String host, int port, java.lang.String username, java.lang.String password)
          Connect to camera at given host and port.
 
Method Summary
 void addFrameListener(FrameListener listener)
          Listen for camera images from this camera.
 java.awt.image.BufferedImage captureImage()
          Capture one image.
protected  void finalize()
           
 java.lang.String getHost()
          return the host this camera is connected to.
 java.awt.image.BufferedImage getLastImage()
          Get the last image captured by this camera, whether it was during a video capture or from a call to captureImage().
 java.util.Date getLastImageTimestamp()
          Get the timestamp of the last image seen by this camera.
 java.lang.String getPassword()
          Get the password used to connect to the camera.
 int getPort()
          Get the port connected to.
 double getRotation()
          Get the angle the images is being rotated before being sent to FrameListener.
 java.lang.String getUsername()
          Get the user name used to log in to the camera.
 boolean isAddTimestamp()
          Flag indicating if date and time is added to image before being sent to FrameListener.
static void main(java.lang.String[] args)
          Main used for testing.
 void removeFrameListener(FrameListener listener)
          Remove listener from list of listeners.
 void setAddTimestamp(boolean addTimestamp)
          Control whether a time and date stamp is added to camera image before it is passed to FrameListener.
 void setHost(java.lang.String host)
          Set host to connect to.
 void setPassword(java.lang.String password)
           
 void setPort(int port)
           
 void setResolution(HawkingCameraResolution resolution)
           
 void setRotation(double rotation)
           
 void setUsername(java.lang.String username)
           
 void shutdown()
          Stops vdeo capture and closes connection to camera.
 void startVideoCapture()
          Start video capture.
 void stopVideoCapture()
          Stops video capture.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HawkingCamera

public HawkingCamera(java.lang.String host,
                     int port,
                     java.lang.String username,
                     java.lang.String password)
              throws com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException,
                     java.net.MalformedURLException,
                     java.io.IOException
Connect to camera at given host and port. Port is typically 4321 unless setup differently at install time.

Parameters:
host - hostname (e.g., "192.168.1.35")
port - port number (usually 4321)
username - log in with this username (defaults to "admin" if null)
password - log in with this password (defaults to "" if null)
Throws:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
java.net.MalformedURLException
java.io.IOException
Method Detail

addFrameListener

public void addFrameListener(FrameListener listener)
Listen for camera images from this camera.

Parameters:
listener - added to listener list

captureImage

public java.awt.image.BufferedImage captureImage()
                                          throws java.net.UnknownHostException,
                                                 java.io.IOException
Capture one image. Note that this calls startVideoCapture() to stop video capture.

Throws:
java.io.IOException
java.net.UnknownHostException

startVideoCapture

public void startVideoCapture()
Start video capture. FrameListeners will start to receive events.


stopVideoCapture

public void stopVideoCapture()
Stops video capture. FrameListeners will no longer receive events. Method blocks until download thread stops.


getHost

public java.lang.String getHost()
return the host this camera is connected to.

Returns:
host name

getLastImage

public java.awt.image.BufferedImage getLastImage()
Get the last image captured by this camera, whether it was during a video capture or from a call to captureImage().

Returns:
image last seen by this camera

getLastImageTimestamp

public java.util.Date getLastImageTimestamp()
Get the timestamp of the last image seen by this camera.

Returns:
timestamp of last image seen

getPassword

public java.lang.String getPassword()
Get the password used to connect to the camera.

Returns:
password

getPort

public int getPort()
Get the port connected to.

Returns:
port number

getRotation

public double getRotation()
Get the angle the images is being rotated before being sent to FrameListener.

Returns:
angle in degrees

getUsername

public java.lang.String getUsername()
Get the user name used to log in to the camera.

Returns:
user name

isAddTimestamp

public boolean isAddTimestamp()
Flag indicating if date and time is added to image before being sent to FrameListener.

Returns:
flag

removeFrameListener

public void removeFrameListener(FrameListener listener)
Remove listener from list of listeners.

Parameters:
listener - to be removed

setAddTimestamp

public void setAddTimestamp(boolean addTimestamp)
Control whether a time and date stamp is added to camera image before it is passed to FrameListener.

Parameters:
addTimestamp - true to add time and date to image

setHost

public void setHost(java.lang.String host)
             throws com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException,
                    java.net.MalformedURLException,
                    java.io.IOException
Set host to connect to.

Parameters:
host - hostname
Throws:
java.io.IOException
java.net.MalformedURLException
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException

setPassword

public void setPassword(java.lang.String password)
                 throws com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException,
                        java.net.MalformedURLException,
                        java.io.IOException
Throws:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
java.net.MalformedURLException
java.io.IOException

setPort

public void setPort(int port)
             throws com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException,
                    java.net.MalformedURLException,
                    java.io.IOException
Throws:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
java.net.MalformedURLException
java.io.IOException

setResolution

public void setResolution(HawkingCameraResolution resolution)
                   throws java.io.IOException
Throws:
java.io.IOException

setRotation

public void setRotation(double rotation)

setUsername

public void setUsername(java.lang.String username)
                 throws com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException,
                        java.net.MalformedURLException,
                        java.io.IOException
Throws:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException
java.net.MalformedURLException
java.io.IOException

shutdown

public void shutdown()
              throws java.io.IOException
Stops vdeo capture and closes connection to camera.

Throws:
java.io.IOException - if an error occurs

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

main

public static void main(java.lang.String[] args)
Main used for testing.

Parameters:
args -


JHawkingCam hosted by SourceForge.net - John Dillenburg - john_sourceforge@dillenburg.org