USB Camera handler (ucam://)

What is the USB Camera handler

TQLEngine provides a protocol handler wrapper to interact with USB Camera. USB Camera are handy actuators for home monitoring, taking one off pictures etc.


  • High frame rate MJPEG 60 fps @ 1280 (H) x 720 (V) , 30 fps @ 1920 (H) x 1080 (V)
  • CMOS 1080P sensor for high quality image and low power consumption
  • high pixel technology for sharp image and accurate color reproduction
  • low light performance - ideal for any lighting condition
  • UVC for use in Linux, Windows XP, WIN CE, MAC, SP2 or above

USB Camera Parameters

Parameter NameDescription
USBCameraParameters.ImageFormat
Specify image format. Example: jpeg
USBCameraParameters.SaveToDisk
Do you want the image file to be saved to disk?. Value is either true or false
USBCameraParameters.ImageName
Specify the file name to be used when saving to the disk. The file gets saved in the current folder in which TQLEngine is running
USBCameraParameters.Size.Height
Image height. An integer value
USBCameraParameters.Size.Width
Image width. An integer value. 
USBCameraParameters.Configuration.StandardStandard value of image
USBCameraParameters.Configuration.QualityQuality of image
USBCameraParameters.Configuration.ChannelThe acquisition channel. Default is 0
USBCameraParameters.Configuration.Brightness

Brightness of video image (0-255)

USBCameraParameters.Configuration.Contrast

Contrast of image (0-255).

USBCameraParameters.Configuration.GammaGamma of image
USBCameraParameters.Configuration.GainGain of image
USBCameraParameters.Configuration.SharpnessSharpness of image (0-255).
USBCameraParameters.Configuration.SaturationSaturation of image (0-255).
USBCameraParameters.Configuration.HueHue of image

USB Camera Parameter Structure

USB Camera Parameter Structure
<USBCameraParameters>
  <ImageFormat></ImageFormat>
  <SaveToDisk></SaveToDisk>
  <ImageName></ImageName>
  <Size>
    <Height></Height>
    <Width></Width>
  </Size>
  <Configuration>
    <Standard></Standard>
    <Quality></Quality>
    <Channel></Channel>
    <Brightness></Brightness>
    <Contrast></Contrast>
    <Gamma></Gamma>
    <Gain></Gain>
    <Sharpness></Sharpness>
    <Saturation></Saturation>
    <Hue></Hue>
  </Configuration>
</USBCameraParameters>

Invoking UCAM Handler

Invoking UCAM Handler via Invoke
<Action Name="USBCameraImageAction">
  <Workflow Limit="1" Live="1" Timeout="-1">
    <Task name="Main" while="true">
      <Event name="Argument" as="ActionArgument"/>
      <Invoke name="GetImage" waitFor="ActionArgument" post="ucam://">
        <Message>
          <Value>
            <USBCameraParameters>
              <ImageFormat>[%:Event.Argument.USBCameraParameters.ImageFormat.Value:%]</ImageFormat>
              <SaveToDisk>[%:Event.Argument.USBCameraParameters.SaveToDisk.Value:%]</SaveToDisk>
              <ImageName>[%:Event.Argument.USBCameraParameters.ImageName.Value:%]</ImageName>
              <Size>
                <Height>[%:Event.Argument.USBCameraParameters.Size.Height.Value:%]</Height>
                <Width>[%:Event.Argument.USBCameraParameters.Size.Width.Value:%]</Width>
              </Size>
              <Configuration>
                <Standard>[%:Event.Argument.USBCameraParameters.Configuration.Standard.Value:%]</Standard>
                <Quality>[%:Event.Argument.USBCameraParameters.Configuration.Quality.Value:%]</Quality>
                <Channel>[%:Event.Argument.USBCameraParameters.Configuration.Channel.Value:%]</Channel>
                <Brightness>[%:Event.Argument.USBCameraParameters.Configuration.Brightness.Value:%]</Brightness>
                <Contrast>[%:Event.Argument.USBCameraParameters.Configuration.Contrast.Value:%]</Contrast>
                <Gamma>[%:Event.Argument.USBCameraParameters.Configuration.Gamma.Value:%]</Gamma>
                <Gain>[%:Event.Argument.USBCameraParameters.Configuration.Gain.Value:%]</Gain>
                <Sharpness>[%:Event.Argument.USBCameraParameters.Configuration.Sharpness.Value:%]</Sharpness>
                <Saturation>[%:Event.Argument.USBCameraParameters.Configuration.Saturation.Value:%]</Saturation>
                <Hue>[%:Event.Argument.USBCameraParameters.Configuration.Hue.Value:%]</Hue>
              </Configuration>
            </USBCameraParameters>
          </Value>
        </Message>
      </Invoke>
      <Log Message="******Invoked USBCamera******"/>
      <Output name="Result" as="ActionResult">
        <Value>
          <Image>[%:[%:@Output:%]Invoke.GetImage.Message.Value:%]</Image>
        </Value>
      </Output>
    </Task>
  </Workflow>
</Action>

Driver Installation Steps

For the ucam handler to work two things are needed, the video driver of the camera which comes by default and some prerequisite libraries which are shown below. 

  • libjpeg8-dev
  • libv4l-dev

If you are running debian based operating system use the following commands

 sudo apt-get install  libjpeg8-dev

 sudo apt-get install libv4l-dev 

Refer to TQL CLI Protocol Install  section for installation of USB Camera driver.