Start a new topic

Camera not starting

Camera not starting


Hello,

I have a question/issue that might be simple to solve but I cannot figgure it out. I am trying to make my own app that has an images as target and the creates a transparent video.

However, my camera is not starting, all i see is the "trial" background from wikitude.

My mainActivity looks like this:

 protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

 

 

        Log.d("myTag","Version:" + android.os.Build.VERSION.SDK_INT);

        //Camera.open();

 

        this.architectView = (ArchitectView)this.findViewById( R.id.architectView );

        final StartupConfiguration config = new StartupConfiguration( key );

        this.architectView.onCreate( config );

 

 

        this.architectView.onPostCreate();

        try {

 

            this.architectView.load(menuEntry);

        } catch (IOException e) {

            e.printStackTrace();

        }

    }

 

The sample project is working, but I cannot see figgure out exactly where/how the camera is opened. Can someone push me in the right direction?

Thanks for any help!

Hi, did you get any particular message in the logcat window? Does your application open the camera before starting the AR View?
One possible explanation is that the main HTML file of your AR world has a non-transparent background. The rendering of this HTML file could be hiding the camera.

My logcat gives this outmout which might be relevant:

04-10 15:14:16.445  11482-11482/com.designit.augmented E/? Device driver API match

    Device driver API version: 29

    User space API version: 29

04-10 15:14:16.445  11482-11482/com.designit.augmented E/? mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Tue Jul 22 19:59:34 KST 2014

...

04-10 15:14:17.475  11482-11482/com.designit.augmented W/AwContents? nativeOnDraw failed; clearing to background color.

04-10 15:14:17.550  11482-11499/com.designit.augmented E/libEGL? called unimplemented OpenGL ES API

04-10 15:14:17.560  11482-11499/com.designit.augmented E/libEGL? called unimplemented OpenGL ES API

04-10 15:14:17.720  11482-11482/com.designit.augmented W/AwContents? nativeOnDraw failed; clearing to background color.

04-10 15:14:18.180  11482-11508/com.designit.augmented E/AndroidProtocolHandler? Unable to open asset URL: file:///android_asset/ade.js

...

 

