Interactive measurements with annotation markers in Zen Core v2.4

In this subforum specific Topics concerning ZEN Core, e.g workbenches, are discussed
Post Reply
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Interactive measurements with annotation markers in Zen Core v2.4

Post by user-6033 »

Hi,

We often measure phases with aid of a grid and a simple counting procedure where the underlying phase under a grid crossing point is counted and cathegorized. These phases are too complicated to be analysed by image analysis procedures. I have been trying to modiffy your example named "Interactive measurements of several images" since I found it an excellent way to to have this manual step but where the script can handle all the statistics and help with the automation of the whole procedure. However, I am stuck at different issues.

1. How to modify the part below into Zen Core 2?

28 image = Zen.Application.LoadImage(PathAndFile,False)
29. Zen.Application.Documents.Add(image)
30. ## Switch to Measurement view
31. imageView = Zen.Application.DocumentViews.Find(image)
32. imageView.ActiveViewType = ZenDocumentView.ImageMeasurement
33. ## Pause loop and tell user what to do
34. Zen.Application.Pause('Switch to Graphics view, Select Keep tool, Select circle tool and draw circles.\nThen press Continue! \nMeasured images will be saved!')"

2. How to show the grid? It seems to be something very simple but I have tried several different ways with image.graphics.showgrid() without any succes. I have put image as activedocument, showed it in zenwindow, running the macro by clicking apply button etc, but do not succed.

3. Is it possible to reach the annotion objects "marker" or "event" and use those? In graphics there are different objects where one is frequentannotions, if I remember the correct name. I do not see really how to reach and use teh specific annotation markers types as specified above. And if I can not use them from OAD can they really be saved together with image and be used afterwards for statistics?

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Dear Frederik Olsson

Please let me start with some general understanding of the ZEN Core software.

ZEN Core is designed to be a workflow system where you can add workbenches to perform the individual steps.
These workbenches can do ‘load file’ or ‘interactive measurement’ etc.
The main idea of OAD within this workflow concept is to be able to generate an additional step, which is not available by the software itself.
Therefore an OAD-workbench acts as an enhancement to the ‘fixed’ workbenches delivered.

ZEN blue is completely different to ZEN Core as e.g. there is no workflow concept at all.
Therefore, ZEN blue has ‘no guidance’ for the user and thus the user can freely act in his ‘toolbox’.
In ZEN blue a macro usually ‘mimics’ the clicks, that a user would do.
This enables OAD programmers to bring a certain workflow to the user or to do things repeatedly.

To summarize it, ZEN Core uses OAD-workbenches as part of a workflow system whereas ZEN blue uses an OAD-macro to automate ZEN.

It is clear to me that some examples of ZEN Core ‘suggest’ to write one OAD-workbench that does all the work. Therefore, the resulting workflow consists of a single step that performs a workflow itself. But, as sayed before, this is not the Intention.

To come back to your questions, Zen.Application.LoadImage(PathAndFile,False) or ZenDocumentView.ImageMeasurement are already available as workbenches.

I know that this does not directly answer your questions but I would like to know if this change of concept would fit to your requirements.
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

In this case OAD script is mainly aimed at provide help for phase calculations (statistics) and help to switch color and name of annotation marker. Showgrid() is of less importance, I just couldn't figure out why it doesn't display on the image when other graphic elements like rectangle does. However it would have been great if it was possible within the script to preconfigure an annotion marker, such as events or marker, with a color and a name. The user can use it until it is time to change to next phase where the script switches name and color, which continues until the process is finished and the script puts statistics in table.

First we tried with help from Zeiss without any use of OAD but could not fully accomplisch the task.

Use of annotation marker is beneficial compared with use of other graphical elements since it is very fast and convenient to click.

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

help to switch color and name of annotation marker
Hello Frederik Olsson,

maybe there is a solution …

The basis is to build a workbench. In my test the tasks ‘Open File’, ‘Macro’, ‘Interactive Measurements’ (Painting first phase), Macro, ‘Interactive Measurements’(Painting second phase), … have been added.

So each time a macro is called a rectangle is inserted in the image to be displayed in the next ‘Interactive Measurements’ step. Each macro step can have its own color setting of the rectangles to be generated. It is also possible to generate multiple rectangles and them position via drag & drop in the Mesurement step. In case only one rectangel is generated (as in the code example) copy & paste can be used to get more of them.

Code: Select all

image = Zen.Application.ActiveWorkbench.GetDefaultInputValue()

zg = ZenGraphic(ZenGraphicCategory.Rectangle)
zg.StrokeColor = ZenColor.FromRgb(255,128,0)
zg.TextColor = ZenColor.FromRgb(255,128,0)
zg.SetBounds(10,10,200,200)

image.Graphics.Add(zg)

Zen.Application.ActiveWorkbench.SetDefaultOutputValue(image)
An alternative is to build a workflow with two central steps ( ‘Interactive Measurements’, Macro) and use

Zen.Application.ActiveWorkbench.StepBack = True

instead of the last line in the macro

Zen.Application.ActiveWorkbench.SetDefaultOutputValue(image)

The StepBack works in 2.4, but not very smoothly. In the next version of ZEN core this will work as expected.

I hope the ideas presented are of use to you.
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

Thanks a lot!! I will probably try both of these since both of them seems vey promising for the task. I really like the idea of the last example, to use stepback method, and we are about to upgrade to v2.5 asap so hopefully this will work smoothly. I do think there is some missing examples of how OAD and workflow can be used as efficent as possible, and maybe give insight in some new ways of working. Current workflow have helped in some easy cases but so far had some missing parts so that there has been a need for more advanced OAD scripts to backup the process. However, I do think some of those issues may be of less importance with v2.5.

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

how OAD and workflow can be used
Hello Frederik Olsson,

there are at the moment not so many tricks.

The only thing I would like to mention is:

If you work with workbenches, as proposed above, there is a way to transfer data from one OAD-Macro to another.

An arbitrary data (object) can be set in Macro1 via a key like

Zen.Application.ActiveWorkbench.SetOutputValue(1,"MyKey")

In a ‘later’ Macro2 the data can be read via

i = Zen.Application.GetLastOutputParameterValue("MyKey")


Maybe this is of use to you.
Post Reply