Log in or register to post comments

Virtual Button issues with UWP C++ Application for Hololens

August 23, 2017 - 12:01pm #1

Hello, I am having trouble creating a Virtual Button on a non-Unity UWP Hololens application written in C++. I am successfully recognizing an imageTarget from a cloud database through a TargetFinder, but when I try to create a virtual button with the imageTarget, the button is always NULL. Here is the code for my callback function that is supposed to add the button after the image is recognized. 

 void HololensCallback::Vuforia_onUpdate(Vuforia::State& state) {
	TrackerManager& trackerManager = TrackerManager::getInstance();
	ObjectTracker* objectTracker = static_cast<:objecttracker>(

	if (objectTracker == nullptr) {
		printf("Was not able to intialize Object Tracker");
	else {

		TargetFinder* targetFinder = (TargetFinder*)objectTracker->getTargetFinder();

		auto p = targetFinder->updateSearchResults();

		//As of now this runs once and only once. I want to make sure we can get one target correctly before
		//continuing to loop and handle other targets. "buttonCreated" is the bool that makes this run only once.
		if (p == TargetFinder::UPDATE_RESULTS_AVAILABLE && !buttonCreated) {

			buttonCreated = true;

			//make sure there is only one active dataset
			int numActiveDataSets = objectTracker->getActiveDataSetCount();

			//make sure the one data set is deactivated
			bool deactivate = objectTracker->deactivateDataSet(data);

			//make sure there is now no active data sets
			int num = objectTracker->getActiveDataSetCount();

			//temporarly stop object tracker

			//Set of button shape/size
			Rectangle rectangle = Rectangle(-108.68, -53.52, -75.75, -65.87);

			//retrieve image object
			const TargetSearchResult *targetSearchResult = targetFinder->getResult(0);

			//get name of image that was found
			const char* string = targetSearchResult->getTargetName();

			//enable tracking on found image
			ImageTarget *imageTarget = targetFinder->enableTracking(*targetSearchResult);

			//enable extended tracking (Not sure if this is essential)
			bool extendedTrack = imageTarget->startExtendedTracking();

			//check to make sure there are still no active data sets
			numActiveDataSets = objectTracker->getActiveDataSetCount();

			//stop the targetFinder as we are only looking for one target as of now

			//button here returns NULL
			VirtualButton *button = imageTarget->createVirtualButton("red", rectangle);

			//start object tracker again
			bool start = objectTracker->start();

			//activate the data set
			bool activate = objectTracker->activateDataSet(data);

Any help would be appreciated!



Log in or register to post comments