Send Captures
This guide shows how to build two Capture objects with different images and vision elements, then send them to a Display in a loop — alternating every 1.5 seconds.
Overview
The script pre-builds two captures at startup and then loops indefinitely, sending them to the display one at a time. Each capture pairs a solid-color image with a set of overlaid vision elements.
Constants
var COLOR_GREEN_HEX = "#cdff12";
var COLOR_DARK_HEX = "#182b31";
var COLOR_WHITE_HEX = "#ffffff";
var FONT_SIZE = 60;
var FILL_OPACITY = 0.2;
var IMAGE_WIDTH = 1200;
var IMAGE_HEIGHT = 800;
All visual settings are declared upfront so they are easy to tweak without touching the rest of the code.
Capture 1 — light background
var image1 = new Ve.Image(IMAGE_WIDTH, IMAGE_HEIGHT, Ve.EPixelFormat.RGB8, [205, 255, 18]);
A 1200×800 image filled with the green color (#cdff12). Three elements are overlaid:
- String — label
"Capture 1"anchored at the top-left corner. - Rect2d — a rotated rectangle (30° tilt) with a semi-transparent dark fill.
- Segment2d — a line with rounded caps connecting two points.
var capture1 = new Capture(image1);
capture1.addVisionElement(veList1);
Capture 2 — dark background
var image2 = new Ve.Image(IMAGE_WIDTH, IMAGE_HEIGHT, Ve.EPixelFormat.RGB8, [24, 43, 49]);
A 1200×800 image filled with the dark color (#182b31). Four elements are overlaid:
- String — label
"Capture 2"anchored at the top-left corner. - Path2d — a closed polygon with six vertices and a semi-transparent green fill.
- Circle2d — a circle outline centered at (750, 550) with radius 100.
- Point2d — a single marker point at (650, 200).
var capture2 = new Capture(image2);
capture2.addVisionElement(veList2);
Loop
while (true) {
var capture: Capture = {} as Capture;
if (flag == "1") {
capture = capture1;
} else {
capture = capture2;
}
Visu.page0.display1.sendCapture(capture);
Visu.update();
if (flag == "1") {
flag = "2";
} else {
flag = "1";
}
waitTime(1500);
}
The loop picks the active capture based on flag, sends it to the display, flips the flag, then waits 1500 ms before the next iteration. Both captures are created once before the loop starts — there is no per-cycle allocation.
Visu.update() must be called after sendCapture() to flush the update to the visualization layer.
Full script
//
// Constants
//
var COLOR_GREEN_HEX = "#cdff12";
var COLOR_DARK_HEX = "#182b31";
var COLOR_WHITE_HEX = "#ffffff";
var FONT_SIZE = 60;
var FILL_OPACITY = 0.2;
var IMAGE_WIDTH = 1200;
var IMAGE_HEIGHT = 800;
//
// Capture 1
//
var image1 = new Ve.Image(IMAGE_WIDTH, IMAGE_HEIGHT, Ve.EPixelFormat.RGB8, [205, 255, 18]);
var veList1: Ve.VisionElement[] = [];
var string1 = new Ve.String("Capture 1");
string1.color = COLOR_DARK_HEX;
string1.fontSize = FONT_SIZE;
string1.setAnchor(new Ve.Point2d(30, 30));
veList1.push(string1 as Ve.VisionElement);
var rect1 = new Ve.Rect2d(200, 200, 400, 300, 30, true);
rect1.lineColor = COLOR_DARK_HEX;
rect1.filled = true;
rect1.fillColor = COLOR_DARK_HEX;
rect1.fillOpacity = FILL_OPACITY;
veList1.push(rect1 as Ve.VisionElement);
var segment1 = new Ve.Segment2d(650, 150, 800, 500);
segment1.lineColor = COLOR_DARK_HEX;
segment1.cap1 = Ve.ECapType.Round;
segment1.cap2 = Ve.ECapType.Round;
veList1.push(segment1 as Ve.VisionElement);
var capture1 = new Capture(image1);
capture1.addVisionElement(veList1);
//
// Capture 2
//
var image2 = new Ve.Image(IMAGE_WIDTH, IMAGE_HEIGHT, Ve.EPixelFormat.RGB8, [24, 43, 49]);
var veList2: Ve.VisionElement[] = [];
var string2 = new Ve.String("Capture 2");
string2.color = COLOR_WHITE_HEX;
string2.fontSize = FONT_SIZE;
string2.setAnchor(new Ve.Point2d(30, 30));
veList2.push(string2 as Ve.VisionElement);
var path2 = new Ve.Path2d([
new Ve.Point2d(260.80, 165.60),
new Ve.Point2d(225.20, 386.40),
new Ve.Point2d(330.40, 247.20),
new Ve.Point2d(435.60, 442.40),
new Ve.Point2d(383.20, 582.40),
new Ve.Point2d(278.00, 604.80),
], true);
path2.filled = true;
path2.fillColor = COLOR_GREEN_HEX;
path2.fillOpacity = FILL_OPACITY;
veList2.push(path2 as Ve.VisionElement);
var circle2 = new Ve.Circle2d(750, 550, 100);
circle2.lineColor = COLOR_GREEN_HEX;
veList2.push(circle2 as Ve.VisionElement);
var point2 = new Ve.Point2d(650, 200);
point2.color = COLOR_GREEN_HEX;
point2.markerSize = 10;
veList2.push(point2 as Ve.VisionElement);
var capture2 = new Capture(image2);
capture2.addVisionElement(veList2);
var flag = "1";
//
// Loop
//
while (true) {
var capture: Capture = {} as Capture;
if (flag == "1") {
capture = capture1;
} else {
capture = capture2;
}
Visu.page0.display1.sendCapture(capture);
Visu.update();
if (flag == "1") {
flag = "2";
} else {
flag = "1";
}
waitTime(1500);
}