Package edu.wpi.first.util
Class RawFrame
java.lang.Object
edu.wpi.first.util.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 empty RawFrame. -
Method Summary
Modifier and Type Method Description void
close()
Close the RawFrame, releasing native resources.ByteBuffer
getData()
Get a ByteBuffer pointing to the frame data.long
getDataPtr()
Get a long (is a uint8_t* in native code) pointing to the frame data.int
getHeight()
Get the height of the image.long
getNativeObj()
Get the pointer to native representation of this frame.PixelFormat
getPixelFormat()
Get the PixelFormat of the frame.int
getSize()
Get the total size of the data stored in the frame, in bytes.int
getStride()
Get the number of bytes in each row of image data.int
getWidth()
Get the width of the image.void
setData(ByteBuffer data, int width, int height, int stride, PixelFormat pixelFormat)
Set frame data.void
setInfo(int width, int height, int stride, PixelFormat pixelFormat)
Call to set frame information.
-
Constructor Details
-
Method Details
-
close
Close the RawFrame, releasing native resources. Any images currently using the data will be invalidated.- Specified by:
close
in interfaceAutoCloseable
-
setData
Set frame data.- Parameters:
data
- A native ByteBuffer pointing to the frame data.width
- The width of the frame, in pixelsheight
- The height of the frame, in pixelsstride
- The number of bytes in each row of image datapixelFormat
- The PixelFormat of the frame
-
setInfo
Call to set frame information.- Parameters:
width
- The width of the frame, in pixelsheight
- The height of the frame, in pixelsstride
- The number of bytes in each row of image datapixelFormat
- The PixelFormat of the frame
-
getNativeObj
Get the pointer to native representation of this frame.- Returns:
- The pointer to native representation of this frame.
-
getData
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 uint8_t* 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.
-
getSize
Get the total size of the data stored in the frame, in bytes.- Returns:
- The total size of the data stored in the frame.
-
getWidth
Get the width of the image.- Returns:
- The width of the image, in pixels.
-
getHeight
Get the height of the image.- Returns:
- The height of the image, in pixels.
-
getStride
Get the number of bytes in each row of image data.- Returns:
- The image data stride, in bytes.
-
getPixelFormat
Get the PixelFormat of the frame.- Returns:
- The PixelFormat of the frame.
-