I am working on android camera app,I want green screen chroma key effect to captured image. I have used http://code.google.com/p/chroma-key-project/downloads/list this chroma key project with my code.
I am using tablet which having front camera instead of back camera..I have also used permission for front camera
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.front" />
still it shows an error null pointer exception from preview.java page to this line . camera.setPreviewDisplay(holder); // <9> why?
Check the preview.java page from the given link in chroma key project.please suggest.
this type of error I am getting.
10-11 15:37:36.131: W/dalvikvm(11339): threadid=1: thread exiting with uncaught exception (group=0x409ee1f8)
10-11 15:37:36.141: E/AndroidRuntime(11339): FATAL EXCEPTION: main
10-11 15:37:36.141: E/AndroidRuntime(11339): java.lang.UnsupportedOperationException
10-11 15:37:36.141: E/AndroidRuntime(11339): at java.lang.Thread.stop(Thread.java:1076)
10-11 15:37:36.141: E/AndroidRuntime(11339): at java.lang.Thread.stop(Thread.java:1063)
10-11 15:37:36.141: E/AndroidRuntime(11339): at com.Activity.new2you4kids.MainClass.startCamera(MainClass.java:179)
10-11 15:37:36.141: E/AndroidRuntime(11339): at com.Activity.new2you4kids.MainClass$1.handleMessage(MainClass.java:61)
10-11 15:37:36.141: E/AndroidRuntime(11339): at android.os.Handler.dispatchMessage(Handler.java:99)
10-11 15:37:36.141: E/AndroidRuntime(11339): at android.os.Looper.loop(Looper.java:137)
10-11 15:37:36.141: E/AndroidRuntime(11339): at android.app.ActivityThread.main(ActivityThread.java:4424)
10-11 15:37:36.141: E/AndroidRuntime(11339): at java.lang.reflect.Method.invokeNative(Native Method)
10-11 15:37:36.141: E/AndroidRuntime(11339): at java.lang.reflect.Method.invoke(Method.java:511)
10-11 15:37:36.141: E/AndroidRuntime(11339): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-11 15:37:36.141: E/AndroidRuntime(11339): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-11 15:37:36.141: E/AndroidRuntime(11339): at dalvik.system.NativeStart.main(Native Method)
Thanks!
Camera.open() tries to open the default back camera i think, so it returns null because there is no camera on the back.
what if you try the function Camera.open(int) to open the front camera?
Like this:
And get it like this:
From: How to detect if there is front camera and if there is how to reach and use front camera?
Edit: the code you are using is very old and has all kinds of old functions, the crash you are having is caused by an old thread function (stop) i think.
Code from the link:
according to the developers site:
stop()
This method is deprecated. because stopping a thread in this manner is unsafe and can leave your application and the VM in an unpredictable state.
See:
java.lang.UnsupportedOperationException when my splash screen starts
http://developer.android.com/reference/java/lang/Thread.html#stop()
Edit two:
Change the onCreateOptionsMenu code to this, you should not use the myMenu variable.