Discussion Board

Results 1 to 13 of 13

Threaded View

  1. #1
    Registered User
    Join Date
    May 2009

    Exclamation PhotoCamera.CaptureImage() fails with front facing camera on Lumia820

    Hello everybody.

    I am pretty new to the WP platform, and am currently researching some of the APIs I will need for my next application.

    Using the article called "How to create a base camera app for Windows Phone" as a starting point, I wrote a very simple application that is supposed to capture a single picture using the front facing camera, which works as expected on the emulator, but fails when I run it on a physical device. However, it runs fine on the device if I use the back camera.

    The problem I am experiencing is that after calling the CaptureImage() method on the PhotoCamera object, the CaptureStarted event fires as expected, but after that, the application hangs and no other event is fired (i.e. the capture never completes).

    If I stop the application and start it again, I get a System.InvalidOperationException when calling the CaptureImage() method (with the following exception message: "You cannot use this instance until it is fully initialized"). At this point the only way to get the PhotoCamera object to initialize correctly is restarting the device.

    The code is very simple, but I'm including it here so anyone can take a look at it (relevant portions only):

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
                Debugger.Log(1, "Info", "\nOnNavigatedTo Event fired\n");
                        cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
                        cam.Initialized += new EventHandler<Microsoft.Devices.CameraOperationCompletedEventArgs>(cam_Initialized);
                        cam.CaptureStarted += new EventHandler(cam_CaptureStarted);
                        cam.CaptureCompleted += new EventHandler<CameraOperationCompletedEventArgs>(cam_CaptureCompleted);
                        cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
                        cam.CaptureThumbnailAvailable += new EventHandler<ContentReadyEventArgs>(cam_CaptureThumbnailAvailable);
                        Debugger.Log(1, "Info", "\nSource set\n");
                    catch (Exception excep)
                        Debugger.Log(1, "Info", "\nException in OnNavigatedTo: " + excep.Message + "\n");
            private void ShutterButton_Click(object sender, RoutedEventArgs e)
                    Debugger.Log(1, "Info", "CaptureImage method called\n");
                catch (Exception ex)
                    Debugger.Log(1, "Info", "CaptureImage exception: " + ex.Message + "\n");
            void cam_Initialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
                if (e.Succeeded)
                        Debugger.Log(1, "Info", "Camera initialized\n");
                    Debugger.Log(1, "Info", "\nFailed to initialize. Message: " + e.Exception.Message + ":** " + e.Exception.StackTrace + "\n");
            void cam_CaptureStarted(object sender, EventArgs e)
                Debugger.Log(1, "Info", "CaptureStarted event fired\n");
    The other event handlers only include debug messages, so I did not include them here.

    When I run the application on the emulator (or on the device, but using the back camera), I get the following debug messages sequence, as expected:

    OnNavigatedTo Event fired
    Source set
    Camera initialized
    CaptureImage method called
    CaptureStarted event fired
    CaptureThumbnailAvailable event fired
    CaptureImageAvailable event fired
    CaptureCompleted event fired

    But when I run it on the device (front camera), I just get these (and then the App hangs):

    OnNavigatedTo Event fired
    Source set
    Camera initialized
    CaptureImage method called
    CaptureStarted event fired

    So, my questions would be:

    1. Am I doing something wrong, or missing something? (if so, why the App runs without issues on the emulator, or when using the back camera on the device?)
    2. Is there something additional I can do to debug the issue? (I don't seem to find any additional way to debug the problem at a lower level)
    3. Has someone else experimented this problem? If so, how did you solved it or worked around it?

    Also, it would be really nice if someone else could try this operation on another 820 developer device. I'm starting to think that this is some kind of device-specific issue, maybe related to the firmware or something similar.

    UPDATE - 13/02/2013

    I modified the application to use the PhotoCaptureDevice class instead of PhotoCamera, as described in article "Advanced photo capture for Windows Phone 8", but the results are basically the same. After I call the capture sequence's StartCaptureAsync() method, the application hangs. As before, it only happens on the device when the front facing camera is being used.

    UPDATE - 14/02/2013

    I tried the same code on a Lumia 920 (through RDA) and it works without any issues, so this is probably not a flaw in the code, as I suspected. If anyone has the time, please test it on a 820 dev device.

    I'm not sure if this is somehow related, but I tested the Microsoft's BLINK App a few days ago, and when I switch to the front facing camera in that App, my phone restarts. I asked a few friends about this on twitter , and one of them told me that she saw a similar behaviour on a 825 device.

    I'm using a Lumia 820 developer device (OS versión: 8.0.9903.10. firmware revisión: 1232.2110.1244.3002).

    If any additional details are needed, just let me know.

    Thanks for your time, and for any answers, comments or suggestions you can provide.
    Last edited by cadlg; 2013-02-14 at 07:05. Reason: Additional options tried

Similar Threads

  1. Camera captureImage crash (Symbian)
    By pixsta in forum [Archived] Qt Quick
    Replies: 2
    Last Post: 2012-04-06, 12:57
  2. Using front camera with camera wrapper
    By juannoguera in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2010-08-25, 13:31
  3. Change Camera::CaptureImage() Resolution
    By neelesh_a1 in forum Symbian
    Replies: 2
    Last Post: 2010-01-27, 21:20
  4. How to use Front Camera
    By kartikbansal in forum Mobile Java Media (Graphics & Sounds)
    Replies: 15
    Last Post: 2008-12-10, 10:01
  5. Replies: 3
    Last Post: 2008-05-05, 16:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts