Package edu.wpi.first.util
Class RawFrame
java.lang.Object
edu.wpi.first.util.RawFrame
- All Implemented Interfaces:
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the RawFrame, releasing native resources.getData()
Get a ByteBuffer pointing to the frame data.long
Get a long (is a uint8_t* in native code) pointing to the frame data.int
Get the height of the image.long
Get the pointer to native representation of this frame.Get the PixelFormat of the frame.int
getSize()
Get the total size of the data stored in the frame, in bytes.int
Get the number of bytes in each row of image data.long
Get the time this frame was grabbed at.Get the time source for the timestamp this frame was grabbed at.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.void
setTimeInfo
(long frameTime, TimestampSource frameTimeSource) Update this frame's timestamp info.
-
Constructor Details
-
RawFrame
public RawFrame()Construct a new empty RawFrame.
-
-
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
-
setTimeInfo
Update this frame's timestamp info.- Parameters:
frameTime
- the time this frame was grabbed at. This uses the same time base as wpi::Now(), in us.frameTimeSource
- the time source for the timestamp this frame was grabbed at.
-
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.
-
getTimestamp
Get the time this frame was grabbed at. This uses the same time base as wpi::Now(), in us.- Returns:
- Time in 1 us increments.
-
getTimestampSource
Get the time source for the timestamp this frame was grabbed at.- Returns:
- Time source
-