Omron Camera Nodes for Node-RED
@rosepetal/node-red-contrib-camera-omron provides 3 nodes for Node-RED that receive the frames of Omron GigE cameras, send them software triggers and change their parameters.
Installation
cd ~/.node-red
npm install @rosepetal/node-red-contrib-camera-omronThe package is not on the public npm registry. Its releases are published to Rosepetal's private npm registry, so npm needs that registry configured for the @rosepetal scope, with credentials for it. Restart Node-RED after the installation.
The cameras are driven by two services that run as Docker containers, from two images tagged with the version of the package. When Start Omron is pressed in a node's dialog, the images that are not on the host yet are pulled from Rosepetal's private container registry, so Docker on the host must be logged in to it.
From a clone of the repository
The repository keeps the installer of the Sentech SDK in Git LFS, so clone it with Git LFS installed. Then, on the host that runs Node-RED:
./install.shThe script:
- Unpacks the Sentech SDK into
sentech-driver/SentechSDK/. It asks forsudofor this step. - Builds the Docker images of the discovery service and of the camera publisher with
sudo docker. It first stops and removes the discovery and camera containers that exist on the host, and the images of a previous build. - Runs
npm installinnode-red/, which fetches thenatsclient. - Looks for the Node-RED user directory,
~/.node-redfirst, and offers to installnode-red/there. If you decline, or no directory is found, it prints thenpm installcommand to run in that directory.
Restart Node-RED afterwards. The nodes start the services from the images tagged with the version of the package, as described above, and pull them when the host does not have them.
Requirements
- Linux x86-64 host with Docker Engine. The user that runs Node-RED must be allowed to run
docker: the nodes call the Docker command line. - A NATS server that listens on port 4222 of that host. The nodes connect to
nats://127.0.0.1:4222, or to the URL in theNATS_URLenvironment variable of the Node-RED process; the two services always connect tonats://localhost:4222. - Node-RED on the same host, with the host's
/dev/shmvisible to it:omron-collectorreads the frames from there. The publisher runs as root in its container and creates the segments with permissions0660, so only root and the members of the root group can read them: run Node-RED as one of them. - Node.js 14 or later.
- Omron GigE cameras on a network interface of the host. The discovery service lists the devices whose vendor, model or display name contains
omron.
Nodes
The three nodes appear under the RP Omron category in the editor.
| Node | Purpose |
|---|---|
| omron-collector | Start and stop the services and the cameras from its dialog, and emit every frame of the selected cameras as a raw image |
| omron-trigger | Send a software trigger to the selected cameras for each incoming message |
| omron-config | Set camera parameters (region of interest, exposure, gain, acquisition mode or any other GenICam node) from constants, the message or the context |
How it works
The nodes do not open the cameras: two services that run as Docker containers on the same host do. The discovery service (container omron-discovery) finds the cameras with the Sentech SDK and starts or stops one publisher container per camera (omron-<MAC>, with the MAC address in upper case and hyphens); each publisher grabs the frames of its camera, converts them to BGR8, writes them to shared memory (/dev/shm) and announces them through the NATS server. omron-collector copies each announced frame from shared memory into a message, and omron-trigger and omron-config send their requests to the publisher through NATS.
The README of the repository describes the services, their NATS subjects and how to build and run them by hand.
Quick start
[omron-collector] → [debug]
[inject] → [omron-trigger]- Start the NATS server before Node-RED.
- Add an
omron-collectornode and open it. Press Start Omron and wait for the panel to showRunning: the cameras found on the network are listed under Available Cameras. - Press Start on a camera whose status is
Free. A camera inNo accessneeds Fix IP first. The publisher waits 10 seconds before it opens the camera; the status then changes toControlled (ours). - Tick the Select checkbox of the camera, close the dialog and deploy. The node shows
subscribed 1and emits one message per frame, with the image inmsg.payload. - To take images on demand, set the
TriggerModeof the camera toOnwith an omron-config node (parameter Custom…), then add anomron-triggernode, select the same camera in its dialog and send it a message.
The publisher does not change the trigger and acquisition settings of the camera when it starts, so the camera delivers frames as it is configured. Use omron-config to change them.
Restarts and reconnection
The containers are created with the restart policy unless-stopped: the discovery service and the publishers of the cameras that were started come back when Docker or the host restarts, without opening a dialog again. A publisher waits 10 seconds after it starts before it opens its camera.
When the link with a camera drops (cable, power), its publisher keeps running and tries to open the camera again until it is back. It then applies again the parameters it had received from omron-config and resumes the acquisition. Meanwhile omron-collector shows reconnecting. While the camera is visible on the network but cannot be opened, the publisher asks the discovery service to repair its IP address, as Fix IP does, about every 30 seconds. A publisher that starts while its camera is unreachable stays alive and follows the same procedure.
Image format
msg.payload of omron-collector is a raw image object:
{
data: Buffer, // Raw pixel data, 8 bits per channel in B, G, R order
width: number, // Image width in pixels
height: number, // Image height in pixels
channels: 3,
colorSpace: "BGR",
dtype: "uint8"
}It is the object that the nodes of @rosepetal/node-red-contrib-image-tools pass between them, so the output of omron-collector can be wired to them.