Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Operator View is intended to give you an opportunity to design a simple UI for your line operators, where they can view the camera with an evaluation of the current image and optionally see other information or be able to enter/choose inputs, which can then be processed in Code.

Editor

Editor is the place where you can design, how the Operator View should look like - determine what elements it should contain and customize their its position, style, and function.

...

The Root and Camera elements are always present in Operator View, but you have the option to add and customize other elements like Label, Input, Select, Slider, or SliderImage.

Info

Position of element can be changed not only by entering specific X and Y number in its settings, but also by clicking on the element and dragging it around the view.

...

This is a parameter for optional elements, which allows you to determine that a certain element will be visible only if the specified key in Context is True. You can then set this key in Code based on your own rules.

...

Then, you can change the specified context key in the Code module for each processed image and the value the key currently has will be shown in the Label in Operator View.

E.g. if you enter this simple code in the Code module, it will show the text ‘True’ in the label if an image is evaluated as OK and ‘False’ if an image is evaluated as NGNOK:

Code Block
languagepy
def main(context):
    context['label_key'] = str(context['result'])

...

Input element allows the operator to write any input text into a field, which can then be processed in Code.

...

The basic settings you can choose are position, background color, text color, width, font size, and visibility by key.

...

Enable Max Length option lets you limit the number of characters the operator is allowed to input into this field.

...

Target Key is the key in Context which will contain the value which was entered in this field at the time the image was processed. You can then work with this value in Code where you access it with (if the target key is set to ‘input1’):

...

Select element allows the operator to select one of the defined options and the chosen option can then be processed in Code.

...

The basic settings you can choose are position, background color, text color, width, font size, and visibility by key.

You can also set the Label text for this select, which can describe what the operator should select in this field, e.g. product type, etc.

Slider

Slider element allows the operator to select a number from a given range set with min and max. Either by using the slider itself or the text field next to it (if enabled by Show text field).

The Label can be used to describe what kind of value is set by the slider. Apart from the position, you can also adjust the slider width and set visibility by key.

...

Disabling the text field can be used e.g. when trying to make an “on/off switch” between 0 and 1, otherwise, the text field is needed for showing the set value.

Target Key is the key in Context which will contain the value which was selected in this field at the time the image was processed. You can then work with this value in Code where you access it with (if the target key is set to ‘input2’):

...

When you finish configuring your operator view in Editor, you can click on Save and go back to the Camera tab and select Operator View > Open operator View, then a window like this will open (with elements as you defined them in Editor) and the operator can start interacting with it:

...

Info

For images you saved (when you had ‘Save images’ enabled or you ‘Captured' the image while the Operator View was running) you can see the operator inputs at that time in the Inspection tab under 'operatorInput’ key, which is a dictionary containing key-value pairs for all your inputs/selects/sliders.

If you set some dynamic label, you can see the value of its context key (if you set its value in code) at that time under the context key name you selected, so e.g. 'label_key' in this example.

If you set visibility by key for some element and you set its value in code, you will see it here too under the name you selected for the key so e.g. ‘visibility_key’ in this example.

...