user2103324
user2103324

Reputation: 31

java.lang.NullPointerException -using opencv and android

I tried to make this code work, but I have this error and I don't know how solve it:

03-23 21:51:44.705: E/AndroidRuntime(1628): java.lang.NullPointerException 03-23 21:51:44.705: E/AndroidRuntime(1628): at org.projectproto.objtrack.SampleViewBase.surfaceCreated(SampleViewBase.java:107)

Upvotes: 1

Views: 886

Answers (1)

fish
fish

Reputation: 828

mCamera seems to be null because Camera.open(); did not return a reference to a camera.

There are different possibilities for that. One might be a missing camera permission in your manifest file. Check it for <uses-permission android:name="android.permission.CAMERA" />

At my Nexus 7 I experienced a problem with Camera.open() as well because for some reason Camera.open(0), which is the same as Camera.open() returned null but Camera.open(1) returned a Camera object of my front camera. May be this is a general issue with devices which only have a frontcamera, but I don't know.

Anyway, this should be the place for you to look at.

Camera | Android Developers

Upvotes: 1

Related Questions