Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, Clipboard, and Errors
   Dialog Functions
   Platform and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Global objects
    settings
    controller
    session
    python
   Collections
    array
    map
    bytes
   File Format I/O
    image_data
    image_stream
   Utils
    crypto
    timer
   Comm
    serial
   Dialogs
    file_open
    file_save
    msg_ok
    msg_ok_cancel
    msg_yes_no
    msg_password
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:objects:image_stream

image_stream

`image_stream` represents a changing image source. It can receive frames from `image_data`, play an image sequence from a folder, or play an MJPEG AVI file. The GUI `image` object can display an `image_stream`.

`image_stream` is not cloneable because it represents active playback/source state.

Constructor

image_stream()

Creates an empty stream.

stream = image_stream();
print(stream.has_frame);     // false

Properties

Property Type Description
`has_frame` boolean `true` when the stream has at least one frame.
`sequence` number Internal frame sequence counter.
`fps` number Playback frames per second.
`loop` boolean Playback loop state.
`frame_count` number Number of frames in the active player.
`next_frame` number Next frame index in the active player.
`running` boolean `true` when the active player is running.

Common Object Methods

to_string()

Returns a display string for the object.

Item Description
Syntax `value.to_string()`
Arguments none
Returns string

Example:

text = value.to_string();

`clone()` is not supported for `image_stream`.


Methods

clear()

Stops and clears any active player, clears the stream, and returns the stream object.

Item Description
Syntax `image_stream.clear()`
Arguments none
Returns image_stream object

Example:

stream.clear();

push(image)

Pushes one `image_data` frame into the stream.

Argument Type Description
`image` image_data Image frame to push.

Returns: `true` if the frame was pushed, or `false` if the image is not valid.

Example:

img = image_data().load("frame.png");
stream = image_stream();
ok = stream.push(img);

load_folder(folder)

Loads a folder as an image sequence using the default filter `*.jpg`.

Argument Type Description
`folder` string Folder containing image frames.

Returns: boolean-style number.

Example:

stream = image_stream();
stream.load_folder("frames");

load_folder(folder, filter)

Loads a folder as an image sequence using a file filter such as `*.png` or `frame_*.jpg`.

Argument Type Description
`folder` string Folder containing image frames.
`filter` string File filter such as `*.png` or `frame_*.jpg`.

Returns: boolean-style number.

Example:

stream = image_stream();
stream.load_folder("frames", "*.png");
stream.fps(10).loop(true).start();

load_avi(filePath)

Loads an MJPEG AVI file as the active player.

Argument Type Description
`filePath` string AVI file path.

Returns: boolean-style number.

Example:

stream = image_stream();
if (stream.load_avi("capture.avi"))
{
    stream.start();
}

fps(value)

Sets playback speed in frames per second.

Argument Type Description
`value` number Playback speed in frames per second.

Returns: image_stream object.

Example:

stream.fps(25);

loop(enabled)

Enables or disables looping.

Argument Type Description
`enabled` boolean Loop state.

Returns: image_stream object.

Example:

stream.loop(false);

start()

Starts the active player.

Item Description
Syntax `image_stream.start()`
Arguments none
Returns boolean-style number

If no folder or AVI player is active, it returns `false`.

Example:

stream.load_folder("frames", "*.jpg");
stream.start();

stop()

Stops playback.

Item Description
Syntax `image_stream.stop()`
Arguments none
Returns boolean-style number

Example:

stream.stop();

Displaying a Stream

Use the GUI `image` object to show an image stream.

stream = image_stream().load_folder("frames", "*.jpg");
view = image().position(10, 10).size(320, 240).load(stream).play();
window().title("Stream").size(360, 300).add(view).show();

Previous: image_data

Next: Utils

exprv4/reference/objects/image_stream.txt · Last modified: by andrej

Page Tools