Windows CE .NET Webcam, Part 1

xiaoxiao2021-03-06  14

Windows CE .NET Webcam, Part 1

Mike HallMicrosoft Corporation

Steve MailsetElechy Consulting

August 6, 2002

Good to CE (see) you back again this month We've taken a look at the hardware needed to build a CEPC reference device;. Now it's time to build a project using Microsoft® Windows® CE .NET So over the next couple. of months, we will build a WebCam device using Windows CE .NET and the CEPC reference platform This project will be divided into two steps:. This month we will start by configuring the platform, adding the core components, and testing the configuration using the Windows CE .NET Emulation Environment. Next Month We Will Follow this up with the final step. ...................

For this Month's Project, We'll Need The Following Items:

Windows CE .NET 4.1. Windows XP Professional, (The Host Operating System). A Suitable USB Web Camera (I'M Using A Logitech® QuickCam® Express). Windows XP Timershot PowerToy.

Let's get started with an overview of the project We're going to build a WebCam project, using the Windows CE HTTPD server to serve up Web pages that show the output from the connected Web camera This raises some interesting questions..:

We're building for emulation, so how will the HTTPD server serve up the images? How will we get the images from the Windows XP Pro Web camera into the emulation environment? Can external clients view the Web pages?

THESE ALE EXCELLENT Questions, AND WILL All Be Addressed As We Work THROUGH The Project. There Are A Number of Steps To Complete this Project, As Follows:

Configure the platform;... Using Platform Wizard, edit the registry and .DAT files, and create the application, which will copy our Web images Build the platform Configure the Windows CE .NET emulator Configure Timershot to deliver its captured images to the _FLATRELEASEDIR (our current Windows CE .NET Project build folder) Boot the image Optional use of a driver and / or DMA Driver to get images from the Windows XP Web camera (a DMA driver provides a driver interface to applications running in the emulator..; the data is spooled from an application or driver running on the desktop) .Let's start with configuring the platform. We will use the Windows CE .NET Platform Wizard to configure our platform. The Platform Wizard is used to create the base project, and allows us to select a number of components, including the Board Support Package (BSP), which in this case will be the emulator, and the platform configuration. There are a number of configurations to choose from, including cell phone, digital imaging device, Internet appliance (this is the option we will choose for the Web camera platform), residential gateway, thin client, and so on-this is simply a starting point for our project. We can add or remove components from the catalog To Customize The Platform for Our Needs.

Figure 1. Selecting the Platform Configuration

The Platform Wizard will provide a number of options based on the configuration we've chosen. Here we've selected the Internet Appliance configuration, so the wizard will provide the appropriate options. In this case, this includes the option to include the standard shell , Microsoft® Internet Explorer 5.5 (useful in an Internet appliance), Windows Media Player-or, alternatively, an Internet appliance that contains all of the previously mentioned features, WordPad, and Inbox applications.Figure 2. Selecting Internet Appliance options

Step 5 of the wizard provides all the applications and media options. This includes Internet Browser, Microsoft® Instant Messenger, Windows Media (audio and video), the Microsoft® .NET Compact Framework Beta, and Standard SDK. We only require the Internet Explorer Option for Our Device, So We can remove the checks from the Other Options.

STEP 6 of the Wizard Provides The Networking and Communication Options for Our Platform, Which is Divided Into Tho Three Distinct Sections:

PAN, Or Personal-Area Networking (Bluetooth, Irda). LAN, or LOCAL-Area Networking (WAN, or Wide-Area Networking (Dial-Up Networking and PPPOE Point-To-Point over Ethernet ).

Since We Don't Require Bluetooth for Our Platform, this Can Be Disabled (Note That We Could) Configuration.)

We're done! The core platform is now configured. We will need to include a number of additional components from the catalog, and we will need to further customize the platform with an application by adding some additional files (more on this later). We could build and test the operating system image right now without further customization and the image would boot and run. Note that by default, we're building a release image of the operating system. We could easily swap to a debug image. Take a Look at the build-Toolbar Below.figure 3. Selecting debug or release-build Options

Let's take a second to examine what's happened so far. We've used the Platform Wizard to create a new platform called GetEmbedded, based on the Internet Appliance platform configuration. We've included support for the Internet Explorer application. We can build this image for debug or release (release generates a smaller image), and debug and release images will each be stored in their own folders-in this case in the folders, C: / Wince410 / public / GetEmbedded / RelDir and EMULATOR_X86Debug or EMULATOR_X86Release.

It's now time to customize the platform by adding support for the HTTPD server (Web server), and an application to drop the captured WebCam image to the appropriate place. First we need to understand how we get the image from the Windows XP Professional USB WebCam INTO The Emulation Environment.

There are two parts to this, the first being a great Windows XP PowerToy called Timershot. This can be downloaded from Microsoft PowerToys for Windows XP. The Timershot application captures images from your connected imaging device (in my case the USB Logitech® QuickCam® Express WebCam), and stores the image in a designated folder.We can configure Timershot to save its captured images into the Platform Builder build output folder (known as the _FLATRELEASEDIR). Within Platform Builder, click Build → Open Build Release Directory. This is the build folder, or flat release directory for the Get Embedded project. (C: / wince410 / public / GetEmbedded / Reldir / EMULATOR_X86Release) We configure Timershot to deliver its image (MyPic.JPG) into the flat release folder.

Here's how the Timershot application looks with the appropriate settings enabled (the camera is pointing at a Windows CE .NET product box) Be sure to disable the "Save a new copy of this file every time a picture is taken" option;. Otherwise, Timershot Will Rename The Output File for Each Image.

Figure 4. The Windows XP Timershot PowerToy

So, we have the image in the build release folder-what now? Do we need to rebuild our operating system image in order to have it available to the HTTPD server? No. Here's one of the great features of Windows CE .NET. At boot time the operating system loads a Relfsd driver (RELease File System Driver). This links the current running operating system image to the _FLATRELEASEDIR for the current running project. This means that you can drop any file into the _FLATRELEASEDIR and have the current running Windows CE operating system image pick up the file and do something useful with it. The _FLATRELEASEDIR appears as "/ Release" within the Windows CE file system. In our case, we are dropping an image from the Web camera into the / Release folder, which Can death. Here's. Here's The Emulator Folder, "/ release"

Now we need to customize the Windows CE .NET project We will start by adding the HTTPD Web server, which can be located in the following Platform Builder catalog location:. Catalog → Display-Based Devices → Communication Services and Networking → Servers → Web Server (Httpd).

The device will register itself on the network using the default device name of "WindowsCE." We can easily modify the default device name by modifying the registry. There are a number of views for our project within Platform Builder, the default being FeatureView. This displays the components, or features, contained within our platform, including any applications or user features we've added to the platform using the Application Wizard (File → New Project or File). Another view of the platform is ParameterView. This contains the hardware -Specific and Project-Specific Bib, DAT, DB, AND REG FILES (See Below). The File Project.Reg Contains The Project-Specific Registry.figure 6. The Parameter View

Changing the machine name and description is as simple as adding the following registry key to the end of the Project.Reg file and rebuilding our platform In this case our device would appear on the network as. . We can Of Course Also Get To The Device Using ITS IP Address, . We'll See How To Figure. We'll See How To Figure.

[HKEY_LOCAL_MACHINE / IDENT]

"Name" = "getmbed"

"Desc" = "Webcam Device"

The default Web server page (/windows/www/wwwpub/default.htm) simply informs you that the Web server is running. We need to replace this with our custom HTML page. We will also want our page to refresh every few seconds so That Our Internet Browser Always shows an up-to-date image.

Here's The HTML Page. I'm Using A One-Second Timeout on The Page, and The Image Name IMAGE.JPG, SO WHEN We Copy Our Timershot Image from The / Release Folder (Called MyPic.jpg) Rename The File to Image.jpg. (We Could, Of Course, Get Timershot To Output A File Called Image.jpg; In this case we'd simply need to copy the file to the wwwpub folder.) for the purposes of this article We will call the html page "frame.html."