Connect USB Webcam Tutorial

This tutorial will introduce you to the process of connecting a webcam sensor.

When working with sensors it is important to remember that every sensor is slightly different─some require a sensor identifier, or additional Linux configuration requirements, etc. The requirements for specific sensors can be found under Supported Sensors in the help center.

1. Define your node using the PolySync SDF Configurator

The first step towards connecting a sensor is to define your node using the PolySync SDF Configurator . You can either use the Ubuntu icon or enter the following command into a Terminal window to start the SDF Configurator:

$ polysync-core-sdf-configurator

Now you can add a new node. In the bottom left corner of the SDF Configurator window click “Add Sensor Node.” A dialog box will appear with a dropdown list for all of the currently supported sensor types. Choose “video-device” from this list.

After pressing “OK,” all of the parameters for the sensor will be visible. If using multiple cameras, be sure to name the sensor to avoid confusion.

Connecting Cam 1

The above Configurator allows you to manage three main categories of parameters, which help you with everything from physical device settings to file paths:

  • Node Configuration
    • Application settings, such as the file path for the the device driver
  • Sensor Configuration
    • Physical settings of the device, such as XYZ placement on the vehicle
    • Published and logged: Pixel format, image width/height, frames per second
    • Optional extended H264 encoder parameters
  • IO Configuration
    • IO settings for the data, such as video frames per second
    • Source: Pixel format, image width/height, frames per second
    • Source device configuration parameters

Within the SDF Configurator all changes are saved after pressing “Enter.”

Copy the node’s SDF ID. This will be used later to start the node.

2. Enumerate and assess the video device name

When the video device is connected to the Linux machine the Video4Linux drivers will enumerate the device name, similar to /dev/video0.

When the device is initialized during the boot process or connected to the host machine you will see it in /var/log/syslog or you can run dmesg in a terminal before connecting the device to your host machine.

Once the device is connected to the host machine, you can add it in the SDF Configurator IO Configuration panel under “Video Device 0 Name” field.

You can also see all video devices by doing:

$ ls -l /dev/video*

3. Starting PolySync manager

Next, you’re going to call the PolySync manager daemon and signal it to start the wall clock:

$ polysync-core-manager

Once that has been completed, you can start the node manually by using the -n flag to reference the “Node ID:” in the Node Configuration section of the SDF Configurator:

$ polysync-core-dynamic-driver -n 1

In an “OK” state, this would be the last line the node prints:

2018-04-15 10:57:47.09s DEBUG  [video-device-1688894064433460] - transition to state: OK - timestamp: 1473994633468834

4. Visualize data using Studio

You are now able to start PolySync Studio in order to visualize the image data. Input the following:

$ polysync-core-studio

Open the video plugin from the button on the plugin loader on the right side of Studio. On the left-hand side of the window you can see the plugin’s control panel. The video device name can be selected from the control panel, and the live input can be seen from the node.

Connecting Cam 2

5. Visualize data outside of PolySync Core Studio

The image data viewer example binds the first image data publisher it finds.

$ cd image_data_viewer
$ make
$ ./bin/polysync-image-data-viewer

Conclusion

Congratulations! You have now successfully connected a webcam sensor.