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();
}
}
}
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).
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]
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.
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();
}
}
}
Steve, welcome to the Fez Gang ! Oh and the Forums
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?
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.
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.