Skip to content
STAGING SERVER
DEVELOPMENT SERVER

Basler Vision Connector: ZeroMQ JSON Test File with Image Viewer#

This ZeroMQ sample demonstrates how to use the Basler Vision Connector to open or close a camera and pre-viewing images of the camera in the image viewer by injecting JSON commands via the ZeroMQ protocol.

Info

Before you start the sample script: If you want to run the script in the Siemens ecosystem, make sure that you have installed the following nodes:

Before execution, ensure that the camera ID is correctly set in both the Device ID parameter and the ZMQ node (device/yourcamera/stream) to match the target camera.
For further possible JSON commands, refer to the Messaging topics in this documentation.

[
    {
        "id": "8507e5326cbfceb7",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "6f708aeb55566cd4",
        "type": "group",
        "z": "8507e5326cbfceb7",
        "name": "Image Viewer",
        "style": {
            "stroke": "#00457C",
            "fill": "#F59D21",
            "label": true,
            "color": "#00457C"
        },
        "nodes": [
            "dd176032ecbd8d32",
            "ac308526b9496d98",
            "0c4e54d7f274bb1c"
        ],
        "x": 594,
        "y": 339,
        "w": 372,
        "h": 122
    },
    {
        "id": "2e5624a5c0ebe0e8",
        "type": "group",
        "z": "8507e5326cbfceb7",
        "name": "Step 1: Get Connected Devices",
        "style": {
            "stroke": "#00457C",
            "fill": "#F59D21",
            "label": true,
            "color": "#00457C"
        },
        "nodes": [
            "77578726a4bffe85"
        ],
        "x": 254,
        "y": 179,
        "w": 252,
        "h": 82
    },
    {
        "id": "a8ee4a3c08b9bc67",
        "type": "group",
        "z": "8507e5326cbfceb7",
        "name": "Step 2: Open Desired Camera",
        "style": {
            "label": true,
            "fill": "#F59D21",
            "stroke": "#00457C",
            "color": "#00457C"
        },
        "nodes": [
            "805fc483dc2c2310",
            "c498adca88babf70"
        ],
        "x": 254,
        "y": 299,
        "w": 212,
        "h": 122
    },
    {
        "id": "ed8ab57337f5915d",
        "type": "group",
        "z": "8507e5326cbfceb7",
        "name": "Step 3: Set Parameters",
        "style": {
            "fill": "#F59D21",
            "label": true,
            "stroke": "#00457C",
            "color": "#00457C"
        },
        "nodes": [
            "f752875b030239fa",
            "f958e3bbd5386335"
        ],
        "x": 254,
        "y": 459,
        "w": 232,
        "h": 122
    },
    {
        "id": "8401886b04aba205",
        "type": "group",
        "z": "8507e5326cbfceb7",
        "name": "Step 4: Start Streaming",
        "style": {
            "fill": "#F59D21",
            "label": true,
            "stroke": "#00457C",
            "color": "#00457C"
        },
        "nodes": [
            "fdf43aeae6b2f048",
            "94334e322ecee30d"
        ],
        "x": 254,
        "y": 619,
        "w": 232,
        "h": 122
    },
    {
        "id": "77578726a4bffe85",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "2e5624a5c0ebe0e8",
        "name": "EnumerateDevices",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"EnumerateDevices\"}",
        "payloadType": "json",
        "x": 390,
        "y": 220,
        "wires": [
            [
                "c04e7d0d7bdef94c"
            ]
        ]
    },
    {
        "id": "e452b3e31863a070",
        "type": "debug",
        "z": "8507e5326cbfceb7",
        "name": "debug",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 915,
        "y": 260,
        "wires": [],
        "l": false
    },
    {
        "id": "c04e7d0d7bdef94c",
        "type": "zeromq request",
        "z": "8507e5326cbfceb7",
        "name": "",
        "fields": "payload",
        "server": "tcp://baslervisionconnector-x86-64:5555",
        "output": "string",
        "isserver": false,
        "intype": "req",
        "x": 820,
        "y": 260,
        "wires": [
            [
                "e452b3e31863a070"
            ]
        ]
    },
    {
        "id": "805fc483dc2c2310",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "a8ee4a3c08b9bc67",
        "name": "OpenDevice",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"OpenDevice\",\"DeviceID\":\"1\"}",
        "payloadType": "json",
        "x": 370,
        "y": 340,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "c498adca88babf70",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "a8ee4a3c08b9bc67",
        "name": "CloseDevice",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"CloseDevice\",\"DeviceID\":\"1\"}",
        "payloadType": "json",
        "x": 370,
        "y": 380,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "ac308526b9496d98",
        "type": "zeromq in",
        "z": "8507e5326cbfceb7",
        "g": "6f708aeb55566cd4",
        "name": "",
        "topic": "device/40062774/stream",
        "fields": "topic,image,metadata",
        "server": "tcp://baslervisionconnector-x86-64:5556",
        "output": "buffer",
        "isserver": false,
        "intype": "sub",
        "x": 730,
        "y": 400,
        "wires": [
            [
                "dd176032ecbd8d32",
                "0c4e54d7f274bb1c"
            ]
        ]
    },
    {
        "id": "fdf43aeae6b2f048",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "8401886b04aba205",
        "name": "StartStreaming",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"StartStreaming\",\"cstm_FormatConversion\":\"JPEG\",\"DeviceID\":\"1\"}",
        "payloadType": "json",
        "x": 380,
        "y": 660,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "94334e322ecee30d",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "8401886b04aba205",
        "name": "StopStreaming",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"StopStreaming\",\"DeviceID\":\"1\"}",
        "payloadType": "json",
        "x": 380,
        "y": 700,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "dd176032ecbd8d32",
        "type": "debug",
        "z": "8507e5326cbfceb7",
        "g": "6f708aeb55566cd4",
        "name": "Raw Data",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 905,
        "y": 420,
        "wires": [],
        "l": false
    },
    {
        "id": "4e43f75c9fc8d57d",
        "type": "mp-function",
        "z": "8507e5326cbfceb7",
        "name": "Device ID",
        "rqs": "",
        "func": "let jsonMessage = msg.payload;\njsonMessage.DeviceID = \"40062774\";\n\nmsg.payload = jsonMessage;\n\nreturn msg;",
        "persistent": false,
        "outputs": 1,
        "threads": 1,
        "noerr": 0,
        "x": 660,
        "y": 300,
        "wires": [
            [
                "c04e7d0d7bdef94c"
            ]
        ]
    },
    {
        "id": "f752875b030239fa",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "ed8ab57337f5915d",
        "name": "SetPixelFormat",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"SetParameters\",\"DeviceID\":\"1\",\"ParameterList\":[{\"Name\":\"PixelFormat\",\"Value\":\"RGB8\"}]}",
        "payloadType": "json",
        "x": 380,
        "y": 500,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "f958e3bbd5386335",
        "type": "inject",
        "z": "8507e5326cbfceb7",
        "g": "ed8ab57337f5915d",
        "name": "SetFPS",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Action\":\"SetParameters\",\"DeviceID\":\"1\",\"ParameterList\":[{\"Name\":\"AcquisitionFrameRateEnable\",\"Value\":true},{\"Name\":\"AcquisitionFrameRate\",\"Value\":10}]}",
        "payloadType": "json",
        "x": 350,
        "y": 540,
        "wires": [
            [
                "4e43f75c9fc8d57d"
            ]
        ]
    },
    {
        "id": "5199de11a4781717",
        "type": "comment",
        "z": "8507e5326cbfceb7",
        "name": "This example demonstrates how to use ZMQ to display the camera image stream within Node-RED. \\n \\n  Note: Before execution, ensure that the camera ID is correctly set in both the Device ID \\n parameter and the ZMQ node (device/yourcamera/stream) to match the target camera.",
        "info": "",
        "x": 580,
        "y": 100,
        "wires": []
    },
    {
        "id": "01e0ddb165e6bb09",
        "type": "image",
        "z": "8507e5326cbfceb7",
        "name": "Image Viewer",
        "width": "400",
        "data": "image",
        "dataType": "msg",
        "thumbnail": false,
        "active": true,
        "pass": true,
        "outputs": 1,
        "x": 995,
        "y": 360,
        "wires": [
            []
        ],
        "inputLabels": [
            "JPEG Image"
        ],
        "l": false
    },
    {
        "id": "0c4e54d7f274bb1c",
        "type": "function",
        "z": "8507e5326cbfceb7",
        "g": "6f708aeb55566cd4",
        "name": "extract data",
        "func": "return {\n    image: msg.metadata,\n};\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 905,
        "y": 380,
        "wires": [
            [
                "01e0ddb165e6bb09"
            ]
        ],
        "l": false
    }
]