---
title: "Example Projects"
description: "Two LumiScan VGR 2.0 example projects - metal rings found by CAD matching (download) and syringes found by a neural network - to learn and test with."
product: "LumiScan VGR / VGR Lite"
component: "lumiscan-vgr"
version: "2.0.0"
display_version: "2.0.0.8"
latest_version: true
language: "en"
url: "https://docs.hdvisionsystems.com/en/lumiscan-vgr/reference/example-projects.html"
---

# Example Projects – LumiScan VGR / VGR Lite

Two complete LumiScan VGR projects from HD Vision Systems show how the settings fit together in a real cell. Both use the settings format of LumiScan VGR 2.0, and both are checked against the settings schemas of v2.0.0 without errors.

|   | metal-rings | ai-syringes |
| --- | --- | --- |
| Task | Pick metal rings from a bin | Pick syringes from a bin |
| Detection | 3D: CAD model matched to the point cloud (`OBJECT_MATCHING`) | 2D: neural network (`ORTM`), then 3D: line fit along the long axis (`LINE_FIT_LONG_AXIS`) |
| Robot | UR5, bin as environment | KUKA LWR, bin as environment |
| Interface | OPC UA | OPC UA |
| Runs without hardware | Yes, with two recorded datasets | Yes, with six recordings |
| Download | [lumiscan-vgr-example-metal-rings-v2.0.0.zip](https://docs.hdvisionsystems.com/en/lumiscan-vgr/_attachments/lumiscan-vgr-example-metal-rings-v2.0.0.zip) (10 MB) | Not published |

The metal-rings project is also the project on which the integration tests of LumiScan VGR run (OPC UA and script mode), so a cycle that works with it on your PC shows that the installation works. To run it step by step, follow [Try the Example Project](https://docs.hdvisionsystems.com/en/lumiscan-vgr/tutorials/first-grip-in-simulation.html); to test an installation with it, see [Test Without a Camera or PLC](https://docs.hdvisionsystems.com/en/lumiscan-vgr/howto/test-without-hardware.html).

## metal-rings: CAD Matching {#metal-rings}

![Grey-scale camera image from above: a clear plastic bin with about twenty metal rings, three rings beside it and the base of a UR5 robot at the top](https://docs.hdvisionsystems.com/en/lumiscan-vgr/_images/example-metal-rings-scene.png)

The rings have no texture a network could learn, but a simple, exact shape. The project therefore needs no neural network: the ring’s CAD model is matched against the point cloud, and two grip points on the ring, each repeated around its axis, give the robot grips from either side.

**Requirements:** LumiScan VGR 2.0.0 or later, and a HALCON licence: the 3D object matching uses HALCON (see [No point cloud matching can be performed](https://docs.hdvisionsystems.com/en/lumiscan-vgr/troubleshooting.html#ts-no-point-cloud-matching)).

**Table 1. Content of the download**

| File or folder | Content |
| --- | --- |
| `settings.json` | The project: camera drivers and cameras, robots, object, pipeline, the recipe `pick-ring`, OPC UA as interface. |
| `objects/ring.json` | The ring (`id` `ring`): CAD model `meshes/ring.stl`, object matching, two grip points with a path template. |
| `pipelines/match-ring.json` | The pipeline `match-ring`: image ROI, collision check against the environment `env`. |
| `robots/` | Three robots: `robot` (the cell, with the hand-eye calibration of both cameras), `ur5` (a UR5 without collision bodies) and `env` (the bin, for collision checks), each with its URDF. |
| `meshes/` | Ring, bin and gripper. |
| `cameras/features/` | One feature file per camera. |
| `data/camera/data1`, `data2` | Two recorded datasets, each an image (`test1.png`) and a point cloud (`test1.ply`) in metres (`dataset.unit.json`). |

### What it shows

- **A simulated camera in the settings file.** The camera `camera` uses the driver `driver-sim-camera` of type `Virtual`, which replays the folders below `data/camera`; `layout` `DATASETS` makes each subfolder a dataset. No command-line option is needed, and the camera keeps its ID. Two real cameras are configured too and switched off (`"enable": false`): a LumiScanX through `LumiScanPlugin.dll` and an Ensenso through `EnsensoPlugin.dll`. See [Camera Roster](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/cameras.html#camera-roster).
  ```json
  "cameraDrivers": [
      { "driverType": "Plugin",  "id": "driver-lumiscan",   "pluginPath": "LumiScanPlugin.dll" },
      { "driverType": "Plugin",  "id": "driver-ensenso",    "pluginPath": "EnsensoPlugin.dll" },
      { "driverType": "Virtual", "id": "driver-sim-camera", "path": "data/camera", "layout": "DATASETS" }
  ],
  "cameras": [
      { "cameraId": "camera", "serial": "LX20220109", "driverId": "driver-sim-camera", "enable": true,
        "featureFiles": [ "cameras/features/camera.device.txt" ] },
      ...
  ]
  ```
- **Settings in several files.** The robots, the object and the pipeline are kept in files of their own and taken into `settings.json` with a `$ref` to the file, for example `{ "$ref": "robots/robot.json#/robot" }`. Inside `objects/ring.json`, a path template (`templates.t_path`) is used by both grip points through `$ref`. See [JSON Preprocessing](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/preprocessing.html).
- **3D object matching.** The 2D step `SET_ROI_PIPELINE` passes the ROI of the pipeline on, and `detection3d` of type `OBJECT_MATCHING` finds the ring in the point cloud:
  ```json
  "detection3d": {
      "type": "OBJECT_MATCHING",
      "cadPath": "meshes/ring.stl",
      "roiPercentage": 1.0,
      "trainingParameters": { "featAngleResolution": 15 },
      "detectionParameters": { "relativeSamplingDistance": 0.04, "keyPointFraction": 0.2, "minScore": 0.13 }
  }
  ```
- **Symmetric grip points.** A ring looks the same after any rotation about its axis. Each grip point is therefore repeated every 22.5° with the pose operation `SYMMETRY_ROTATION`, so the robot gets a ring of candidates on each side and takes the best one it can reach without collision. See [Pose Operations](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/objects.html#pose-operations).
- **Relative waypoints.** The path approaches from above and behind the grip and leaves the same way (`WP_RELATIVE` waypoints of the robot `robot`). See [Relative Waypoints](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/robots.html#relative-waypoints).
- **Collision check against the bin.** The pipeline checks the paths against the robot `env`, whose URDF holds the bin (`collisionRobotFilter`), and against the point cloud (`collisionCloud`).
- **A recipe.** `pick-ring` selects the camera `camera`, the pipeline `match-ring` and the robot `robot` and runs `CAPTURE_IMAGE`, `COMPUTE_2D`, `COMPUTE_3D` and `GET_BEST_RESULT`. An OPC UA client runs it with `RunRecipe`. See [Recipe Settings](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/recipes.html).

## ai-syringes: Neural Network and Line Fit {#ai-syringes}

> [!NOTE]
> This project is not published, because it contains a trained neural network. The excerpts below show how its settings are built.

Syringes lie in a bin in every orientation, and they overlap. A neural network finds each syringe in the image as an oriented box; the points of the point cloud inside that box give the syringe’s position and long axis in 3D. The robot grips it from above.

![Grey-scale image of a bin full of syringes; about twenty syringes are framed by yellow oriented boxes labelled size_4](https://docs.hdvisionsystems.com/en/lumiscan-vgr/_images/example-ai-syringes-2d-detection.png)

*Figure 1. Syringes found by the neural network in the image: each oriented box is one syringe*

![Point cloud of the syringes seen from above, with yellow 3D boxes on the detected syringes](https://docs.hdvisionsystems.com/en/lumiscan-vgr/_images/example-ai-syringes-3d-detection.png)

*Figure 2. The same syringes as 3D boxes in the point cloud (Scene tab)*

![3D scene with a violet KUKA lightweight robot arm reaching with its gripper into a yellow bin that holds the point cloud of the syringes](https://docs.hdvisionsystems.com/en/lumiscan-vgr/_images/example-ai-syringes-best-grip.png)

*Figure 3. The best grip: the KUKA LWR reaches into the bin (Scene tab, Show Best Grip)*

### What it shows

- **A neural network in the 2D detection.** The network `detection_obbav_4` (type `ORTM`) is declared once and used by the object’s 2D steps. The steps set the ROI, run the network with a detection threshold of 0.4, and halve each box in both directions about a fixed point in the box (`SCALE`), so that only part of the syringe is used for 3D. See [Network Settings](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/networks.html) and [Object Settings](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/objects.html).
  ```json
  "networks": [
      { "id": "detection_obbav_4", "networkPath": "networks/ORTM/network_description.json" }
  ],
  ...
  "detection2d": {
      "steps": [
          { "type": "SET_ROI", "imageROI": { "x": 0, "y": 0, "width": 1280, "height": 960 } },
          { "type": "SET_NETWORK", "networkId": "detection_obbav_4", "detectionThreshold": 0.4, "local": true },
          { "type": "SCALE", "scale": [0.5, 0.5], "fixedPoint": [0, 0.5] }
      ]
  },
  "detection3d": { "type": "LINE_FIT_LONG_AXIS", "roiPercentage": 0.75 }
  ```
- **Three kinds of camera driver.** A LumiScanX through `LumiScanPlugin.dll`; an Ensenso through `EnsensoPlugin.dll` and a 2D camera through the Teledyne Spinnaker GenTL producer (`driverType` `GenICam`, `gentlPath`), both switched off; and a `Virtual` driver for the recordings. The recordings are replayed with `--simulate-camera --simulate-camera-path data`.
- **Camera parameters.** `cameraParameters[]` switches on the auto-exposure of the LumiScanX, measured in a polygon of the image, and gives the lens intrinsics (`fx`, `fy`, `cx`, `cy`) of the 2D camera, which cannot report them itself. See [Auto-exposure](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/cameras.html#auto-exposure).
  ```json
  "cameraParameters": [
      { "cameraId": "camera-lumiscan",
        "autoExposure": { "enable": true, "roi": [[160, 120], [1120, 120], [1120, 840], [160, 840]],
                          "statistic": "MEDIAN", "targetIntensity": 80, "tolerance": 10,
                          "acceptedIntensityMin": 20, "acceptedIntensityMax": 230,
                          "minExposureTime_us": 500, "maxExposureTime_us": 200000, "retryBudget_ms": 800 } },
      ...
  ]
  ```
- **Robot templates with `$parents`.** The settings file keeps the common part of a robot (pose format, URDF, frames, waypoints) under `templates.t_robot`; the robots `robot1` and `robot_free` take it with `$parents` and add only their hand-eye calibration (`cameraToRobot`). See [`$parents`](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings/preprocessing.html#parents).
  ```json
  "robots": [
      { "id": "robot1", "$parents": ["/templates/t_robot"],
        "cameraToRobot": { "camera-lumiscan": [[1, 0, 0, 0.0], [0, -1, 0, 0.5], [0, 0, -1, 0.61], [0, 0, 0, 1.0]], ... } },
      ...
  ]
  ```
- **A recipe.** `pick-needle` selects the camera `camera-lumiscan`, the pipeline `pipeline_4` and the robot `robot1` and runs the default cycle.

## Testing with the Example Projects {#testing}

- **Check a settings file.** Open `settings.json` of the example in an editor that checks JSON schemas, such as Visual Studio Code: the `"$schema"` key points to the schemas of the installed LumiScan VGR (see [`$schema` and Checking the File in an Editor](https://docs.hdvisionsystems.com/en/lumiscan-vgr/json-settings.html#schema)). The example shows no errors and no warnings. Compare your own project with it when the editor marks a key you do not understand.
- **Check an installation.** Run the recipe `pick-ring` of metal-rings in manual mode, from an OPC UA client or from a script, see [Test Without a Camera or PLC](https://docs.hdvisionsystems.com/en/lumiscan-vgr/howto/test-without-hardware.html). A cycle that returns `SUCCESS` shows that LumiScan VGR, its dependencies and the HALCON licence work on this PC.
- **Narrow down a problem.** If your own project fails and metal-rings works on the same PC, the cause is in your project (settings, files, camera), not in the installation.
