Camera module issues

I just got the Spider Kit and have been having problems with the camera module similar to [url]http://www.tinyclr.com/forum/21/4322/[/url]

I’ve been following the Getting Started Guide [url]http://www.ghielectronics.com/downloads/Gadgeteer/Mainboard/Spider_GettingStarted/[/url].

When I run the program, the debug window will display “Camera ERROR : Unable to take picture. The camera is already busy taking a picture.” Occasionally the camera will work for 4-5 pictures then fail, but it often fails on first attempt, though these images are little more than a general blur.

Things I’ve tried:
Camera plugged into red power board - recognised OK by computer
Checked program.gadgeteer diagram
All other button/led modules work
Latest firmware installed (I think - I installed the Jan 6th SDK and updated firmware as part of that installation)

Has anyone any ideas?


public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
        }

        void camera_PictureCaptured(Camera sender, GT.Picture picture)
        {
            display.SimpleGraphics.DisplayImage(picture, 5, 5);
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            if (camera.CameraReady)
            {
                camera.TakePicture();
            }
            else
            {
                Debug.Print("Camera not ready");
                display.SimpleGraphics.Clear();
            } 
        }
    }

Thanks for any help.

The camera is focused manually. I had to adjust mine considerably to get a focused image the first time I used it.

Check to make sure the button pressed event is only firing once by setting a breakpoint. If the glitch filter is not set right, you may get several button press events firing so quickly that the camera is actually still busy transferring the image to the screen. There was a bug with the button module related to this, but I believe it was fixed in the latest SDK.

[quote]Check to make sure the button pressed event is only firing once by setting a breakpoint. If the glitch filter is not set right, you may get several button press events firing so quickly that the camera is actually still busy transferring the image to the screen. There was a bug with the button module related to this, but I believe it was fixed in the latest SDK.
[/quote]

Thanks for the suggestion, but it doesn’t seem to have helped. The button pressed event is only firing once (and seems pretty reliable in regards the issue you mentioned).

Hello Alex. Here is a new wiki page that explains how to troubleshoot the camera module. I hope it helps you:

[url]http://wiki.tinyclr.com/index.php?title=Gadgeteer_Camera[/url]

Hi,

I got exactly the same problem. I tried the troubleshootung guide from the wiki and this is the debug output:

any suggestions?

thanks in advance,
Daniel

Ok, in my case it seems to work better when I use a lower resolution:

[quote] camera.CameraConnected += new Camera.CameraConnectedEventHandler(camera_CameraConnected);
camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
camera.CurrentPictureResolution = new Camera.PictureResolution(176,144);[/quote]

Sometimes there are still errors, where the camera hangs after one of the first pictures but when I get past the first four or five pics it seems to work nice. Perhaps a timing problem?

That’s helped, it settled into a rhythm of successfully capturing every third shot. Are there users who can take ‘high’ resoultion pictures without issue, or is it a problem associated with the hardware system?

[quote]Camera reports that it is ready to take a picture. Attempting to take a picture
Camera was busy taking a picture. Number of times picture capture failed: 1
Camera was busy taking a picture. Number of times picture capture failed: 2
Picture successfully captured!
Picture encoding: 3
Attempting to print the picture to the display…
Picture sent to the display.
Camera reports that it is ready to take a picture. Attempting to take a picture
Camera was busy taking a picture. Number of times picture capture failed: 1
Camera was busy taking a picture. Number of times picture capture failed: 2
Picture successfully captured!
Picture encoding: 3
Attempting to print the picture to the display…
Picture sent to the display.
Camera reports that it is ready to take a picture. Attempting to take a picture
Camera was busy taking a picture. Number of times picture capture failed: 1
Camera was busy taking a picture. Number of times picture capture failed: 2
Picture successfully captured!
Picture encoding: 3
Attempting to print the picture to the display…
Picture sent to the display.
Camera reports that it is ready to take a picture. Attempting to take a picture
Camera was busy taking a picture. Number of times picture capture failed: 1
Camera was busy taking a picture. Number of times picture capture failed: 2
Picture successfully captured!
Picture encoding: 3
Attempting to print the picture to the display…
Picture sent to the display.
Camera reports that it is ready to take a picture. Attempting to take a picture
Camera was busy taking a picture. Number of times picture capture failed: 1
Camera was busy taking a picture. Number of times picture capture failed: 2[/quote]

