Forums - Startpreview failed error on Nexus -S

2 posts / 0 new
Last post
Startpreview failed error on Nexus -S
rahul.budhiraja
Join Date: 4 Sep 10
Location: Singapore
Posts: 1
Posted: Wed, 2011-11-02 01:12

Hi,

I followed the installation instructions and was able to compile successfully.When I tested the app on my Nexus-S ,the home screen ,settings and about screens are shown fine,but when I press the Start button it gives a "process com.qualcomm.fastcorner has stopped unexpectedly error" .

The Logcat output is :

 

11-02 05:59:23.062: ERROR/AndroidRuntime(668): FATAL EXCEPTION: main
11-02 05:59:23.062: ERROR/AndroidRuntime(668): java.lang.RuntimeException: Unable to resume activity {com.qualcomm.fastcorner/com.qualcomm.fastcorner.FastCVSample}: java.lang.RuntimeException: startPreview failed
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2120)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.os.Looper.loop(Looper.java:123)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at java.lang.reflect.Method.invokeNative(Native Method)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at java.lang.reflect.Method.invoke(Method.java:507)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at dalvik.system.NativeStart.main(Native Method)
11-02 05:59:23.062: ERROR/AndroidRuntime(668): Caused by: java.lang.RuntimeException: startPreview failed
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.hardware.Camera.startPreview(Native Method)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at com.qualcomm.fastcorner.FastCVSample.startPreview(FastCVSample.java:524)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at com.qualcomm.fastcorner.FastCVSample.onResume(FastCVSample.java:323)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.Activity.performResume(Activity.java:3832)
11-02 05:59:23.062: ERROR/AndroidRuntime(668):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2110)

So it gives a start preview error.I checked my default Camera app and it shows a "cannot connect to Camera error" .I thought that it was probably something wrong with my phone so I restarted the OS and checked if the phone's camera was working correctly,and it was ok.When I restarted the OS,the camera works fine but when I run the FastCV Sample App ,the app crashes and I cannot use other apps which make use of the camera.I have treid checking,unchecking the USB development option as well.

Is there any solution to this?Has anyone tried FastCV on the nexus s .

Hope that somebody can help me out.

Cheers,

Rahul

  • Up0
  • Down0
Eduardo_Zubillaga
Join Date: 31 Oct 11
Posts: 4
Posted: Fri, 2011-11-11 08:25

Hi Rahul,

I have the same problem. Trying to solve it, I have added some code to the setUpCamera method of FastCVSample Java class:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

private void setupCamera() {
  final Camera.Parameters parameters = mCamera.getParameters();
  /**************************** ADDED CODE **********************************/
  List<Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes();
  Size previewSize = supportedPreviewSizes.get(0);
  int width = previewSize.width;
  int heigth = previewSize.height;
  int w_diff = Math.abs(mDesiredWidth - width);
  int h_diff = Math.abs(mDesiredHeight - heigth);
  double diff = Math.pow(Math.pow(w_diff, 2) + Math.pow(h_diff, 2), 0.5);
  Size aux = null;
  for (int i = 1; i < supportedPreviewSizes.size()-1; i++) {
    aux = supportedPreviewSizes.get(i);
    int width_aux = aux.width;
    int height_aux = aux.height;
    int w_diff_aux = Math.abs(mDesiredWidth - width_aux);
    int h_diff_aux = Math.abs(mDesiredHeight - height_aux);
    double diff_aux = Math.pow(Math.pow(w_diff_aux, 2) + Math.pow(h_diff_aux, 2), 0.5);
    if (diff_aux < diff) { previewSize = aux; }
  }
  /******************************************************************************/
  parameters.setPreviewFrameRate( 30 );
  //  parameters.setPreviewSize( mDesiredWidth, mDesiredHeight );
  parameters.setPreviewSize( previewSize.width, previewSize.height );
  parameters.setFocusMode( Camera.Parameters.FOCUS_MODE_INFINITY );
  parameters.setWhiteBalance( Camera.Parameters.WHITE_BALANCE_FLUORESCENT );
  mCamera.setParameters( parameters );
  mPreviewWidth = mCamera.getParameters().getPreviewSize().width;
  mPreviewHeight = mCamera.getParameters().getPreviewSize().height;   
  ...
}

 

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

With this new code, I don't get that exception anymore. A kind of peculiarly processed image is captured by the mobile camera but may be is right as the application performs the corners detection.

I hope it helps you.

Regards,

Eduardo

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.