Skip to content

Session Images ​

The Session Images widget shows the images of a session in a dialog: a grid of square thumbnails and, when one is clicked, a detail panel with the image, its result, its date and the results of each model. The boxes and polygons of the detections are drawn over the image and the thumbnails. The widget shows nothing in its group: one message opens the dialog and the next ones fill it.

Palette: category Pages, label session images. 1 input, 1 output.

The Sessions widget has the same viewer built in, and the images it reads from a session folder have the shape described under Input.

Configuration ​

PropertyDescriptionDefault
NameNode name shown in the editor.''
GroupDashboard group of the widget. The dialog opens only in browsers showing the page of this group.(required)
LocaleLocale Config node. This widget takes only the footbar texts from it.''
SizeWidth and height of the widget (0 = automatic).0 / 0
Dialog titleTitle of the dialog when the opening message has no msg.class. The title is shown in capitals, followed by the number of images.''
Max imagesMaximum number of images in the grid. Empty or 0 uses 60.60
Show mask checkboxShows the MASK toggle in the footbar. Unticked, the toggle is hidden and the mask stays in its last state (off by default).true
Show bbox checkboxShows the BBOX toggle. Unticked, the toggle is hidden and the boxes stay in their last state (shown by default).true
Show polygon checkboxShows the POLYGONS toggle. Unticked, the toggle is hidden and the polygons stay in their last state (shown by default).true
Mask checkbox textLabel of the MASK toggle. Built-in text: MASK.''
Bbox checkbox textLabel of the BBOX toggle. Built-in text: BBOX.''
Polygon checkbox textLabel of the POLYGONS toggle. Built-in text: POLYGONS.''
Hover label textTitle of the first option of the footbar cog menu. Built-in text: Labels on hover.''
Hover label hintSubtitle of that option. Built-in text: Show a label only while pointing at its detection.''
Box fill textTitle of the second option of the cog menu. Built-in text: Bounding box fill.''
Box fill hintSubtitle of that option. Built-in text: Tint the inside of each bounding box.''
Annotations on thumbnailsInitial state of the Show annotations button of the dialog header.true

The seven text properties work the same way: the node's own text wins. When it is empty, or equal to the built-in text, the text set in the Locale config is used, and when that is empty too, the built-in text.

The dialog ​

  • Header: the title, the number of images and, when there are images, the Show annotations button, which shows or hides the boxes and polygons on the thumbnails (not on the detail image). Its state is remembered per widget in the browser.
  • Grid: 200-pixel square thumbnails with the image name as caption. The border is red when isAnomalous is true and green when it is false. Clicking a thumbnail opens the detail panel on the right; clicking it again closes the panel.
  • Detail panel: the image name, its position (3 / 40), a selector of the image type when the image has more than one, a maximize button and a button to hide the panel. Below the image: Result, Date and a Models section with one expandable panel per model. The mouse wheel zooms up to 8x, a double click zooms in or returns to fit, dragging moves a zoomed image, and the toolbar in the bottom right corner zooms out, zooms in and fits. The side arrows and the Left and Right arrow keys move to the previous or next image. Maximized, the image takes the dialog, with a strip of thumbnails below it and the information on the right.
  • Footbar: a cog menu with Labels on hover (a detection label is shown only while the pointer is over its box or polygon) and Bounding box fill (boxes get a translucent fill, in the detail image and on the thumbnails); the cog shows a dot while either is on. Then the MASK toggle (the image and the thumbnails show their mask version when they have one), and the BBOX and POLYGONS toggles. Mask is off, boxes and polygons are on, and both menu options are off by default; changes are remembered per widget in the browser.

Closing the dialog, with the close button, a click outside it or showDialog: false, empties the grid.

Input ​

A message that carries msg._client, such as a click in another widget of the dashboard, updates only the browser it came from; a message without it updates every browser. The node adds itself to the base's Accept Client Data list, so nothing has to be ticked there.

Open and close ​

js
msg.payload = { showDialog: true };
msg.class = "scratch";   // optional: title of the dialog
PropertyTypeDescription
payload.showDialogbooleantrue opens the dialog, false closes it. A message with this property only opens or closes: the rest of its payload is ignored.
classstringTitle of the dialog, read when it opens. Without it, Dialog title is used.

Images ​

Images are accepted only while the dialog is open: send them after the message that opens it. Images that arrive while it is closed are ignored.

  • payload as an array replaces all the images, in the order given.
  • payload as an object adds one image at the start of the grid.

