Calc Results By Python: Vision data type conversion to Python data types

The following information holds for Mech-Vision 1.7.x.

Supported Vision data types

  • PoseList
  • Pose2DList
  • NumberList
  • StringLis
  • Image;Cloud(XYZ)
  • Cloud(XYZ-Normal)
  • Size3DList
  • StringList
  • BoolList
  • IndexList

Input/Output Port Definition

Define multiple inputs by inserting a “;” (without space after “;” else input after the space gets dismissed)
E.g.: Input Port(s): NumberList;StringList

If the number of output ports does not match the number of outputs of the Python function it will happen that the Vision block (Calc Results by) returns “No Output” and the warning: “The number of parameters in the Python script is inconsistent with the number of output ports defined in the Step’s parameter.”

Data Type Mapping

Input/Output Port Shape/len Type DataType Comment
PoseList (N,7) np.array np.float64
Pose2DList (N,3) np.array np.float64 Order: (x,y,theta)
NumberList N list float
StringList N list str
Image/Color (H,W,3) np.array np.uint8
Image/Depth (H,W,1) np.array np.float32
Cloud(XYZ) (N,3) np.array np.float32 x,y,z in m
Cloud(XYZ-Normal) (N,7) np.array np.float32 x,y,z in m; Order: (x,y,z,nx,ny,nz,0)
Size3DList (N,3) np.array np.float64
BoolList N List bool
IndexList N List int

Mech-Vision Lists

It is possible to also pass a list to the Calc Results By Python block. A list in Mech-Vision will be converted to a nested Python list. E.g. PoseList[.] will be converted to a Python list that contains np.arrays.


1 Like

Thanks for the list Florian!

Do you know if there is a possible way of naming the Inputs and Outputs?
i.e. PoseList(“Poses from X”); PoseList(“Poses from Y”)

I regret to inform you that I am not aware that this is possible.
I would like to have this functionality as well.

The naming of these inputs is, as far as I have tested, only possible in the procedure out.
image

In adapter you can run the project and store the vision result. In this example I can now access the stored data using vision_result[“n_points”]

I believe it is currently not possible to name the inputs of the python steps. To increase readability you could however map them to the corresponding names in your python at the start of your function, and use allocators with step-name before/after the python step in Mech-Vision.

Hi,

Thank you for sharing this information.