buffer Lua Interface¶
get¶
Get a pointer to the BufferLua object
- Arguments:
- buffer ptr Pointer to Module object
- Returns:
- buffer ptr Pointer to casted BufferLua object
Example
ptr = buffer:.get(ptr)
copy¶
Get a copy of a buffer, or of a buffer's region
- Arguments:
- buffer ptr Pointer to a buffer
- number x X Position for region to get (Optional for region)
- number y Y Position for region to get (Optional for region)
- number width Width for region to get (Optional for region)
- number height Height for region to get (Optional for region)
- boolean relative Specify if the region coordinates are relative (Optional for region)
- Returns:
- buffer ptr Pointer to casted BufferLua object
Example
ptr = buffer:.copy(ptr,x,y,width,height,relative)
copyToRegion¶
Copy a buffer's region to another buffer's region (Should be the same size)
- Arguments:
- buffer ptr Pointer to a buffer
- number x X Position for region to copy from
- number y Y Position for region to copy from
- number width Width for region to copy from
- number height Height for region to copy from
- boolean relative Specify if the region coordinates to copy from are relative
- buffer dest_buffer Pointer to a buffer to copy to
- number dx X Position for region to copy to
- number dy Y Position for region to copy to
- number dwidth Width for region to copy to
- number dheight Height for region to copy to
- boolean drelative Specify if the region coordinates to copy to are relative (optional)
- Returns:
- boolean success If the copy was successful
Example
success = buffer:.copyToRegion(ptr,x,y,width,height,relative,dest_buffer,dx,dy,dwidth,dheight,drelative)
is_valid¶
Check if a buffer pointer has valid data
- Arguments:
- buffer ptr Pointer to a buffer
- Returns:
- boolean valid Is valid data
Example
valid = buffer:.is_valid(ptr)
getSize¶
Get buffer size
- Arguments:
- buffer ptr Pointer to a buffer
- Returns:
- number[] size Buffer size
Example
size = buffer:.getSize(ptr)
resize¶
Resize buffer
- Arguments:
- buffer ptr Pointer to a buffer
- number[] size Buffer size
Example
buffer:.resize(ptr,size)
drawRect¶
Draw a rectangle on a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- number x Rectangle X position (Relative)
- number y Rectangle Y position (Relative)
- number width Rectangle Width (Relative)
- number height Rectangle Height (Relative)
- number[] color Object color (Array with 3 values)
- number thickness Rectangle thickness
Example
buffer:.drawRect(ptr,x,y,width,height,color,thickness)
drawPoly¶
Draw a polygon on a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- number[][] shape Vector of points for shape ([:][2]) (Relative)
- number[] color Object color (Array with 3 values between 0 and 255)
- number alpha Polygon color alpha (0.0 - 1.0)
Example
buffer:.drawPoly(ptr,shape,color,alpha)
fill¶
Fill a specific buffer with a color
- Arguments:
- buffer ptr Pointer to a buffer
- number[] color Color to fill the buffer (Array with 3 values)
- number opacity Opacity of color to fill the buffer
Example
buffer:.fill(ptr,color,opacity)
drawLine¶
Draw a line on a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- number[] srcPt Line starting point (Array with 2 values) (Relative)
- number[] dstPt Line ending point (Array with 2 values) (Relative)
- number[] color Line color (Array with 3 values)
- number thickness Line thickness
Example
buffer:.drawLine(ptr,srcPt,dstPt,color,thickness)
drawPolyLine¶
Draw a line consisting of multiple points example: outputimg:drawPolyLine({{0,0},{10,0},{10,10},{20,10},{20,200}}, {255, 255, 0}, 1)
- Arguments:
- buffer ptr Pointer to a buffer
- number[][] pts Line points (Array of Array with 2 values) (Relative)
- number[] color Line color (Array with 3 values)
- number thickness Line thickness
Example
buffer:.drawPolyLine(ptr,pts,color,thickness)
drawCircle¶
Draw a circle on a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- number[] centerPt Circle center point (Array with 2 values) (Relative)
- number radius Circle radius (Relative)
- number[] color Object color (Array with 3 values)
- number thickness Circle thickness
Example
buffer:.drawCircle(ptr,centerPt,radius,color,thickness)
writeText¶
Write text on a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- number[] srcPt Text starting point (Array with 2 values) (Relative)
- string text Text to write to buffer
- number[] color Object color (Array with 3 values)
- number fontscale Text font scale
- number thickness Text thickness
- number fontface Text font face
Example
buffer:.writeText(ptr,srcPt,text,color,fontscale,thickness,fontface)
writeTextAutoSize¶
Write text on a specific buffer from the instance with auto adjusted size for different screens
- Arguments:
- buffer ptr Pointer to a buffer
- number[] srcPt Text starting point (Array with 2 values) (Relative)
- string text Text to write to buffer
- number[] color Object color (Array with 3 values)
- number fontface Text font face
- number generic_size Size of text (0-Small 1-Normal 2-Big)
Example
buffer:.writeTextAutoSize(ptr,srcPt,text,color,fontface,generic_size)
getTextAutoSize¶
Get the size of the auto adjusted text for different screens
- Arguments:
- buffer ptr Pointer to a buffer
- string text Text to write to buffer
- number fontface Text font face
- number generic_size Size of text (0-Small 1-Normal 2-Big)
- Returns:
- number[] size Size of text on screen
Example
size = buffer:.getTextAutoSize(ptr,text,fontface,generic_size)
loadImage¶
Draw an image from a file into a specific buffer from the instance
- Arguments:
- buffer ptr Pointer to a buffer
- string filename Image filename to load
- Returns:
- bool state of loading the image
Example
state = buffer:.loadImage(ptr,filename)
saveImage¶
Save an image to a file
- Arguments:
- buffer ptr Pointer to a buffer
- string filename Image filename to save
Example
buffer:.saveImage(ptr,filename)
brightness¶
Adjust image brightness
- Arguments:
- buffer ptr Pointer to a buffer
- number delta Positive or negative value by which to alter brightness
Example
buffer:.brightness(ptr,delta)
grayscale¶
Convert image to grayscale
- Arguments:
- buffer ptr Pointer to a buffer
- bool singleChannel Convert image to 1 or 3 channels
Example
buffer:.grayscale(ptr,singleChannel)
fishToPano¶
Convert fisheye image to equirectangular panoramic
- Arguments:
- buffer ptr Pointer to a buffer
- float xOffset X offset in source image
- float yOffset Y offset in source image
Example
buffer:.fishToPano(ptr,xOffset,yOffset)
fishToPanoOld¶
Convert fisheye image to equirectangular panoramic (Old version)
- Arguments:
- buffer ptr Pointer to a buffer
- float xOffset X offset in source image
- float yOffset Y offset in source image
Example
buffer:.fishToPanoOld(ptr,xOffset,yOffset)
blur¶
Blur the image
- Arguments:
- buffer ptr Pointer to a buffer
- number x Rectangle X position (Relative)
- number y Rectangle Y position (Relative)
- number width Rectangle Width (Relative)
- number height Rectangle Height (Relative)
- number amount Blur amount
Example
buffer:.blur(ptr,x,y,width,height,amount)
pixelate¶
Pixelate the image
- Arguments:
- buffer ptr Pointer to a buffer
- number x Rectangle X position (Relative)
- number y Rectangle Y position (Relative)
- number width Rectangle Width (Relative)
- number height Rectangle Height (Relative)
- number amount Pixelate amount
Example
buffer:.pixelate(ptr,x,y,width,height,amount)
drawBoundingBox¶
Draw a bounding box on the buffer
- Arguments:
- buffer ptr Pointer to a buffer
- number x Rectangle X position (Relative)
- number y Rectangle Y position (Relative)
- number width Rectangle Width (Relative)
- number height Rectangle Height (Relative)
- string label Bounding box label
- number[] color Bounding box color
- number thickness Bounding box thickness
Example
buffer:.drawBoundingBox(ptr,x,y,width,height,label,color,thickness)
getTimestamp¶
gets timestamp
- Arguments:
- buffer ptr Pointer to a buffer
- Returns:
- number timestamp of the buffer frame (0 if not defined, usually in milliseconds - might be device dependent)
Example
timestamp = buffer:.getTimestamp(ptr)
getFrameId¶
gets frame id
- Arguments:
- buffer ptr Pointer to a buffer
- Returns:
- number current frame ID
Example
current = buffer:.getFrameId(ptr)
rotate90deg¶
Rotate the buffer multiples of 90 degrees
- Arguments:
- number rotateFlag Flag to determine rotation degree and direction, 0 for rotating 90 degree CW, 1 for rotating 180 degree CW and 2 for rotating 270 degree CW
Example
buffer:.rotate90deg(rotateFlag)