|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| [[Category: Primer]] | | [[Category: Primer]] |
|
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
|
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
|
| |
| ----
| |
|
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
| <tabber>
| |
| C#=
| |
| <div class="source">
| |
| <syntaxhighlight lang=csharp>
| |
| using Phidgets;
| |
| using Phidgets.Events;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| Java=
| |
| <div class="source">
| |
| <syntaxhighlight lang=java>
| |
| import com.phidgets.*;
| |
| import com.phidgets.event.*;
| |
| </syntaxhighlight>
| |
| </div>
| |
| |-|
| |
| VB.Net=
| |
| <div class="source">
| |
| <syntaxhighlight lang=vbnet>
| |
| Public Class Form1
| |
| 'The Phidget object declaration
| |
|
| |
| Dim WithEvents ifKit As Phidgets.InterfaceKit
| |
|
| |
| '... Form1_Load and Form1_OnClosing here
| |
| End Class
| |
| </syntaxhighlight>
| |
| </div>
| |
| </tabber>
| |
|
| |
|
| {| | | {| |
Introduction
Webcams come in many forms, but the USB ones usually come as UVC (USB Video Class) devices. This primer gives a very brief overview of what they are and how to use them.
Advantages
The advantage of UVC devices is their cross-platform compatibility, especially within the various flavours of Linux.
- Wikpedia gives a good overview of their levels of compatibility
- Many devices other than the Phidget webcam use the same protocol, please refer to a compatibility list
Use
A UVC device should be truly plug and play. Even on the Phidget Single Board Computer, the drivers are already installed. You can almost immediately begin using video capture programs on your operating system to record video or pictures.
Examples include:
- Capture from Windows media players and creators
- Use iMovie on Mac OS X
- Use Cheese on Linux (
sudo apt-get install cheese
)
However, these programs are usually graphical programs which don't help if you want to use the webcam in code.
Code
Regardless of your platform, a good place to start is OpenCV. It is a library for C/C++ that focuses solely on processing images and video. It also has bindings to other languages like Python.
We also offer a programming example in C# to use the webcam:
Additional advice by operating system is below.
Phidget SBC
Any UVC webcam device should work interchangeably with any other UVC webcam device, So you don't have to use the Phidget one, you can find one that fits your needs.
On our Single Board Computer (SBC) page, we give an example of how to use a UVC webcam to take pictures using the SBC and OpenCV in code:
Windows
On Windows, OpenCV is your best bet.
Linux
On full Linux systems, you can possibly use OpenCV, though there have been some problems on standard Ubuntu distributions.
Alternatively, you can use the program streamer
which can then be used in code:
sudo apt-get install streamer
streamer -c /dev/video0 -b 16 -o output.jpg
Did You Know
The UVC standard outlines more than just picture taking - it can control pan, tilt, resolution, etc depending on the functionality for your camera. This is how the Phidget SBC controls what resolution is displayed on its Web Interface.
If you want to play with these advanced features, and you own an SBC, you can look at the scripts in /var/www/
on the SBC.