A question about using the Camera

EDIT with additional information that I forgot to mention in my original post.

Neither method works after using ‘camera.TakePicture()’. Take picture or streaming give exceptions.
Yes! it could be my code but I ‘think’ (could very well be wrong) that the spider I/O cannot communicate with the camera?

I worked around this just using streaming to capture a single picture bitmap to save to file but I ‘think’ I should be able to use either OR both methods.
Sure would like to know why. I’ll leave it at that.

Ya’ all have a GREAT day!

As a note my camera shows version 1.1. My question relates to coding for it.

I have no issues getting images from it.

I have two uses for the camera in my code.

  1. Buttons to start/stop/save image for streaming.
  2. Buttons for Takepicture/save fo snapshot.

Each (1 and 2) works on its own without any problems. I can receive images and can display/save the bitmaps to file.

My problem is whenever I use camera.TakePicture(); I then can no longer stream the camera.

Exception received is:

Exception System.Exception - 0xffffffff (1)

#### Message: 
#### GHIElectronics.NETMF.USBHost.USBH_Webcam::StartStreaming_Internal [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_Webcam::StartStreaming [IP: 0005] ####
#### Gadgeteer.Modules.GHIElectronics.Camera::StartStreamingBitmaps [IP: 007e] ####
#### GadgeteerSpiderServer.Program::StreamOn [IP: 0057] ####
#### GadgeteerSpiderServer.Program::processSpecial [IP: 010e] ####
#### GadgeteerSpiderServer.Program::TestBuffer [IP: 010a] ####
#### GadgeteerSpiderServer.Program::XBeeSerial_LineReceived [IP: 002c] ####
#### Gadgeteer.Interfaces.Serial::OnLineReceivedEvent [IP: 0037] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001c] ####
#### GadgeteerSpiderServer.Program::Main [IP: 001a] ####

A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
Error invoking method “Gadgeteer.Interfaces.Serial” (check arguments to Program.BeginInvoke are correct)

This Information, in my mind, tells me nothing! I assume it is related to the USBHost?

The streaming method returns and I never receive the GTM.GHIElectronics.Camera.BitmapStreamedEventHandler(camera_BitmapStreamed); event.


//Partial code

       //Camera events
            cameraSocket4.PictureCaptured +=
                new Camera.PictureCapturedEventHandler(camera_PictureCaptured);

            cameraSocket4.BitmapStreamed += 
                new GTM.GHIElectronics.Camera.BitmapStreamedEventHandler(camera_BitmapStreamed);

        Bitmap PicBitmap;
        byte[] cambytes;
        Image imgCamera;

        //The picture returned in PictureCaptured is a valid .BMP file.
        void camera_PictureCaptured(Camera sender, GT.Picture picture)
        {
            //Save GT.Picture picture for saving this picture data to SDCard
            pictureSnapped = picture;

            //Display the picture on canvasData
            imgCamera = new Image();
            imgCamera.Bitmap = picture.MakeBitmap();
            canvasData.Children.Clear();
            canvasData.Children.Add(imgCamera);
            Canvas.SetLeft(imgCamera, 0);
            Canvas.SetTop(imgCamera, 0);
            lcdData.Visibility = Visibility.Visible;
            lcdWiFly.Visibility = Visibility.Hidden;
        }
        //
        private void camera_BitmapStreamed(Camera sender, Bitmap bitmap)
        {
            PicBitmap = bitmap;
            imgCamera = new Image();
            imgCamera.Bitmap = bitmap;
            canvasData.Children.Clear();
            canvasData.Children.Add(imgCamera);
            Canvas.SetLeft(imgCamera, 0);
            Canvas.SetTop(imgCamera, 0);
            lcdData.Visibility = Visibility.Visible;
            lcdWiFly.Visibility = Visibility.Hidden;
        }
        //
        private void StreamOn()
        {
            //Create new event -- [b]Added to the original code to see if a new event would help[/b]
            cameraSocket4.BitmapStreamed +=
                new GTM.GHIElectronics.Camera.BitmapStreamedEventHandler(camera_BitmapStreamed);

            cameraSocket4.RestartStreamingTrigger = 1500; 

            //Start streaming and tell PC
            XBeeSerial.Write(XB + "Camera streaming on~");
            Thread.Sleep(500);
            cameraSocket4.StartStreamingBitmaps(new 
                Bitmap(cameraSocket4.CurrentPictureResolution.Width,
                cameraSocket4.CurrentPictureResolution.Height));
        }
        //

        private void StreamOff()
        {
            //Stop streaming and tell PC
            XBeeSerial.Write(XB + "Camera streaming off~");
            cameraSocket4.StopStreamingBitmaps();
        }
        //
        private void TakeSnapShot()
        {
            cameraSocket4.StopStreamingBitmaps();
            cameraSocket4.TakePicture();
        }
        //


Is there any way to ‘reset’ the camera after using the cameraSocket4.TakePicture(); method?

Any ideas?

Thanks!