Log in or register to post comments

'Failed to load dataset' from NativeActivity

March 10, 2013 - 4:00am #1

Hi,

I'm trying to integrate Vuforia into our engine. My current setup uses a Java class extending 'NativeActivity' which copies minimal setup from the ImageTargets example - basically the 'InitQCARTask' background task. This task succesfully initialises then I do the rest in C++ land:

		// Initialise tracker
		m_pTrackerManager = &QCAR::TrackerManager::getInstance();
		if( !m_pTrackerManager ) { tRE_BreakBlock_Error( "QAR", "Failed to create tracking manager." ); }
		tRE_System.Log( "QAR", "Initialised tracker manager." );

		m_pImageTracker = static_cast< QCAR::ImageTracker * >( m_pTrackerManager->initTracker( QCAR::Tracker::IMAGE_TRACKER ) );
		if( !m_pImageTracker ) { tRE_BreakBlock_Error( "QAR", "Failed to create image tracker." ); }
		tRE_System.Log( "QAR", "Initialised image tracker." );

		// Callback for data set swaps
//		QCAR::registerCallback( &updateCallback );

		// Number of markers to track
//		QCAR::setHint( QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 2 );

		// Create data set
		m_pDataSet = m_pImageTracker->createDataSet();
		if( !m_pDataSet ) { tRE_BreakBlock_Error( "QAR", "Failed to create data set." ); }
		tRE_System.Log( "QAR", "Created data set." );

		if( tRE_System.FileExists( "StonesAndChips.xml" ) )
		{
			tRE_System.Log( "QAR", "Engine believes data set exists" );
		}

		if( m_pDataSet->exists( "StonesAndChips.xml", QCAR::DataSet::STORAGE_APPRESOURCE ) )
		{
			tRE_System.Log( "QAR", "Data set exists for QCAR too" );
		}

		// Load data set
		if( !m_pDataSet->load( "StonesAndChips.xml", QCAR::DataSet::STORAGE_APPRESOURCE ) )
		{
			tRE_BreakBlock_Error( "QAR", "Failed to load data set." );
		}
		tRE_System.Log( "QAR", "Loaded data set." );