The list is then cut to Max images, dropping the images at the end. Every image message closes the detail panel.

An image object:

FieldTypeDescription
imageShowobjectThe image in one or more types, keyed by type name (for example raw, join). See below.
idstringUnique key. Generated when missing.
namestringCaption of the thumbnail and title of the detail panel.
resultstringShown as Result (— when missing), in red when isAnomalous is true, in green otherwise.
isAnomalousbooleanColour of the thumbnail border and of the result.
datenumber, string or objectMilliseconds since 1970, the same as a numeric string, or an object with seconds. Shown in the browser's time zone with the Spanish date format (day/month/year). Any other value, an ISO date string for example, is shown as received.
resumeobjectResults per model. See below.
bbox, polygonsarrayDetections used when the image type has none.

Each entry of imageShow:

FieldDescription
imageDataFull image.
imageDataThumbnailThumbnail. Without it, the thumbnail uses imageData; without imageData, the detail uses the thumbnail.
imageDataMaskMask version of the image, shown when MASK is on.
imageDataThumbnailMaskMask version of the thumbnail.
bboxBoxes of this type.
polygonsPolygons of this type.

An image can be a URL, a data URL or bare base64. Bare base64 longer than 100 characters gets a data: header from its first bytes: JPEG, PNG, WebP or GIF, and JPEG when none matches.

The grid shows the first type of each image. The detail panel keeps the type selected for the previous image when the new one has it; otherwise it shows join when the image has that type, else its first type. The selector shows the type names with spaces for underscores, and the strip of the maximized view follows the type selected.

An older format is also accepted: { imageData, filename }, with imageUrl or image in place of imageData and name in place of filename. It becomes an image with a single type named image and no result, date or detections.

Detections ​

  • Box: { x_rel, y_rel, w_rel, h_rel, tag, score, color }. x_rel and y_rel are the top-left corner, w_rel and h_rel the size, all as fractions (0 to 1) of the image. A box with a missing or non-numeric coordinate is skipped.
  • Polygon: { points, tag, confidence, color, alpha }. points is [[x, y], ...] or [{ x, y }, ...] in fractions of the image, with at least 3 valid points. alpha is the opacity of the fill in the detail image (0.35 when missing).
  • Colour: a CSS colour, { r, g, b, a } or [r, g, b, a] (a optional). When it is missing or not valid, the colour is derived from tag; a polygon without tag is green.
  • Label: in the detail image, tag followed by score (boxes) or confidence (polygons) cut to two decimals, for example scratch 0.95. A detection without tag has no label. Thumbnails show the shapes without labels.

Models ​

resume is an object keyed by model name. Each model is an expandable panel. Its header is red when the model's result is NOK and green when it is OK; with any other result, red or green follows isAnomalous (true or false), and the header is dark blue when neither tells. Inside, one row per field. Numbers between 0 and 1 are shown as percentages when the field name contains score, confidence, probability, ratio or threshold, or when they are not whole numbers. A ruleResults array is listed rule by rule under each rule's name (or Rule 1, Rule 2, and so on). A model named barcode ocr, in any letter case, is not shown.

Output ​

This node does not send messages. The output port is never used.

Status and errors ​

  • No group configured: logged when the node has no group. The widget is not shown.

Usage example ​

A function node triggered by a click in another widget (so msg._client points to that browser). It opens the dialog with the class as title, then sends the images of that class:

js
const open = {
    _client: msg._client,
    class: "scratch",
    payload: { showDialog: true }
};

const images = {
    _client: msg._client,
    payload: [
        {
            id: "1742547441440",
            name: "1742547441440",
            date: 1742547441440,
            result: "NOK",
            isAnomalous: true,
            imageShow: {
                raw: {
                    imageData: "/images/1742547441440_raw.jpg",
                    imageDataThumbnail: "/images/thumbs/1742547441440_raw.jpg",
                    bbox: [
                        { x_rel: 0.42, y_rel: 0.31, w_rel: 0.08, h_rel: 0.05, tag: "scratch", score: 0.93 }
                    ]
                }
            },
            resume: {
                defects: { result: "NOK", score: 0.93, minScore: 0.5 }
            }
        }
    ]
};

return [[open, images]];

Both messages leave on the same output, in that order, so the images arrive once the dialog is open.