net.sourceforge.jartoolkit.videoinput.videocapturing
Class JARVideo

java.lang.Object
  extended bynet.sourceforge.jartoolkit.videoinput.videocapturing.JARVideo
All Implemented Interfaces:
JARPictureSource

public class JARVideo
extends java.lang.Object
implements JARPictureSource

Class used for capturing a video using DirectX on Windows. This class is a native interface to the ARVideo-dll used by the ARToolKit. This code is based on the ARToolKit 2.65f & DSVideoLib 0.0.5a modified by Thomas Pintaric from the Vienna University of Technology (http://www.ims.tuwien.ac.at/~thomas/artoolkit.php). You need DirectX 9b installed on your maschine, because of using DirectShow for grabbing the frames. Without a capturing-device this class woun't run, too. The get an instance of this class you have to call the Create-method. Only one instance of this class will created. The use JARVideo you have to do following steps:

  1. Create an instance of JARVideo by using myinstance = JARVideo.create();
  2. Grap the first frame internally by using myinstance.grabFrame()
  3. Get the width, height and size of the framebuffer
  4. Create a new intarray for storing the framedata, eg. dataArray = new int[(size>>2)];
  5. In the mainloop call myinstance.getNextBuffer(dataArray) to update the framebuffer

In later Versions there will be port to Linux using the AR-Toolkit port for Video For Linux!.


Field Summary
static java.lang.String version
          The Version of JARVideo.
 
Method Summary
static JARVideo create()
          Create a JARVideo instance.
static JARVideo create(java.lang.String config)
          Create a JARVideo instance.
static JARVideo create(java.lang.String config, int buffer)
          Create a JARVideo instance.
 void displayProperties()
          Print the capturedevice-properties to the console.
 int getBitCount()
          get the bitdepth of a frame.
 int getBitCount(int buffer)
          get the bitdepth of a frame.
 void getBuffer(int[] pixel)
          Get the buffer as an integerarray.
 void getBuffer(int[] pixel, int buffer)
          Get the buffer as an integerarray.
 long getBufferPointer()
          Get the buffer as a longpointer.
 long getBufferPointer(int buffer)
          Get the buffer as a longpointer.
 long getBufferSize()
          Get the size of the framebuffer in bytes.
 long getBufferSize(int buffer)
          Get the size of the framebuffer in bytes.
 int getHeight()
          Get the height of a frame.
 int getHeight(int buffer)
          Get the height of a frame.
 void getNextBuffer(int[] pixel)
          Get the next frame and return the buffer as an integerarray.
 void getNextBuffer(int[] pixel, int buffer)
          Get the next frame and return the buffer as an integerarray.
 long getNextBufferPointer()
          Get the next frame and return the buffer as a longpointer.
 long getNextBufferPointer(int buffer)
          Get the next frame and return the buffer as a longpointer.
 int getWidth()
          Get the width of a frame.
 int getWidth(int buffer)
          Get the width of a frame.
 void grabFrame()
          Grab next frame from capturedevice.
 void grabFrame(int buffer)
          Grab next frame from capturedevice.
 void setFlippedImage(boolean flip)
          Set the flag for flipping the image.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The Version of JARVideo.

See Also:
Constant Field Values
Method Detail

create

public static JARVideo create()
                       throws java.lang.InstantiationException
Create a JARVideo instance. You can create an instance only once. If you call this static method more than once null will return.

Returns:
A instance of a JARVideo class, or null, if you called this method more than once.
Throws:
java.lang.InstantiationException

create

public static JARVideo create(java.lang.String config)
                       throws java.lang.InstantiationException
Create a JARVideo instance. You can create an instance only once. If you call this static method more than once null will return.

Parameters:
config - Configuration for initialising DirectShow (Please refer video.h by Thomas Pintaric.
Returns:
A instance of a JARVideo class, or null, if you called this method more than once.
Throws:
java.lang.InstantiationException

create

public static JARVideo create(java.lang.String config,
                              int buffer)
                       throws java.lang.InstantiationException
Create a JARVideo instance. You can create an instance only once. If you call this static method more than once null will return.

Parameters:
config - Configuration for initialising DirectShow (Please refer video.h by Thomas Pintaric.
buffer - Used for specify which buffer to use (Refer video.h by Thomas Pintaric.)
Returns:
A instance of a JARVideo class, or null, if you called this method more than once.
Throws:
java.lang.InstantiationException

displayProperties

public void displayProperties()
Print the capturedevice-properties to the console.

Specified by:
displayProperties in interface JARPictureSource

getBitCount

public int getBitCount()
get the bitdepth of a frame.

Specified by:
getBitCount in interface JARPictureSource
Returns:
The bitdepth of a frame, eg. 32, 24, etc.

getBitCount

public int getBitCount(int buffer)
get the bitdepth of a frame.

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The bitdepth of a frame, eg. 32, 24, etc.

getBuffer

public void getBuffer(int[] pixel)
Get the buffer as an integerarray.

Specified by:
getBuffer in interface JARPictureSource
Parameters:
pixel - The buffer in which the framedata will be copied in.

getBuffer

public void getBuffer(int[] pixel,
                      int buffer)
Get the buffer as an integerarray.

Parameters:
pixel - The buffer in which the framedata will be copied in.
buffer - Specify left(0) or right(1) buffer of a stereoimage.

getBufferPointer

public long getBufferPointer()
Get the buffer as a longpointer. This method can by used in method JARToolKit.JARDetectMarker(long dataPtr, int thresh). should be faster than JARDetectMarker( int dataPtr[], int thresh );

Specified by:
getBufferPointer in interface JARPictureSource
Returns:
The buffer of imagedata as longpointer.

getBufferPointer

public long getBufferPointer(int buffer)
Get the buffer as a longpointer. This method can by used in method JARToolKit.JARDetectMarker(long dataPtr, int thresh). should be faster than JARDetectMarker( int dataPtr[], int thresh );

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The buffer of imagedata as longpointer.

getBufferSize

public long getBufferSize()
Get the size of the framebuffer in bytes.
CAUTION: This is the size in bytes. If you want to declare a intarray, then you have to divide the bytesize by 4, eg.
  int size = JARVideo.GetBufferSize();
  dataArray = new int[size>>2];
  ...
  JARVideo.GetBuffer(dataArray);
  

Specified by:
getBufferSize in interface JARPictureSource
Returns:
The size of the framebuffer in bytes.

getBufferSize

public long getBufferSize(int buffer)
Get the size of the framebuffer in bytes.
CAUTION: This is the size in bytes. If you want to declare a intarray, then you have to divide the bytesize by 4, eg.
  int size = JARVideo.GetBufferSize();
  dataArray = new int[size>>2];
  ...
  JARVideo.GetBuffer(dataArray);
  

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The size of the framebuffer in bytes.

getHeight

public int getHeight()
Get the height of a frame.

Specified by:
getHeight in interface JARPictureSource
Returns:
The height of a frame in pixel.

getHeight

public int getHeight(int buffer)
Get the height of a frame.

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The height of a frame in pixel.

getNextBuffer

public void getNextBuffer(int[] pixel)
Get the next frame and return the buffer as an integerarray.

Specified by:
getNextBuffer in interface JARPictureSource
Parameters:
pixel - The buffer in which the framedata will be copied in.

getNextBuffer

public void getNextBuffer(int[] pixel,
                          int buffer)
Get the next frame and return the buffer as an integerarray.

Parameters:
pixel - The buffer in which the framedata will be copied in.
buffer - Specify left(0) or right(1) buffer of a stereoimage.

getNextBufferPointer

public long getNextBufferPointer()
Get the next frame and return the buffer as a longpointer. Like GetBufferPointer() this method can by used by JARToolKit.JARDetectMarker(long dataPtr, int thresh).

Specified by:
getNextBufferPointer in interface JARPictureSource
Returns:
The buffer of imagedata as longpointer.

getNextBufferPointer

public long getNextBufferPointer(int buffer)
Get the next frame and return the buffer as a longpointer. Like GetBufferPointer() this method can by used by JARToolKit.JARDetectMarker(long dataPtr, int thresh).

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The buffer of imagedata as longpointer.

getWidth

public int getWidth()
Get the width of a frame.

Specified by:
getWidth in interface JARPictureSource
Returns:
The width of a frame in pixel.

getWidth

public int getWidth(int buffer)
Get the width of a frame.

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.
Returns:
The width of a frame in pixel.

grabFrame

public void grabFrame()
Grab next frame from capturedevice. This call updates the internal framebuffer.

Specified by:
grabFrame in interface JARPictureSource

grabFrame

public void grabFrame(int buffer)
Grab next frame from capturedevice. This call updates the internal framebuffer.

Parameters:
buffer - Specify left(0) or right(1) buffer of a stereoimage.

setFlippedImage

public void setFlippedImage(boolean flip)
Set the flag for flipping the image.

Specified by:
setFlippedImage in interface JARPictureSource
Parameters:
flip - If true, the image will be flipped vertically.