Now all goes well until it tries to load "StonesAndChips.xml". The file (and it's .dat sibling) is definitely located within my 'assets' folder and the engine reports the file as existing. The problem is that both the data set 'exists' and 'load' fail - logcat gives me the following:

"E/AR      (10031): Failed to load dataset 'StonesAndChips.xml'."

Any ideas as to what could be preventing QCAR from loading a file that's definitely in the right place?

Cheers,
Richard

'Failed to load dataset' from NativeActivity

July 28, 2015 - 3:30am #21

failed to load tracker data

 

Again and again I m getting this error since two days ...

I have done all the things according to this link

https://developer.vuforia.com/forum/faq/android-how-do-i-add-another-target-video-playback-sample

please tell me some solution for android working on sdk 4.2.4 

'Failed to load dataset' from NativeActivity

March 20, 2013 - 3:06am #20

Hi, your question is not related to the original topic of this thread (the problem here is originating by using Vuforia with native activities);

can you post in a new thread (or follow on exsiting thread if you already created one) ?

Thanks.

 

'Failed to load dataset' from NativeActivity

March 20, 2013 - 2:11am #19

hi .. 

can i interrupt and ask the similar problem ??

 

i am stuck at a very commonly faced problem with videoplayback application .

I want to add multiple images in my asset and for that i want multiple videos to play .

i have modified my StonesAndChips.xml file  ,for starters i have added only one image "CHIPS1.jpg"

 

"    <?xml version="1.0"?>
<QCARConfig xsi:noNamespaceSchemaLocation="qcar_config.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Tracking>
        <ImageTarget name="stones" size="247 173"/>
        <ImageTarget name="chips" size="247 173"/>
        <ImageTarget name="chips1" size="247 173"/>
    </Tracking>
    
</QCARConfig>"
 
my concerns ->
1. it gives error "Failed to load tracker data" every time i modify the .xml file.
2. my Stonesandchips.dat file is not getting generated automatically.. can it be the reason ?
3. how to generate a .dat file once you modify your stoneandChips.xml file ?
4. i have made necessary changes in the VideoPlay.cpp file .(i guess i m correct in that)
i ll attach my Videoplay.cpp code in the next thread for your reference. 
 
 
thanking you in advance.

'Failed to load dataset' from NativeActivity

March 13, 2013 - 6:01am #18

No, no plans at the moment. But you can add your request in our forum wish-list section:

https://developer.vuforia.com/forum/general-discussion/wish-list

 

'Failed to load dataset' from NativeActivity

March 13, 2013 - 5:57am #17

No worries on the name front, I'll just remain anonymous for now :)

Yeah, Windows/PC version - something I'd love to see.

'Failed to load dataset' from NativeActivity

March 13, 2013 - 5:49am #16

You can't change the name of your account, I presume you will have to create a new account.

Plans about Windows ? Do you mean on PC ?

'Failed to load dataset' from NativeActivity

March 13, 2013 - 5:40am #15

Yeah, was a 'fun' one to find. Will keep you updated if I make any other discoveries.

I have a couple of O/T questions:

1. Can't can't seem to see where I change my name from '44' - am I missing something?

2. Are you aware of any plans for a Windows version of Vuforia? We do most of our development under Windows using our cross-platform engine and that's the kind of thing that would speed up development iteration time massively.

Cheers,
Richard

'Failed to load dataset' from NativeActivity

March 13, 2013 - 2:26am #14

Thanks Richard for the update; sounds like a really tricky issue, but good to hear you made such progress;

keep us posted, as we will then update the native activity tutorial as per your suggestions.

'Failed to load dataset' from NativeActivity

March 13, 2013 - 2:01am #13

Hi Alessandro,

After lots of simplifying of the NativeActivity version of ImageTargets I've made some progress!

It all boiled down to step 14 from https://developer.vuforia.com/resources/dev-guide/android-native-activities.

Part of that code calls 'javaVM->AttachCurrentThread(&env, NULL);' which is usually detached afterwards but in this case it's not. If I remove that from ImageTargets it also stops rendering the background video texture just like my engine version. Conversly if I add that line and the caching of the JNI vars from the activity to my engine I now get video background rendering too.

I haven't had time to really look through it as time is of the essence but I'm guessing it's linked to getting the render thread attached to the QCAR activity thread as there's the third NativeActivity it's sat on.

Now I have the background rendering I'm trying to reintegrate back into my main engine render loop. So far I'm getting crashes but I suspect this is down to state synchronisation issues between 'QCAR::Renderer::getInstance().drawVideoBackground()' and my OpenGL renderer with state caching.

Cheers,
Richard

'Failed to load dataset' from NativeActivity

March 12, 2013 - 5:18am #12

Hi, I can't see anything wrong in your code;

one last thing it comes to my mind is to try these two lines of code (put them right before the drawVideoBackground() function):

glDisable(GL_CULL_FACE); // as it might be that your videobackground gets culled away

and:

glDisable(GL_DEPTH_TEST);

If that does not solve the issue, my suggestion would be to have a look at the BackgroundTextureAccess sample; that sample shows how to "manually" render the video background (basically by creating a background mesh and applying the video background texture to it).

That sample has the "advantage" to make all the involved OpenGL calls explicit, so it really shows all the OpenGL details of how to achieve videobackground rendering; I think that could really help you to see exactly what goes wrong (for instance, is the video texture invalid, or is it the background mesh not being rendered, etc.)

 

'Failed to load dataset' from NativeActivity

March 12, 2013 - 3:26am #11

Hi Alessandro,

Yep, I'm calling the video configuration in exactly that order. I know the camera itself is working as the tracking side of things behave so it's definitely linked to the video background setup/rendering. The main difference is that I'm setting up the tracker and then initialising the camera in the same native function. Here's my complete initialisation function for reference:

// Initialise our tracker
//
tRE_EResult tRE_CARProcessor_QCAR::InitialiseTracker()
{
	tRE_System.Log( "QAR", "Initialising QCAR:" );
	tRE_System.LogTab();

	tRE_EResult eResult( tRE_Failed );
	tRE_BreakBlock()
	{
		// Initialise tracker
		m_pTrackerManager = &QCAR::TrackerManager::getInstance();
		if( !m_pTrackerManager ) { tRE_BreakBlock_Error( "QAR", "Failed to create tracking manager." ); }
		tRE_System.Log( "QAR", "Initialised tracker manager." );

		m_pImageTracker = static_cast< QCAR::ImageTracker * >( m_pTrackerManager->initTracker( QCAR::Tracker::IMAGE_TRACKER ) );
		if( !m_pImageTracker ) { tRE_BreakBlock_Error( "QAR", "Failed to create image tracker." ); }
		tRE_System.Log( "QAR", "Initialised image tracker." );

		// Callback for data set swaps
//		QCAR::registerCallback( &updateCallback );

		// Number of markers to track
//		QCAR::setHint( QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 2 );

		// Create data set
		m_pDataSet = m_pImageTracker->createDataSet();
		if( !m_pDataSet ) { tRE_BreakBlock_Error( "QAR", "Failed to create data set." ); }
		tRE_System.Log( "QAR", "Created data set." );

		// Load data set
		if( !m_pDataSet->load( "AppData/AR/AR/QCAR/Tarmac.xml", QCAR::DataSet::STORAGE_APPRESOURCE ) ) { tRE_BreakBlock_Error( "QAR", "Failed to load data set." ); }
		tRE_System.Log( "QAR", "Loaded data set." );

		// Set activate data set
		if( !m_pImageTracker->activateDataSet( m_pDataSet ) ) { tRE_BreakBlock_Error( "QAR", "Failed to activate data set." ); }
		tRE_System.Log( "QAR", "Activated data set." );

		// Grab default (hopefully back) camera
		QCAR::CameraDevice::CAMERA Camera( QCAR::CameraDevice::CAMERA_DEFAULT );

		// Initialize the camera
		QCAR::CameraDevice& rCameraDevice( QCAR::CameraDevice::getInstance() );
		if( !rCameraDevice.init( Camera ) ) { tRE_BreakBlock_Error( "QAR", "Failed to initialise camera." ); }
		tRE_System.Log( "QAR", "Initialised camera." );

		// Configure the video background
//		configureVideoBackground();
#if 1
		// Get the default video mode
		QCAR::VideoMode VideoMode( rCameraDevice.getVideoMode( QCAR::CameraDevice::MODE_DEFAULT ) );

		// Configure the video background
		QCAR::VideoBackgroundConfig Config;
		Config.mEnabled = true;
		Config.mSynchronous = true;
		Config.mPosition.data[ 0 ] = 0.0f;
		Config.mPosition.data[ 1 ] = 0.0f;

		tRE_uint screenWidth( 0 ), screenHeight( 0 );

		// RJT TODO:
	#if 0
			if (isActivityInPortraitMode)
			{
				//LOG("configureVideoBackground PORTRAIT");
				config.mSize.data[0] = videoMode.mHeight
					* (screenHeight / (float)videoMode.mWidth);
				config.mSize.data[1] = screenHeight;

				if(config.mSize.data[0] < screenWidth)
				{
					LOG("Correcting rendering background size to handle missmatch between screen and video aspect ratios.");
					config.mSize.data[0] = screenWidth;
					config.mSize.data[1] = screenWidth * 
						(videoMode.mWidth / (float)videoMode.mHeight);
				}
			}
			else
			{
				//LOG("configureVideoBackground LANDSCAPE");
				config.mSize.data[0] = screenWidth;
				config.mSize.data[1] = videoMode.mHeight
					* (screenWidth / (float)videoMode.mWidth);

				if(config.mSize.data[1] < screenHeight)
				{
					LOG("Correcting rendering background size to handle missmatch between screen and video aspect ratios.");
					config.mSize.data[0] = screenHeight
						* (videoMode.mWidth / (float)videoMode.mHeight);
					config.mSize.data[1] = screenHeight;
				}
			}
	#else
			Config.mSize.data[0] = 1024;
			Config.mSize.data[1] = 1024;
	#endif

//		LOG("Configure Video Background : Video (%d,%d), Screen (%d,%d), mSize (%d,%d)", videoMode.mWidth, videoMode.mHeight, screenWidth, screenHeight, config.mSize.data[0], config.mSize.data[1]);
		tRE_System.Log( "QAR", "Configure Video Background : Video (%d,%d), Screen (%d,%d), mSize (%d,%d)",
			VideoMode.mWidth, VideoMode.mHeight, screenWidth, screenHeight, Config.mSize.data[0], Config.mSize.data[1]
		);

		// Set the config
		QCAR::Renderer::getInstance().setVideoBackgroundConfig( Config );
#endif

		// Select the default mode
		if( !rCameraDevice.selectVideoMode( QCAR::CameraDevice::MODE_DEFAULT ) ) { tRE_BreakBlock_Error( "QAR", "Failed to select video mode." ); }
		tRE_System.Log( "QAR", "Selected camera mode." );

		// Start the camera
		if( !rCameraDevice.start() ) { tRE_BreakBlock_Error( "QAR", "Failed to start camera." ); }
		tRE_System.Log( "QAR", "Started camera." );

		// Uncomment to enable flash
//		if( QCAR::CameraDevice::getInstance().setFlashTorchMode( true ) )

		// Uncomment to enable infinity focus mode, or any other supported focus mode
		// See 'CameraDevice.h' for supported focus modes
//		if( QCAR::CameraDevice::getInstance().setFocusMode( QCAR::CameraDevice::FOCUS_MODE_INFINITY ) )

		// Start the tracker
		m_pImageTracker->start();

		// Fetch camera projection matrix
		const QCAR::CameraCalibration& rCameraCalibration( rCameraDevice.getCameraCalibration() );
		QCAR::Matrix44F Projection( QCAR::Tool::getProjectionGL( rCameraCalibration, 2.0f, 2500.0f ) );
		tRE_MemoryCopy( &m_mProjection, &Projection, sizeof( tRE_SMatrix44 ) );

		// RJT NOTE: Seems we need to flip Y
		m_mProjection._11 *= -1.0f;

		tRE_System.Log( "QAR", "Started tracker." );
		eResult = tRE_Success;
	}

	tRE_System.LogUnTab();
	return eResult;
};

Last night I tried compiling the ImageTargets example via command line which worked as expected. Then I followed the Native Activites guide (https://developer.vuforia.com/resources/dev-guide/android-native-activities) which worked after one small change to the instructions - Step 10 needs to be added to the '.ImageTargets' activity whereas the 'intent-filter' is connected to the '.ImageTargetsSplashScreen' activity.

The NativeAcitivity version of image targets works and I've been trying to simplify it as much as possible, the video background still renders so I appreciate it's pretty robust - just baffled as to why my engine test bed doesn't..

'Failed to load dataset' from NativeActivity

March 11, 2013 - 11:21am #10

I see.

So, it actually looks like your camera images might have zero width and zero height (or something misconfigured in the camera image anyway), as otherwise it should render something (even if incorrect, but at least you should see somehing).

So, my opinion here is that your background configuration code (where you set the config position and size) is not called at the right place;

if you take the original Image Targets sample, you will see this code snippet:

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv *,
                                                                         jobject)
{
	
    QCAR::CameraDevice::CAMERA camera = QCAR::CameraDevice::CAMERA_DEFAULT;

    // Initialize the camera:
    if (!QCAR::CameraDevice::getInstance().init(camera))
        return;

    // Configure the video background
    configureVideoBackground();

    // Select the default mode:
    if (!QCAR::CameraDevice::getInstance().selectVideoMode(
                                QCAR::CameraDevice::MODE_DEFAULT))
        return;

       // Start the camera:
    if (!QCAR::CameraDevice::getInstance().start())
        return;

In particular, that snippet shows that the camera configureVideoBackground() is called after the camera initialization, but before the camera start.

I would suggest to check if you are following the same pattern (if not, try to do the same sequence of operations as above)

 

'Failed to load dataset' from NativeActivity

March 11, 2013 - 10:16am #9

I'm now calling the video background config during initialisation and have reduced my rendering loop to the following:

	static tRE_bool sbFlicker( tRE_True );
	sbFlicker ? glClearColor(1.0f, 0.0f, 0.0f, 0.0f) : glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
	sbFlicker = !sbFlicker;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Get the state from QCAR
	QCAR::State State( QCAR::Renderer::getInstance().begin() );

	// Explicitly render the Video Background
	QCAR::Renderer::getInstance().drawVideoBackground();



	// Finish
	QCAR::Renderer::getInstance().end();

As expected, the screen flickers red and blue but I'm still not getting any background video rendering. I am setting the video background width/height to 512x512 for testing purposes, I assume that just controls the extents of the quad it's drawn to and should be fine to use?

'Failed to load dataset' from NativeActivity

March 11, 2013 - 10:03am #8

Ok.

I can think of two issues:

  1. you should call the configuration code (video background config) only once, let's say at initialization, not at every frame,
  2. you should also call glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); before calling begin(), i.e.:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();
    
    // Explicitly render the Video Background
    QCAR::Renderer::getInstance().drawVideoBackground();


    //TODO your scene rendering here


    QCAR::Renderer::getInstance().end();    

'Failed to load dataset' from NativeActivity

March 11, 2013 - 9:11am #7

Hi,

Yep, the rest of my scene renders correctly - literally just video background not working. I've tried removing all of my scene rendering too so it's just the video background render being called per frame but that doesn't render either.

'Failed to load dataset' from NativeActivity

March 11, 2013 - 9:08am #6

Hi, does you scene gets rendered correctly ? (for instance if you make some sort of "animation" like changing the clear color every frame, or somthing simple like that, do you see that correctlty rendered ? i.e. is it just the video background not showing up?

 

'Failed to load dataset' from NativeActivity

March 11, 2013 - 8:32am #5

Hi Alessandro,

Thanks for the update. That all seems to be working now - I can load the data set by calling up to Java and back to native code. I've added camera/tracking code and that's also working. Can't seem to get the background video to render though - I've been trying the following code as a test just before I finish my main engine render frame (with a depth buffer clear just before):

	// Get the default video mode
	QCAR::CameraDevice& rCameraDevice( QCAR::CameraDevice::getInstance() );
	QCAR::VideoMode VideoMode( rCameraDevice.getVideoMode( QCAR::CameraDevice::MODE_DEFAULT ) );

	// Configure the video background
	QCAR::VideoBackgroundConfig Config;
	Config.mEnabled = true;
	Config.mSynchronous = true;
	Config.mPosition.data[ 0 ] = 0.0f;
	Config.mPosition.data[ 1 ] = 0.0f;
	Config.mSize.data[ 0 ] = 512;//screenWidth;
	Config.mSize.data[ 1 ] = 512;//( VideoMode.mHeight * ( screenWidth / static_cast< tRE_f32 >( VideoMode.mWidth ) ) );

	// Set the config
	QCAR::Renderer::getInstance().setVideoBackgroundConfig( Config );

	// Get the state from QCAR
	QCAR::State State( QCAR::Renderer::getInstance().begin() );

	// Explicitly render the Video Background
	QCAR::Renderer::getInstance().drawVideoBackground();

	// Finish
	QCAR::Renderer::getInstance().end();

All I get is the previously drawn frame from my engine scene, it's like this code is doing nothing. I've tried it with the video config code elsewhere (less frequent :) but same result. Any ideas as to what that might be?

Cheers,
Richard

'Failed to load dataset' from NativeActivity

March 10, 2013 - 2:50pm #4

Hi Richard,

thanks for the detailed explanation; indee, as you say, for threadng reasons, you should stick to your second appraoch.

Concerning your question:

Ideally, I'd not have to call the Java-level 'QCAR.init' function and do it all from within 'android_main' at C++ level but I gather that's not possible?

I confirm that (AFAIK at least) you cannot skip the Java code QCAR.init(), so you will have to live with that.

 

'Failed to load dataset' from NativeActivity

March 10, 2013 - 7:52am #3

Hi Alessandro,

Yep, that's definitely called first. I've delved a bit deeper and discovered a bit more:

To simplify things I made the QCAR.init blocking within my 'onCreate' function. Once that's executed succesfully I've tried two different paths:

1) Make a native call down from 'onCreate' to a C++ function that inits the tracker/loads the dats set. This loads the data set as expected.

2) Enter my native application in the usual way through 'android_main' then call the same init/data set load as 1. This is how I was doing things in my first forum post and fails when trying to load the data set.

One theory I have is that 2. fails to load the data set as it's called on another thread (I gather native apps run within their own thread) to 'QCAR.init'. To test this I've made a JNI call from 'android_main' back up to a Java function that then calls back down to initialise the tracker/load the data sets. This works.

I'm just trying to determine the best path to go now. Ideally, I'd not have to call the Java-level 'QCAR.init' function and do it all from within 'android_main' at C++ level but I gather that's not possible? Ultimately, our engine's cross-platform and so I'm trying to keep as much code as generic as possible (I'm hoping to use this same implementation for iOS).

Any further information, advice or work-arounds would be much appreciated.

Cheers,
Richard

'Failed to load dataset' from NativeActivity

March 10, 2013 - 6:08am #2

Hi, 

have you checked that you call QCAR.init() (in Java) before loading the DataSet ?

Log in or register to post comments