Ask Your Question
3

tuto Android 4.1.1 + OpenCV 2.4.2 + Nexus S

asked 2012-09-24 09:23:59 -0600

Thalion gravatar image

Hello, I'm new to OpenCV and more generally to "computer vision" and android.hardware.Camera. I try to run the examples (tutorial-0-androidcamera et tutorial-1-addopencv) and nothing works.

For the first, the LogCat say :

  • 09-21 14:35:47.800: E/BufferQueue(15201): [unnamed-15201-0] setBufferCount: SurfaceTexture has been abandoned!
  • 09-21 14:35:47.808: D/AndroidRuntime(15201): Shutting down VM
  • 09-21 14:35:47.808: W/dalvikvm(15201): threadid=1: thread exiting with uncaught exception (group=0x40cb3300)
  • 09-21 14:35:47.808: E/AndroidRuntime(15201): FATAL EXCEPTION: main
  • 09-21 14:35:47.808: E/AndroidRuntime(15201): java.lang.RuntimeException: startPreview failed
  • 09-21 14:35:47.808: E/AndroidRuntime(15201): at android.hardware.Camera.startPreview(Native Method)
  • 09-21 14:35:47.808: E/AndroidRuntime(15201): at org.opencv.samples.tutorial0.SampleViewBase.setupCamera(SampleViewBase.java:138)

And for the second :

  • 09-21 14:38:36.206: E/BufferQueue(15330): [unnamed-15330-0] setBufferCount: SurfaceTexture has been abandoned!
  • 09-21 14:38:36.206: D/AndroidRuntime(15330): Shutting down VM
  • 09-21 14:38:36.206: W/dalvikvm(15330): threadid=1: thread exiting with uncaught exception (group=0x40cb3300)
  • 09-21 14:38:36.214: E/AndroidRuntime(15330): FATAL EXCEPTION: main
  • 09-21 14:38:36.214: E/AndroidRuntime(15330): java.lang.RuntimeException: startPreview failed
  • 09-21 14:38:36.214: E/AndroidRuntime(15330): at android.hardware.Camera.startPreview(Native Method)
  • 09-21 14:38:36.214: E/AndroidRuntime(15330): at org.opencv.samples.tutorial1.SampleViewBase.setupCamera(SampleViewBase.java:138)

I saw that there were some known issues with the previous version, but were theoricaly corrected with the latest one. However, I tried to compare yesterday solutions with today's code, and i can't explain what's going wrong.

I used this package : http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.2/OpenCV-2.4.2-android-sdk.zip/download

sorry for my bad english

David

edit retag flag offensive close merge delete

Comments

Are you using prebuilt apk files from the SDK? If not, could you try to run them? You can also try to run 15-puzzle sample.

Update: today I tested 15-puzzle on Nexus S and it works OK. That means that other samples should work without issues. Is it possible that you changed sources and somehow broken the samples?

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-09-25 05:57:08 -0600 )edit

I tried to run the camera0 app with the same setup and it didn't work (tried 2.4.0 before). I think there is a problem with the camera preview as 15-puzzle did work without problems

steveT gravatar imagesteveT ( 2012-09-25 12:45:06 -0600 )edit

I'm having the same problem.

akessner gravatar imageakessner ( 2012-10-17 08:38:00 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2012-12-11 11:54:37 -0600

steveT gravatar image

Lately I tried my Android app with opencv 2.4.0 on Jelly Bean and I got the same error. I solved it by removing the following two lines in ViewBase.setPreview

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
     mCamera.setPreviewTexture( new SurfaceTexture(10) );
 else
     mCamera.setPreviewDisplay(null);

and replaced it with

 mCamera.setPreviewDisplay(mHolder);

Now it's not possible to write to the SurfaceView that was originally used for the preview because the canvas is constantly locked. So I removed the writing-to-the-canvas stuff from the ViewBase's thread and registered a callback in the View which is executed in onProcessFrame so that I have the image data some where else. Now I can process the image data and write it to another SurfaceView which overlays the original camera output.

edit flag offensive delete link more

Comments

Actually, changing the camera's setPreviewCallback instead of using the onProcessFrame method should work fine as well.

steveT gravatar imagesteveT ( 2012-12-11 11:55:08 -0600 )edit
0

answered 2012-12-14 03:09:02 -0600

V.G. gravatar image

If you believe, that this issue has been resolved, could you please accept the most appropriate answer (even if it's your own one) and close this question. It would greatly improve navigation and overall experience with OpenCV Q&A.

Thanks.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-09-24 09:23:59 -0600

Seen: 2,558 times

Last updated: Dec 14 '12