domenica 25 aprile 2021

I'M STILL HERE! eMOTION (with no 'e')

 Ok, I know, I missed a lot this small space, and coming back is always an eMOTION, yes an Electronic MOTION!


Ok maybe it is correct to refer as DIGITAL MOTION...

Anyway, some days ago I used a product, the Leap Motion Controller!


Wait...


... AdBlock is it you???...

Ok.. Leap Motion Controller... I would like to talk about it, its company and so on but no $_$ omg :'( so the maximum suffered effort is: look on its website ultraleap.com.

As the name suggests... or not... this device allows to track hands movement and perform nice stuff as interacting with applications with your hands with no touch and so on, so could be a forward step with respect to the (OMG) touch on screens!

Maybe the solution could be still no mature for business users but it is very useful for researchers, developers, people with a fked brain like mine and emperors and kings of this GALAXY (Yes, Andromeda Galaxy is not included!).

There are nice applications to try with Leap Motion Controller but I don't want to focus on it, now I MUST use this post for WHO wants to start to develop nice applications with this device.

So, LET'S START:

Items:
Save LeapSDK folder, freeglut and glew folders in a path, for example "C:\Users\username\Documents\Libraries\".

Freeglut and glew are used only for those applications using GLUT.

For first, set a new environment variable by Windows System Properties. Search on search bar of Windows "System Properties", click on "System" --> "Advanced system settings" --> "Environment Variables..." and in the "System variables" window, click on "New..." and make a new environment variable:

Variable name: LEAP_SDK
Variable value: path of your LeapSDK (i.e. C:\Users\username\Documents\Libraries\LeapSDK)

Reboot the computer.

Open Visual Studio 2019 --> Create a new project --> Console App --> we can name the project as "LeapTest".


  • Open the Project Property Pages using the Project > Properties menu command.
  • Set up a Debug configuration:
    • Choose the Debug configuration as "Debug" or "Active(Debug)" and Platform as "x64" or "Active(x64)".
    • Add the SDK include directory to your project:
      • i.  Under Configuration Properties, select C/C++ > General.
      • ii. In the properties pane, add the SDK include directory to the Additional Include Directories field by adding:

        $(LEAP_SDK)\include
        C:\Users\admin\Documents\Libraries\freeglut\include
        C:\Users\admin\Documents\Libraries\glew\include


    • Add references to the Leap Motion libraries:
      • i. Under Configuration Properties, select Linker > General.
      • ii. In the properties pane, add the SDK lib\x64 directory to the Additional Library Directories field by adding:

        $(LEAP_SDK)\lib\x64
        C:\Users\admin\Documents\Libraries\glew\lib\Release\x64
        C:\Users\admin\Documents\Libraries\freeglut\lib\x64


      • iii. Select Linker > Input
      • iv. Add LeapC.lib;freeglut.lib;glew32.lib;glew32s.lib;opengl32.lib; to the Additional Dependencies field.

    • Add a Post-Build Event to copy the Leap Motion libraries to the project’s target executable directory.
      • i. Under Configuration Properties, select Build Events > Post-Build Event.
      • ii. Edit the Command Line field to copy the libraries, adding:

        xcopy /yr "$(LEAP_SDK)\lib\x64\LeapC.dll" "$(TargetDir)"
        xcopy /yr "C:\Users\admin\Documents\Libraries\glew\bin\Release\x64\glew32.dll" "$(TargetDir)"
        xcopy /yr "C:\Users\admin\Documents\Libraries\freeglut\bin\x64\freeglut.dll" "$(TargetDir)"
  • Set up a Release configuration:
    • Choose the Release configuration.
    • Repeat the steps above with configuration as "Release".

Let's guess you want to test some sample applications provided by Leap Motion in the LeapSDK/samples. This folder contains several examples of programs to test. Let's test the "ExampleConnection" program.

Go to the LeapTest project created at the beginning, and delete the .cpp file containing the main() function (LeapTest.cpp) because the samples are written in C and this could cause errors as "Unresolved external symbol..." due to the linking of .c objects with a .cpp object. At this point, make a new .c file that will contain the main() function.

On the right pane of Visual Studio, under the project, right-click on LeapTest --> Add... --> Existing Item... and select CallbackSample.c (containing the main() function), ExampleConnection.h and ExampleConnection.c. These files are contained in the LeapSDK/samples folder.

Connect the Leap Motion Controller to the computer, compile and build the solution and run the program.
Remember to build as x64 otherwise you will get the error of LeapC.h not found.

When the program is run, you can stop it by pressing Enter.

---------------------------------------

You can also test some GLUT application for having some interesting result. From your project delete the CallbackSample.c, we don't need it and, on the right pane of Visual Studio, under the project, right-click on LeapTest --> Add... --> Existing Item... and select GLUTSample.c, GLutils.c and GLutils.h.

Try again to build and run the application as x64 and your result will open a new graphical window like this:


VERY COOL!

The used LeapSDK is the latest version but in Preview mode, but I think it could have some improvement with respect the previous versions.

The only limit I'm seeing is related to keeping up one or two fingers of one hand and the result is a closed hand. Maybe it could be fixed by "playing" on the Leap functions.

I continue to test more this device... let's see this eMOTION...

Nessun commento:

Posta un commento