Blog Stats
  • Posts - 95
  • Articles - 0
  • Comments - 19
  • Trackbacks - 0

 

Camera Detection

So, got the Motorola MC75 working with its inbuilt camera.   However during a demo the other day I inadvertently clicked my camera capture button on a device that doesn't have an inbuilt camera (doh).

Of course my application then blew up.

So here's the code that performs a camera capture but also detects (well catches) if the device doesn't have one...

 

try

            {

CameraCaptureDialog ccd = new CameraCaptureDialog();

                ccd.InitialDirectory = @"\";

                ccd.DefaultFileName = "test.jpg";

                ccd.Mode = CameraCaptureMode.Still;

                ccd.Resolution = new Size(640, 480);

DialogResult dr1 = ccd.ShowDialog();

if (dr1 == DialogResult.OK)

                {

                    Bitmap _Photo = new Bitmap(ccd.FileName);

// put your code in here todo something with the image

                }

                ccd.Dispose();

            }

catch

            {

MessageBox.Show("No Camera Attached", "No Camera", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

            }


Feedback

No comments posted yet.


Post a comment





 

 

 

 

Copyright © Richard Jones