Class PixelSource

java.lang.Object
  |
  +--PixelSource

public class PixelSource
extends java.lang.Object


Field Summary
 int kHeight
          This is the height of the video that you requested when you constructed this object
 int kWidth
          This is the width of the video that you requested when you constructed this object
 int vidWidth
          This is the actual width of the video which may differ from the width you requested because some extra slop bytes may be added at the end of each line.
 
Constructor Summary
PixelSource(int pw, int ph)
          This is the constructor class.
 
Method Summary
 java.lang.String changeSource(int whichSource)
           
 int[][] getBackground()
          This returns a two dimensional array describing the background as last grabbed with the grab background commnad.
 int[] getBackGroundPixel(int x, int y)
          This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the background.
 int[] getBackGroundPixelSlow(int x, int y)
          This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the background.
 int[] getMasks()
          This is a mask that hilites the red, green, blue or alpha part of the integer packed full of ARGB.
 int[] getPackedBackground()
          This returns the array for the current background.
 int[] getPixel(int[] inArray, int x, int y)
          This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the array you supply.
 int[] getPixel(int x, int y)
          This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate.
 int[] getPixelArray()
          This gives you back the pixels in an int array created and sized by pixel source.
 void getPixelArray(int[] _newPixels)
          This tickles tickles the video and puts the pixels in an int array that you supplied .
 int[] getShifts()
          This is the amount you would would have to shift a byte packed into an int to give you an accurate value.
 void grabBackground()
          This refreshes the background.
 void grabFrame()
          This gives you a fresh frame for getPixel and setPixel to operate on.
 void idleIt()
          This tickles whatever is suppling the video to give up fresh pixels.
 void idleIt(int numberOfTimes)
          This tickles whatever is suppling the video, with DV cameras you may have to tickle them many times between every frames to get rid of a lag.
 void killSession()
          Be sure to call this when you close or destroy your main window so a connection to your camera is not left hanging .
 void makeJPEG(java.lang.String pathname, java.lang.String filename)
          This does a quick dump of a jpeg and writes it out to a file at a given pathname in a given filename.
 void setPixel(int[] inputArray, int x, int y, int alpha)
          This sets the alpha (transparency) at a given x, y position.
 void setPixel(int[] inputArray, int x, int y, int red, int green, int blue, int alpha)
          This sets the red, green, blue and alpha (transparency) at a given x, y position.
 void setPixel(int x, int y, int alpha)
          This sets the alpha (transparency) at a given x, y position which is often necessary to see anything at all with an ARGB image.
 void setPixel(int x, int y, int red, int green, int blue, int alpha)
          This sets the alpha (transparency) at a given x, y position.
 void unpackBackground()
          Culls out the r g and b ahead of time so you save on the shifting and masking.
 void videoSettings()
          This pops up the video setting dialog box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kWidth

public int kWidth
This is the width of the video that you requested when you constructed this object


vidWidth

public int vidWidth
This is the actual width of the video which may differ from the width you requested because some extra slop bytes may be added at the end of each line. Sometimes no bytes are added (on most pc's) but sometime 4 bytes are added (most MACs).


kHeight

public int kHeight
This is the height of the video that you requested when you constructed this object

Constructor Detail

PixelSource

public PixelSource(int pw,
                   int ph)
This is the constructor class.

Method Detail

getPixel

public int[] getPixel(int x,
                      int y)
This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate. This is very convenient but a little slower. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


getPixel

public int[] getPixel(int[] inArray,
                      int x,
                      int y)
This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the array you supply. This is very convenient but a little slower. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


getBackGroundPixelSlow

public int[] getBackGroundPixelSlow(int x,
                                    int y)
This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the background. You would have to call grabBackGround() first for this to work. The masking and shifting is done on the fly here, instead of ahead of time so it is is a bit slow.


getBackGroundPixel

public int[] getBackGroundPixel(int x,
                                int y)
This returns a 3 element array which contains the values for Red Green and Blue at the specified x,y coordinate within the background. You would have to call grabBackGround() first for this to work.


setPixel

public void setPixel(int x,
                     int y,
                     int red,
                     int green,
                     int blue,
                     int alpha)
This sets the alpha (transparency) at a given x, y position. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


setPixel

public void setPixel(int x,
                     int y,
                     int alpha)
This sets the alpha (transparency) at a given x, y position which is often necessary to see anything at all with an ARGB image. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


setPixel

public void setPixel(int[] inputArray,
                     int x,
                     int y,
                     int alpha)
This sets the alpha (transparency) at a given x, y position. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


setPixel

public void setPixel(int[] inputArray,
                     int x,
                     int y,
                     int red,
                     int green,
                     int blue,
                     int alpha)
This sets the red, green, blue and alpha (transparency) at a given x, y position. If you want speed you sould use getPixelArray and pull out the Red Green and Blue in your own object using shifting and Masking


idleIt

public void idleIt()
This tickles whatever is suppling the video to give up fresh pixels.


idleIt

public void idleIt(int numberOfTimes)
This tickles whatever is suppling the video, with DV cameras you may have to tickle them many times between every frames to get rid of a lag.


getPixelArray

public void getPixelArray(int[] _newPixels)
This tickles tickles the video and puts the pixels in an int array that you supplied .


getPixelArray

public int[] getPixelArray()
This gives you back the pixels in an int array created and sized by pixel source. It does not tickle the video first so you might call grabframe() first.

Returns:
This is convenient to have the array created and sized for you but be aware that each call to this will replace the contents.

videoSettings

public void videoSettings()
This pops up the video setting dialog box.


getBackground

public int[][] getBackground()
This returns a two dimensional array describing the background as last grabbed with the grab background commnad. This is the result of masking and shifting that is done once when you grab the background to save time later. The outer array is for each pixels, the inner array for each color in a pixel in rgb order.


getPackedBackground

public int[] getPackedBackground()
This returns the array for the current background. You might want to get this before masking and shifting in case you want to blur it.


unpackBackground

public void unpackBackground()
Culls out the r g and b ahead of time so you save on the shifting and masking.


grabFrame

public void grabFrame()
This gives you a fresh frame for getPixel and setPixel to operate on.


grabBackground

public void grabBackground()
This refreshes the background. It also unpacks it. Generally you should remove everything from the foreground before you call this handler


killSession

public void killSession()
Be sure to call this when you close or destroy your main window so a connection to your camera is not left hanging .


changeSource

public java.lang.String changeSource(int whichSource)

getMasks

public int[] getMasks()
This is a mask that hilites the red, green, blue or alpha part of the integer packed full of ARGB. You only need this if you start accessing the int array yourself and unpacking the ARGB out of the ints. They are returned in the order of argb. Using getPixel and setPixel allows you to avoid all of this.


getShifts

public int[] getShifts()
This is the amount you would would have to shift a byte packed into an int to give you an accurate value. You only need this if you start accessing the int array yourself and unpacking the ARGB out of the ints. They are returned in the order of argb. Using getPixel and setPixel allows you to avoid all of this.


makeJPEG

public void makeJPEG(java.lang.String pathname,
                     java.lang.String filename)
This does a quick dump of a jpeg and writes it out to a file at a given pathname in a given filename.