Log in or register to post comments

VirtualButton::isPressed

March 24, 2012 - 7:26am #1

Hello,

i'm working on a very simple iOS app using Vuforia SDK.
The app displayes 3d text billboards on top of an image target and it works correctly. Now i'd like to add virtual buttons where the billboards are located. I added button definitions to the xml file. I double-checked with my code that these values are parsed correctly.

The issue:
Very often VirtualButton::isPressed returns true even if nothing is pressing the button. Even if i put the printed image on an empty table too often the button is detected as pressed... I tried to change sensitivity to LOW but the problem persists. I even tried with a different image target but i still have the same problem.

Another consideration:
I did NOT draw the buttons on the image. I was assuming editing the xml file is enough for the system to check the pressed state. Is there any need to have button images drawn in the imagetarget?

EDIT
this is the code i'm using to set button sensitivity:

// Inside renderFrameQCAR before anything else
if (!_vbInited) {
    QCAR::ImageTarget *target = [[QCARUtils getInstance()] getImageTarget:0];
    int numButtons = target->getNumVirtualButtons();
    for (int i = 0; i < numButtons; i++) {
        QCAR::VirtualButton *button = target->getVirtualButton(i);
        assert(button->setSensitivity(QCAR::VirtualButton::LOW));
    }
    // Do this just once otherwise button presses are not detected at all!
    _vbInited = YES;
}

This is the way i detect if a button is pressed:

// Inside renderFrameQCAR while looping active trackables
QCAR::ImageTarget *target = (QCAR::ImagetTarget *)activeTrackable;
int numButtons = target->getNumVirtualButtons();
for (int i = 0; i < numButtons; i++) {
    QCAR::VirtualButton *button = target->getVirtualButton(i);
    if (button->isPressed()) {
        // Do something
    }
}

Re: VirtualButton::isPressed

March 26, 2012 - 3:05am #3

Glad to see that you resolved this.

Note that the virtual buttons have to live entirely within the target region. You don't need to draw anything - if your target doesn't contain any obvious 'button' regions you may wish to outline them as we do in the VirtualButtons sample app.

Re: VirtualButton::isPressed

March 24, 2012 - 9:36am #2

I answer my self... it turned out it was just a problem of a poor quality image target. I replaced it with a 4/5 stars target and now is working perfectly even whit normal sensitivity.

Log in or register to post comments