Just a few days ago I got my Fez Spider kit. I ran through the process of updating the firmware, then built and ran the LED demo as described here: Getting Started with the .NET Gadgeteer - Part 1: Background, Setup, and Hello World - Pete Brown's 10rem.net

When I build and run the camera demo as instructed in the getting started guide:

http://www.ghielectronics.com/downloads/Gadgeteer/Mainboard/Spider/FEZSpider%20Starter%20Kit%20Guide.pdf

I get this message: “The camera is already busy taking a picture.”

As suggested I’ve gone to the camera troubleshooting page: GHI Electronics – Where Hardware Meets Software

When I build and run this application I get error messages. Now, I know the reason I can’t figure out these errors is because I’m a complete n00b in C# and visual studio, and yes, I’m going to apply myself to learning it, but it would be great to have the kit I just bought do stuff, so any help is very much appreciated.

Here are the error messages:

Error 1 The name ‘camera’ does not exist in the current context
several of those, and one of these:
Error 4 ‘camera_troubleshooting.Program’ does not contain a definition for ‘ProgramStarted’ and no extension method ‘ProgramStarted’ accepting a first argument of type ‘camera_troubleshooting.Program’ could be found (are you missing a using directive or an assembly reference?)

It seems it doesn’t like lines like these: camera.CameraConnected += new Camera.CameraConnectedEventHandler(camera_CameraConnected);

All this code was cut and pasted from the troubleshooting page.

What am I doing wrong?

@ User_8195 - did you setup the modules in the designer exactly as shown in the screenshot on the trouble shooting page?

I did my anal-retentive computer nerd best to everything exactly as shown. Not to say that I couldn’t have made a mistake…

What I just did was take the first comment in this thread and create a new project using the code in the message. This code works great - press the button and a photo appears on the screen. Perfect!

Someday I’ll look back on this and laugh, clown laugh, at my C# ignorance, but at this point I don’t have the slightest idea why this code works and the other code does not. Hopefully this will help someone else out there at least.

  • Steve

Here it is:

public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
// Use Debug.Print to show messages in Visual Studio’s “Output” window during debugging.
Debug.Print(“Program Started”);

        button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
        camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);
    }

    void camera_PictureCaptured(Camera sender, GT.Picture picture)
    {
        display.SimpleGraphics.DisplayImage(picture, 5, 5);
    }

    void button_ButtonPressed(Button sender, Button.ButtonState state)
    {
        if (camera.CameraReady)
        {
            camera.TakePicture();
        }
        else
        {
            Debug.Print("Camera not ready");
            display.SimpleGraphics.Clear();
        } 
    }
}

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

Steve, welcome to the Fez Gang ! Oh and the Forums :wink:

What I suspect you did differently in the two situations was connect a camera in the Gadgeteer designer. If you don’t do that, there’s no object named “camera” won’t exist - and yep, that’s something you’ll get used to in C#, the “scope” of objects.

How many frames per second can this camera capture at lowest resolution?
When you say the camera is manual focus, do you have to manually change the focus if you want to focus on something at different distances?

Thanks,
Roger Larsen

Don’t know about the FPS, but yes, you have to manually change the focus by screwing the lens in (or out) if you want to take a picture of something more (or less) distant.

I think it was 20 or 30 at low res

Nice, and you have access to the raw bitmap data, or is it compressed? (unlock bits like you do in regular .net?)

I’m using the video expr. shield now and transferring the data over uart to my fez panda II to do hough transforms. I can max do 3-4fps over UART. Picking up the arduino I again I was quickly reminded of how much I dislike that platform. 2K SRAM, no debugging++… Anyways, I’m looking to just do the whole thing in .net mf I can capture the raw bits from the camera.

I need atleast 3fps performance for object tracking.

Not sure what you mean

display.SimpleGraphics.DisplayImage(picture, 0, 0);
Where picture is a GT.picture. Is that a compressed image or a raw stream of 8bpp image or simlar?

Thanks

It is raw 16BPP