leapmotion / leapjs

JavaScript client for the Leap Motion Controller
https://developer.leapmotion.com/leapjs
Apache License 2.0
2k stars 446 forks source link

Screen API data in Javascript? #31

Open RileySpiller opened 11 years ago

RileySpiller commented 11 years ago

I don't see any Screen API information in the raw JSON data. I've got a v6 device and v0.7.3 software. Has it not been implemented in Javascript yet?

barbagallo commented 11 years ago

I don't think you need the Screen object, do you?

Given the context of the browser and the window object that's readily available.

neptunius commented 11 years ago

While you do have browser window information, you similarly have screen size information in most graphics engines. However, these do not provide a physical screen location in Leap coordinate space, as the Screen API does once you have run the screen locator tool. You can then convert between Leap coordinates and screen pixels, including projecting from a finger tip onto the screen like a laser pointer. It also supports multiple monitor setups quite well.

We have not added the Screen data or the new features coming in the 0.7.4 release to the JSON data or JavaScript API yet, as Josh and others are focusing on improving the core functionality and making the library more testable. Once this is further along, we plan to catch up with the constantly evolving C++ API and distribute the JavaScript library with our main SDK download.

Alan Davis // Leap SDK team

hyzhak commented 11 years ago

@neptunius looking forward to this opportunity. Without Screen API i can't implement precise pointing

saschagehlich commented 11 years ago

+1

Right now, we use the absolute position in 3d space to map it to the screen. This is not very precise and doesn't really feel natural. We would still use this as a fallback in case the screen has not been located (a flag for that would be great).

A real screen position would be awesome though (even though it will be hard to map it to the actual window position)

Any update on this @neptunius / @joshbuddy ?

brianantonelli commented 11 years ago

+1

@saschagehlich could you share the code you're using?

cabbibo commented 11 years ago

@brianantonelli @saschagehlich @Hyzhak

I personally really enjoy using 'CD gain' as a method of getting more accurate pointing. It basically just multiples the velocity by a 'CD gain' in order to get the new position. I wrote a very hacky demo of some different gain equations that can be used, that you guys are free to check out and tear apart / reuse. I'm happy to answer any questions about it! As you can see some of the equations work better then others, but overall, I like the feel better than absolute positioning, and it allows the user to point to much smaller areas, because it takes away some of the natural hand shake.

http://cabbibo.com/leap/lmlab/mouse/test.html

An Image of different CD gain equations that different companies use: http://www.nonsequitoria.com/v.php?s=research&f=control_display_gain

brianantonelli commented 11 years ago

@cabbibo This was a HUGE help thank you so much!

cabbibo commented 11 years ago

@brianantonelli So glad. It definitely was a super helpful discovery for me as well, so I had to share it!

joshbuddy commented 11 years ago

fwiw, @cabbibo is an awesome human being. On another note ... this is still coming, just been a bit delayed on getting this work done :)

hyzhak commented 11 years ago

@joshbuddy good news! we're still waiting it

jackey commented 10 years ago
    function xy(mm) {
        var max_mm_x = 600,
            max_mm_y = 500;
        var max_px_x = parseInt($(window.document).width()),
            max_px_y = parseInt($(window.document).height());

        var x2 = parseInt(mm[0]) + max_mm_x / 2;
        var y2 = max_mm_y - parseInt(mm[1]);
        return [(max_px_x / max_mm_x) * x2 ,(max_px_y / max_mm_y )  * y2];
    }

this is function to convert position of finger to position in windows screen. is it your want ?

hyzhak commented 10 years ago

@jackey nope, you miss the point of Screen API. Look there for more information https://developer.leapmotion.com/documentation/Languages/C++/Guides/Leap_Screen_Location.html