googlearchive / tango-examples-c

JNI example projects for Project Tango [deprecated] C-API
https://developers.google.com/ar
Apache License 2.0
337 stars 204 forks source link

connectOnFrameAvailable fails to connectSurface #111

Open sjfricke opened 7 years ago

sjfricke commented 7 years ago

I have spent a lot of time making sure my example is exactly as that of hello_video and I keep getting

TangoErrorType TangoService_connectOnFrameAvailable(TangoCameraId, void*, void (*)(void*, TangoCameraId, const TangoImageBuffer*)): Done connecting callbacks.
...
interface E/tango_client_api: TangoErrorType TangoService_connect(void*, TangoConfig): Internal error: Failed to connectSurface, cam id: 0.

While what it SHOULD be is

I/tango_client_api: TangoErrorType TangoService_connectOnFrameAvailable(TangoCameraId, void*, void (*)(void*, TangoCameraId, const TangoImageBuffer*)) called for cam id(0) before TangoService_connect(). Callback will be registered on next call to TangoService_connect().
...
I/tango_client_api: TangoErrorType TangoService_connect(void*, TangoConfig): Successfully connected to Tango.
sjfricke commented 7 years ago

I found if I manually run adb shell am grant com.my.app.package android.permission.CAMERA it works, but not sure why this isn't automatic

Other option is to add

private static final int MY_CAMERA_REQUEST_CODE = 100;

if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
{
  requestPermissions(new String[]{Manifest.permission.CAMERA}, MY_CAMERA_REQUEST_CODE);
}

to the samples