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
Modifier and Type Method Description voidclose()Close the RawFrame, releasing native resources.ByteBuffergetDataByteBuffer()Get a ByteBuffer pointing to the frame data.longgetDataPtr()Get a long (is a char* in native code) pointing to the frame data.longgetFramePtr()Get the pointer to native representation of this frame.intgetHeight()Get the height of the frame.intgetPixelFormat()Get the PixelFormat of the frame.intgetTotalData()Get the total length of the data stored in the frame.intgetWidth()Get the width of the frame.voidsetData(ByteBuffer dataByteBuffer, long dataPtr, int totalData, int width, int height, int pixelFormat)Called from JNI to set data in class.voidsetHeight(int height)Set the height of the frame.voidsetPixelFormat(int pixelFormat)Set the PixelFormat of the frame.voidsetWidth(int width)Set the width of the frame.
-
Constructor Details
-
Method Details
-
close
Close the RawFrame, releasing native resources. Any images currently using the data will be invalidated.- Specified by:
closein 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
Get the pointer to native representation of this frame.- Returns:
- The pointer to native representation of this frame.
-
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
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
Get the total length of the data stored in the frame.- Returns:
- The total length of the data stored in the frame.
-
getWidth
Get the width of the frame.- Returns:
- The width of the frame.
-
setWidth
Set the width of the frame.- Parameters:
width- The width of the frame.
-
getHeight
Get the height of the frame.- Returns:
- The height of the frame.
-
setHeight
Set the height of the frame.- Parameters:
height- The height of the frame.
-
getPixelFormat
Get the PixelFormat of the frame.- Returns:
- The PixelFormat of the frame.
-
setPixelFormat
Set the PixelFormat of the frame.- Parameters:
pixelFormat- The PixelFormat of the frame.
-