net.sourceforge.jartoolkit.videoinput.videocapturing
Class JARFrameGrabber

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

public class JARFrameGrabber
extends java.lang.Object
implements JARPictureSource

Class used for capturing a video using DirectX on Windows. This class is a native interface to the FrameGrabber class used by the AR-Toolkit. This class will run on Windows only. You also need to have DirectX 8 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 JARFrameGrabber you have to do following steps:

  1. Create an instance of JARFrameGrabber by using myinstance = JARFrameGrabber.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!. New in Version 2.0: You are able to submit a configuration when creating the JARFrameGrabber. For syntax look in JARFramegrabber.cpp!

Version:
2.0
Author:
Jörg Stöcklein (ozone_abandon at sourceforge.net)

Field Summary
static java.lang.String version
          The Version of JARFrameGrabber.
 
Method Summary
static JARFrameGrabber create()
          Create a JARFrameGrabber instance.
static JARFrameGrabber create(java.lang.String config)
          Create a JARFrameGrabber instance.
 void displayProperties()
          Print the capturedevice-properties to the console.
 int getBitCount()
          Get the bitdepth of a frame.
 void getBuffer(byte[] pixel)
          Get the buffer as an bytearray.
 void getBuffer(int[] pixel)
          Get the buffer as an integerarray.
 long getBufferPointer()
          Get the buffer as a longpointer.
 long getBufferSize()
          Get the size of the framebuffer in bytes.
 int getFPS()
          Get the framerate of the videostream.
 int getHeight()
          Get the height of a frame.
 void getNextBuffer(int[] pixel)
          Get the next frame and return the buffer as an integerarray.
 long getNextBufferPointer()
          Get the next frame and return the buffer as a longpointer.
 int getWidth()
          Get the width of a frame.
 void grabFrame()
          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 JARFrameGrabber.

See Also:
Constant Field Values
Method Detail

create

public static JARFrameGrabber create()
                              throws java.lang.InstantiationException
Create a JARFrameGrabber 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 JARFrameGrabber class, or null, if you called this method more than once.
Throws:
java.lang.InstantiationException

create

public static JARFrameGrabber create(java.lang.String config)
                              throws java.lang.InstantiationException
Create a JARFrameGrabber 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
Returns:
A instance of a JARFrameGrabber 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.

getBuffer

public void getBuffer(byte[] pixel)
Get the buffer as an bytearray.

Parameters:
pixel - The buffer in which the framedata will be copied in.

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.

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.

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 = JARFrameGrabber.GetBufferSize();
  dataArray = new int[size>>2];
  ...
  JARFrameGrabber.GetBuffer(dataArray);
  

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

getFPS

public int getFPS()
Get the framerate of the videostream.

Returns:
The framerate of a stream, eg. 12, 15, 25, 30, etc.

getHeight

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

Specified by:
getHeight in interface JARPictureSource
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.

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.

getWidth

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

Specified by:
getWidth in interface JARPictureSource
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

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.