Follow this procedure to test the DL Streamer Pipeline Server OPC UA publishing using the docker.
-
Configure and start the OPC UA Server
If you already have a functioning OPC UA server, you can skip this step. Otherwise, this section provides instructions for using the OPC UA server provided by Unified Automation.
-
Download and Install the OPC UA Server Download the OPC UA C++ Demo Server (Windows) and install it on your Windows machine. Please note that this server is available only for Windows.
-
Starting the OPC UA Server
- Open the Start menu on your Windows machine and search for UaCPPServer.
- Launch the application to start the server.
-
-
Update the following variables related to the OPC UA server in
.env.OPCUA_SERVER_IP= # <IP-Address of the OPC UA server> OPCUA_SERVER_PORT= # example: 48010 OPCUA_SERVER_USERNAME= # example: root OPCUA_SERVER_PASSWORD= # example: secret
-
Update the OPC UA
variableto appropriate value for the pipelinepallet_defect_detection_opcuainapps/pallet-defect-detection/configs/pipeline-server-config.json."opcua_publisher": { "publish_frame" : true, "variable" : "ns=3;s=Demo.Static.Scalar.String" },
-
To use an AI model of your own please follow the steps as mentioned in this document
-
Setup the application to use the docker based deployment following this document.
-
Start the pipeline using the following cURL command. Update the
HOST_IPand ensure the correct path to the model is provided as shown below. This example starts an AI pipeline.Note: If you're running multiple instances of app, ensure to provide
NGINX_HTTPS_PORTnumber in the url for the app instance i.e. replace<HOST_IP>with<HOST_IP>:<NGINX_HTTPS_PORT>If you're running a single instance and using anNGINX_HTTPS_PORTother than the default 443, replace<HOST_IP>with<HOST_IP>:<NGINX_HTTPS_PORT>.curl -k https://<HOST_IP>/api/pipelines/user_defined_pipelines/pallet_defect_detection_opcua -X POST -H 'Content-Type: application/json' -d '{ "source": { "uri": "file:///home/pipeline-server/resources/videos/warehouse.avi", "type": "uri" }, "destination": { "metadata": [ { "type": "opcua", "publish_frame": true, "variable": "ns=3;s=Demo.Static.Scalar.String" } ], "frame": { "type": "webrtc", "peer-id": "pddopcua", "overlay": false } }, "parameters": { "detection-properties": { "model": "/home/pipeline-server/resources/models/pallet-defect-detection/deployment/Detection/model/model.xml", "device": "CPU" } } }'
-
Run the following sample OPC UA subscriber on the different machine by updating the
<IP-Address of OPCUA Server>to read the meta-data written to server variable from DL Streamer Pipeline Server.import asyncio from asyncua import Client, Node class SubscriptionHandler: def datachange_notification(self, node: Node, val, data): print(val) async def main(): client = Client(url="opc.tcp://<IP-Address of OPCUA Server>:48010") client.set_user("root") client.set_password("secret") async with client: handler = SubscriptionHandler() subscription = await client.create_subscription(50, handler) myvarnode = client.get_node("ns=3;s=Demo.Static.Scalar.String") await subscription.subscribe_data_change(myvarnode) await asyncio.sleep(100) await subscription.delete() await asyncio.sleep(1) if __name__ == "__main__": asyncio.run(main())
Install asyncua before running the above script (if not already installed):
pip3 install asyncua