Export (0) Print
Expand All

Simulated Webcam

Microsoft Robotics

Glossary Item Box

Microsoft Robotics Developer StudioSend feedback on this topic

Simulated Webcam

The SimulatedWebcam service demonstrates how to simulate a webcam using the simulation engine's CameraEntity.

This sample is provided in the C# language. You can find the project files for this sample at the following location under the Microsoft Robotics Developer Studio installation folder:

Sample location
Samples\Simulation\Sensors\SimulatedWebcam

Contents:

Prerequisites

Hardware

This service requires no special hardware apart from a suitable graphics card to run the Simulator.

Software

This software is designed to run with Microsoft Robotics Developer Studio.

Setting Up the Service

The SimulatedWebcam service is installed automatically with RDS. The sample that shows usage of the SimulatedWebcam service is the simulation tutorial Simple Robot with Drive.

The simulated webcam implements the Generic Web Camera service contract so that it can be used by other services.

Running the Service

There are two different methods to start the SimulatedWebcam service. Either:

  • Start the service by adding the service to a manifest either through DSS Manifest Editor (DSSME) or manually with any text editor. The below XML shows how the SimulatedWebcam service should appear in the manifest.
    XML
    <?xml version="1.0"?>
    <Manifest 
        xmlns:simulation="http://schemas.microsoft.com/robotics/2006/04/simulation.html" 
        xmlns:simulatedwebcam="http://schemas.microsoft.com/2006/09/simulatedwebcam.html" 
        xmlns:this="urn:uuid:9adb2c6b-48c8-45ac-a0f7-3f4cc2d4ebd0" 
        xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html" 
        xmlns="http://schemas.microsoft.com/xw/2004/10/manifest.html">
      <CreateServiceList>
        <!--Any other services you want to start could be here-->
        <ServiceRecordType>
          <dssp:Contract>http://schemas.microsoft.com/2006/09/simulatedwebcam.html</dssp:Contract>
          <dssp:PartnerList>
            <dssp:Partner>
              <dssp:Service>http://localhost/CameraEntityName</dssp:Service>
              <dssp:PartnerList />
              <dssp:Name>simulation:Entity</dssp:Name>
            </dssp:Partner>
          </dssp:PartnerList>
          <Name>this:SimulatedWebcam</Name>
        </ServiceRecordType>
      </CreateServiceList>
    </Manifest>
  • Start the service programatically in code that generates a simulation environment:
    C#
    Microsoft.Robotics.Services.Simulation.Sensors.SimulatedWebcam.Proxy.Contract.CreateService(
      ConstructorPort, "http://localhost/" + cameraEntity.State.Name,
      Microsoft.Robotics.Simulation.Partners.CreateEntityPartner(
          "http://localhost/" + cameraEntity.State.Name)
    );

Using the Service

To retrieve an up to date copy of the webcam's image, post a QueryFrameRequest and receive a QueryFrameResponse. You can do this either programatically or through VPL.

Summary

This sample covered the following:

 

 

© 2012 Microsoft Corporation. All Rights Reserved.

Show:
© 2014 Microsoft