Im not sure I understand your question about the camera - That is my whole problem, I am not opening it at all. (However, I cannot open my device's camera app at the same time as this app is running in the background)

 

I dont think the issue is in the html/css/js documents. I am just using the example code from your app here, without any modifications. (Example 7 video with bonus transparency)

 

When I start my app I have the top border saying "Scan target #1(surfer) or #2(biker)" and two small preview pictures. After 10 secounds this top-border disapears, as specified in the javascript file.

Where the camera feed should be, is just a black screen with the text "trial" written all over it.

 

Thanks for the feedback Gabriele

 

The line with "W/AwContents? nativeOnDraw failed; clearing to background color" could in my opinion be the reason for the issues. In this post https://jira.appcelerator.org/browse/TIDOC-1548 they have the same error, albeit another program altogether. Someone mentions this:  

This issue seems to be related to the way the webview is created.
I created a module, that creates the webview inside a fragment. When created this way, the error does not occur.

I am not sure how the webview is created when using the wikitude architectview, but it could be related as the samples are created in an fragment, or at least, the camera is?

When I call the this.architectView.getCurrentCamera() it return with "REAR" which seems to correct to me. So the camera might very well be opened, it is just hidden/not drawn/redndered as you suggest in your reply Garbriele. However I am not sure how to solve this issue.

Have you tried scanning the target? If the problem is the camera rendering, you should see the augmentation on the screen, even if the background is black.

You must put this in the Lifecyle Method in the same class but not in onCreate: 

 

protected void onPostCreate( final Bundle savedInstanceState ) {

super.onPostCreate( savedInstanceState );

if ( this.architectView != null ) {

this.architectView.onPostCreate();

try {

this.architectView.load("<index html in assets folder>");

 

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

 

And it works fine :)

Hi guys,

 

I have the exact same problem. I copied the first cam (surfer) example from the sample app and started my own activity according to the few instructions in the android starting tutorials. I do see the surfer header which means the html is loaded.

i also got the called unimplemented OpenGL ES API error. 

activity_main.xml:


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="horizontal">

<com.wikitude.architect.ArchitectView android:id="@+id/architectView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>

</LinearLayout>


 

Permissions:

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission android:name="android.permission.ACCESS_GPS" />

    <uses-permission android:name="android.permission.CAMERA" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 

My main method:

public class MainActivity extends Activity {

ArchitectView architectView;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

 

this.architectView = (ArchitectView) this

.findViewById(R.id.architectView);

final StartupConfiguration config = new StartupConfiguration(key);

this.architectView.onCreate(config);

}

 

@Override

protected void onPostCreate(Bundle savedInstanceState) {

super.onPostCreate(savedInstanceState);

if (this.architectView != null) {

this.architectView.onPostCreate();

try {

this.architectView.load("index.html")

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

}

Is the normal sample application working?

What happens if you try scanning the target (even if the camera background is black)?

Can you post (or e-mail) the full source code of your test application?

The sample application is working. The camera works, if I scan the surfer dude i see the surfboard appear.

In my own created app nothing happens if I scan the target. The camera doesnt show, the surfboard doesnt appear. Only black trial trial trial trial.

Source:

 

MainActivity.java

package com.example.wikitudedemo;

 

import java.io.IOException;

 

import com.wikitude.architect.ArchitectView;

import com.wikitude.architect.StartupConfiguration;

 

import android.app.Activity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

 

public class MainActivity extends Activity {

ArchitectView architectView;

 

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

 

this.architectView = (ArchitectView) this

.findViewById(R.id.architectView);

final StartupConfiguration config = new StartupConfiguration("1234567890"); //my key here

this.architectView.onCreate(config);

}

 

@Override

protected void onPostCreate(final Bundle savedInstanceState) {

super.onPostCreate(savedInstanceState);

if (this.architectView != null) {

this.architectView.onPostCreate();

try {

this.architectView.load("index.html");

 

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

 

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

 

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}

 

activity_main.xml


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="horizontal">

<com.wikitude.architect.ArchitectView android:id="@+id/architectView" android:layout_width="fill_parent" android:layout_height="fill_parent"/>

</LinearLayout>

 

assets/index.html

copied index.html / assets folder / css folder / js folder exactly from the sample surfer dude (1_Client$Recognition_1_Image$On$Target)

 

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.wikitudedemo"

    android:versionCode="1"

    android:versionName="1.0" >

 

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission android:name="android.permission.ACCESS_GPS" />

    <uses-permission android:name="android.permission.CAMERA" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 

    <uses-feature

        android:name="android.hardware.camera"

        android:required="true" />

    <uses-feature

        android:name="android.hardware.location"

        android:required="true" />

    <uses-feature

        android:name="android.hardware.sensor.accelerometer"

        android:required="true" />

    <uses-feature

        android:name="android.hardware.sensor.compass"

        android:required="true" />

    <uses-feature

        android:glEsVersion="0x00020000"

        android:required="true" />

 

    <uses-sdk

        android:minSdkVersion="21"

        android:targetSdkVersion="22" />

 

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >

        <activity

            android:name=".MainActivity"

            android:label="@string/app_name"

            android:configChanges="screenSize|orientation">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>

 

</manifest>

 

If you want any other source pls let me know


 

 

using a samsung galaxy s4 for testing

solved

Put an empty template project next to the sample project in the sdk zip! There are quite a few people that ran into a similar problem as the 'hints'  given in the developer guide are a bit hard to find.

 

@Override

public void onResume() {

super.onResume();

 

this.architectView.onResume();

}

 

 

Thank you for the information.

 

thanks! This was driving me nuts!

for anyone else with the same issue, refer to these lines in the docs:

 

It is very important to notify the ArchitectView about life-cycle events of the Activity. Call architectView's onCreate(), onPostCreate(), onPause(), onResume(), onDestroy() inside your Activity's lifecycle methods.

 

basically, you need to override each of those activity lifecycle methods and call the architectView's methods inside them. like so:

@Override
protected void onPause() {
super.onPause();
this.architectView.onPause();
}

@Override
protected void onResume() {
super.onResume();
this.architectView.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
this.architectView.onDestroy();
}

 

 
Login or Signup to post a comment