I have now a fully functional EMX Dev System with an Wifi module working and a couple of motors plus wheels for my personal robot project.
The final piece is the Camera that I would like to mount on the Robot. I have came across several Posts mentioning a GHI USB camera for my EMX system. The links for that camera no longer exist.
Can anyone help me to find a suitable camera for my Project.
I am running GHI SDK 4.1 and NETMF 4.1. I cannot upgrade to the lastest 4.2 because my WiFi module apparently does no work with that version.
So, basically I can use a normal USB Camera and use the code below from the SDK 4.1 Documentation to instrument the camera?
GUS, the gadgeteer camera should work with the same code from SDK 4.1? That camera is much smaller than the ones I have.
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using GHIElectronics.NETMF.USBHost;
using GHIElectronics.NETMF.System;
class Program
{
static Bitmap LCD = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
static USBH_Webcam cam;
static USBH_Webcam.ImageFormat usedFormat;
static Thread videoThread;
public static void Main()
{
// Subscribe to USBH events.
USBHostController.DeviceConnectedEvent += USBHostController_DeviceConnectedEvent;
Thread.Sleep(Timeout.Infinite);
}
static void USBHostController_DeviceConnectedEvent(USBH_Device device)
{
if (device.TYPE == USBH_DeviceType.Webcamera && cam == null)
{
cam = new USBH_Webcam(device);
cam.Disconnected += cam_Disconnected;
// get supported formats
USBH_Webcam.ImageFormat[] formats = cam.GetSupportedFormats();
// use the first format
if (formats.Length > 0)
{
usedFormat = formats[0];
// run a thread to display the video
videoThread = new Thread(VideoThread);
videoThread.Start();
}
}
}
public static void VideoThread()
{
try
{
cam.StartStreaming(usedFormat);
LCD.Clear();
while (true)
{
// is there a new image?
if (cam.IsNewImageReady())
{
// center the image
cam.DrawImage(LCD, (LCD.Width - cam.CurrentFormat.Width) / 2, (LCD.Height - cam.CurrentFormat.Height) / 2, cam.CurrentFormat.Width, cam.CurrentFormat.Height);
LCD.Flush();
}
}
}
catch (Exception e)
{
Debug.Print("Exception: " + e.Message);
}
}
static void cam_Disconnected(USBH_Webcam sender, USBH_WebcamEventArgs args)
{
videoThread.Abort();
cam.StopStreaming();
cam = null;
}
}