Package edu.wpi.first.cscore.raw
Class RawFrame
- java.lang.Object
-
- edu.wpi.first.cscore.raw.RawFrame
-
- All Implemented Interfaces:
AutoCloseable
public class RawFrame extends Object implements AutoCloseable
Class for storing raw frame data between image read call.Data is reused for each frame read, rather then reallocating every frame.
-
-
Constructor Summary
Constructors Constructor Description RawFrame()
Construct a new RawFrame.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the RawFrame, releasing native resources.ByteBuffer
getDataByteBuffer()
Get a ByteBuffer pointing to the frame data.long
getDataPtr()
Get a long (is a char* in native code) pointing to the frame data.long
getFramePtr()
Get the pointer to native representation of this frame.int
getHeight()
Get the height of the frame.int
getPixelFormat()
Get the PixelFormat of the frame.int
getTotalData()
Get the total length of the data stored in the frame.int
getWidth()
Get the width of the frame.void
setData(ByteBuffer dataByteBuffer, long dataPtr, int totalData, int width, int height, int pixelFormat)
Called from JNI to set data in class.void
setHeight(int height)
Set the height of the frame.void
setPixelFormat(int pixelFormat)
Set the PixelFormat of the frame.void
setWidth(int width)
Set the width of the frame.
-
-
-
Constructor Detail
-
RawFrame
public RawFrame()
Construct a new RawFrame.
-
-
Method Detail
-
close
public void close()
Close the RawFrame, releasing native resources. Any images currently using the data will be invalidated.- Specified by:
close
in interfaceAutoCloseable
-
setData
public void setData(ByteBuffer dataByteBuffer, long dataPtr, int totalData, int width, int height, int pixelFormat)
Called from JNI to set data in class.- Parameters:
dataByteBuffer
- A ByteBuffer pointing to the frame data.dataPtr
- A long (a char* in native code) pointing to the frame data.totalData
- The total length of the data stored in the frame.width
- The width of the frame.height
- The height of the frame.pixelFormat
- The PixelFormat of the frame.
-
getFramePtr
public long getFramePtr()
Get the pointer to native representation of this frame.- Returns:
- The pointer to native representation of this frame.
-
getDataByteBuffer
public ByteBuffer getDataByteBuffer()
Get a ByteBuffer pointing to the frame data. This ByteBuffer is backed by the frame directly. Its lifetime is controlled by the frame. If a new frame gets read, it will overwrite the current one.- Returns:
- A ByteBuffer pointing to the frame data.
-
getDataPtr
public long getDataPtr()
Get a long (is a char* in native code) pointing to the frame data. This pointer is backed by the frame directly. Its lifetime is controlled by the frame. If a new frame gets read, it will overwrite the current one.- Returns:
- A long pointing to the frame data.
-
getTotalData
public int getTotalData()
Get the total length of the data stored in the frame.- Returns:
- The total length of the data stored in the frame.
-
getWidth
public int getWidth()
Get the width of the frame.- Returns:
- The width of the frame.
-
setWidth
public void setWidth(int width)
Set the width of the frame.- Parameters:
width
- The width of the frame.
-
getHeight
public int getHeight()
Get the height of the frame.- Returns:
- The height of the frame.
-
setHeight
public void setHeight(int height)
Set the height of the frame.- Parameters:
height
- The height of the frame.
-
getPixelFormat
public int getPixelFormat()
Get the PixelFormat of the frame.- Returns:
- The PixelFormat of the frame.
-
setPixelFormat
public void setPixelFormat(int pixelFormat)
Set the PixelFormat of the frame.- Parameters:
pixelFormat
- The PixelFormat of the frame.
-
-