
Engineering Insight | How Mehdi Shayestehfar at Ti2 integrated Basler industrial cameras, Python, FastAPI, CODESYS and OPC UA through a shared camera service.
Industrial machine vision involves more than connecting cameras and capturing images. When camera operations need to be accessible through browser-based engineering tools and PLC applications, the challenge includes coordinating hardware access, commands and system status.
For a Sydney-based startup, Mehdi Shayestehfar, Head of Engineering at Ti2, developed a web-first machine vision platform integrating Basler industrial cameras, Python, FastAPI, CODESYS and OPC UA.
The objective was to create a maintainable architecture in which engineers could manage cameras through a browser while PLC applications could initiate supported operations through the same underlying service.
The project highlights a practical industrial integration question: how can different interfaces share equipment while maintaining consistent status reporting and explicit control permissions?
Sharing camera access across interfaces
The platform needed to support live viewing, image capture, recording, parameter management and PLC-initiated operations.
The browser interface and PLC application both needed access to the same physical cameras. Allowing each interface to establish its own independent hardware connection could introduce competing access, inconsistent status information and more complicated error handling.
The architecture therefore needed a defined approach to camera ownership, command coordination and shared system state.
It also needed to preserve browser-based engineering access for commissioning and diagnostics while allowing CODESYS to initiate camera operations when authorised.
One central camera service
Mehdi designed the platform around a central Python service responsible for managing the physical Basler cameras.
The FastAPI application maintains camera sessions and uses per-camera locks to coordinate access to camera operations. The browser interface and OPC UA integration communicate through this service rather than independently managing the hardware.
This establishes a common application-level path for camera operations and a shared basis for reporting camera status and errors.
The platform described in the original article supports:
- Logical camera slots and retained camera sessions.
- Full-resolution image capture.
- Live viewing and recording.
- Image statistics and histogram information.
- Saved camera parameter profiles.
- Browser-based engineering and diagnostic pages.
- PLC-initiated operations through CODESYS and OPC UA.
- Shared camera status and error reporting.
Centralising camera management establishes a clear ownership model. Additional interfaces can use the service without each introducing a separate hardware connection.
Keeping engineering access available
An important design decision concerned how browser-based engineering tools and PLC control would coexist.
An initial approach restricted browser control while PLC operation was enabled. During development, this limited access to functions needed for commissioning and recovery.
The revised approach retained access to the authenticated browser interface while allowing the operator to enable or disable PLC command authority through the web dashboard.
This separates monitoring from permission to operate the cameras.
The PLC can receive camera status information when command authority is disabled, provided the communication connection and telemetry path remain operational. Separately, the backend checks whether PLC-initiated operations are permitted.
Enforcing that check in the Python backend matters. Disabling a visible browser or HMI control does not, by itself, prevent another client from attempting to issue a command.
These command-permission checks are one part of the access arrangement. They should not be interpreted as a complete description of security across the browser, OPC UA connection, host computer and network.
Coordinating PLC commands through OPC UA
Communication between CODESYS and the camera service uses an application-level request, acknowledgement and completion sequence over OPC UA.
The sequence described for Project X is:
- CODESYS writes the parameters required for the operation.
- The PLC increments the Request ID after the command details are ready.
- Python detects the request and updates the acknowledgement state.
- The camera service attempts the requested operation.
- The result and status fields are updated.
- The Completed ID is updated after the result information has been written.
The ordering gives the PLC application a defined way to distinguish a new request from an operation that has been acknowledged or completed.
Request and completion identifiers also help associate commands with their results. However, they do not independently guarantee duplicate-request handling, timeout detection or recovery after interrupted communication. Those behaviours depend on the surrounding application logic.
That distinction is important when describing the integration. A defined handshake provides structure, while fault handling requires its own implementation and testing.
Commissioning in stages
Development followed a staged approach so that individual functions could be assessed before additional integration requirements were introduced.
Camera verification
Camera discovery and image acquisition were checked using Basler pylon Viewer.
Browser-based control
Web control was established for each camera, with retained sessions and synchronised status information.
OPC UA communication
The command handshake was introduced using simulated operations, alongside heartbeat exchange.
Camera service integration
The OPC UA exchange was connected to the physical camera service.
CODESYS integration
CODESYS visualisation controls were added for PLC-initiated camera operations.
Access management
Browser authentication and web-controlled PLC command permissions were implemented.
Interface testing
Responsive behaviour was checked across industrial monitors, laptops, tablets and mobile phones.
This sequence allowed camera functionality, communication and control behaviour to be assessed progressively. Completing these development stages should be distinguished from final production acceptance.
Engineering lessons from Project X
Define hardware ownership early
When several interfaces need access to the same equipment, a central service can establish a clear ownership model and help prevent competing hardware connections.
Separate monitoring from control authority
A PLC may need equipment status even when it is not authorised to initiate operations. Treating telemetry and command permissions separately allows diagnostic visibility to be considered independently.
Enforce permissions where commands are processed
Interface restrictions should be supported by checks in the application responsible for processing operations, alongside appropriate authentication and access controls.
Define command states and failure behaviour
The PLC needs a clear way to determine whether an operation has been received, acknowledged, completed or rejected. Result states and communication-failure behaviour need to be specified and tested.
Include engineering access in the architecture
Browser-based diagnostics can be useful during commissioning and recovery. Access arrangements should account for troubleshooting as well as normal machine operation.
Development outcome and next steps
Mehdi’s original article describes a working approach to integrating industrial cameras with browser-based tools and PLC applications through a shared software service.
The architecture brings camera management, engineering access and PLC communication together around common camera sessions, shared state and a defined command exchange.
At the time of that article, the next phase included deployment on the target Windows PC, regression testing with the installed Basler cameras and further integration of production inspection results, recipes and traceability.
The reported outcome is therefore architectural and developmental. Completed production deployment, acceptance-test results and operational benefits should be added only when confirmed.
For engineers developing similar applications, the project demonstrates why equipment ownership, command coordination and shared state deserve as much attention as the individual technologies.
Frequently asked engineering questions
How can a browser interface and a PLC share industrial cameras?
One approach is to centralise camera ownership in a service that exposes operations to both interfaces. In Project X, the Python and FastAPI service manages the Basler cameras, while the browser and CODESYS integration communicate through that service.
What role does OPC UA play?
OPC UA provides the communication mechanism between the PLC application and camera service. The application defines command parameters, request identifiers, acknowledgement states and result handling.
Why separate monitoring from command permissions?
Monitoring provides equipment status. Command permissions determine whether an interface can initiate operations.
Separating them allows diagnostic visibility to remain available when command authority is disabled, subject to the communication path remaining operational.
Developed by Mehdi Shayestehfar, Head of Engineering, Ti2. Adapted from his original article, “Building a Web-First Machine Vision Platform for Project X”.
Have a machine vision, CODESYS or industrial software integration requirement?
Contact Patrick van Eybergen at Ti2:
Phone: 1300 842 111
Email: sales@ti2.com.au
