Log in or register to post comments

Creating several Virtual Buttons dynamically

August 13, 2015 - 5:08am #1

Hi,

I'm using Vuforia 4.2.3 on Android, using C++.

I'm trying to create several Virtual Buttons using the 'toggleVirtualButton' method - but I am only able to create one button. All the rest fail with log message "ImageTarget::createVirtualButton(): Failed to create virtual button." 

I made sure the names are not the same, I have tried various rectangle coordinates - but came up with nothing.

 

Any ideas what could the problem be?

 

Thanks,

yakobom

Creating several Virtual Buttons dynamically

September 11, 2015 - 4:40pm #7

Hi,

Yes, you can use the user defined targets for the virtual buttons. It may be that the place where you are creating the button is not feature rich so it won't trigger, or it can be triggering not so reliably.

How are you checking if the buttons are correctly created and triggered? The sample itself does not render the buttons area, you have to define the coordinates in the sample if you want to see them but you don't need to render the button for it to work.

If you are still experiencing problems after this, please attach some images and also relevant code where you create the buttons.

Creating several Virtual Buttons dynamically

September 1, 2015 - 8:56pm #6

Hi,

Thanks for your reply.

Yes, I have checked the sample and as mentioned below I am using 'toggleVirtualButton'. I am rendering my buttons, and I am able to see the first button always - the creation of the second one always fails.

After rechecking my code, I realized that the part that does not work referes to a User Defined Target only, for regular targets all the buttons are created and are shown. Is there a limit on the number of virtual buttons for UDT?

 

Thanks,

yakobom

Creating several Virtual Buttons dynamically

August 31, 2015 - 11:16am #5

Have you checked the sample application provided? Look for method toggleVirtualButton(ImageTarget imageTarget, String name, float left, float top, float right, float bottom) in VirtualButtons.java.

You can see there that we are destroying and creating the buttons whenever you check or uncheck the button in the app menu for virtual buttons.

If that works then try with your target by just replacing it instead of the Wood target. Then create the buttons one by on the target.

Check in VirtualButtonsRenderer.java in method RenderFrame() the line containing for (int i = 0; i < imageTargetResult.getNumVirtualButtons(); ++i), there you can iterate through all the virtual buttons and check if the button was created.

Notice that the buttons area are not automatically rendered, if you want to render the button contour you would need to check how is it done below that code where we use vbRectangle[] or just modify the Rectangle values.

 

Creating several Virtual Buttons dynamically

August 17, 2015 - 10:01pm #4

Guys, I'm still stuck with this issue - can anyone try to assist?

 

Thanks,

yakobom

Creating several Virtual Buttons dynamically

August 15, 2015 - 11:16pm #3

Thank you, but that is not the case. You see, if I change the order of the creation, the first button is always the one that is created and shown. So it seem like it is not a problem of the coordinates...

 

yakobom

Creating several Virtual Buttons dynamically

August 13, 2015 - 10:23am #2

It may be possible you are defining your buttons outside of your image target.

Go to this link for more information: https://developer.vuforia.com/library/articles/Solution/How-To-Implement-Virtual-Buttons

Log in or register to post comments