Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

...Use LeapMotion in Ventuz

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

divin
Posts: 11
Joined: 28 Mar 2012, 02:53
Location: korea
Contact:

Re: ...Use LeapMotion in Ventuz

Post by divin » 10 Dec 2013, 03:11

hi

First of all,
I just wanna say that I appreciate all of these postings above cuz there are what I'm trying to find solution for a couple of days.

btw,
MrTompkins wrote:
I guess the missing LeapCSharp.Net4.0 is causing the following error message:
...'Leap.Controller' does not contain a definition for 'Addlistiner'
I do also have same problem with this below.
if possible, let me know what to do.

i know what this means
MrTompkins wrote:
I just saw the mistake...there is a huge difference between:
Addlistener = AddListener
but, it cannot figure out to where i need to fix the code.

thanks Erik and those who post reply :D

MrTompkins

Re: ...Use LeapMotion in Ventuz

Post by MrTompkins » 10 Dec 2013, 08:40

Hello Divin,
I'm just ignoring the missing LeapCSharp.Net4.0 and don't use it at all.
The LeapCSharp.Net3.5 is absolutely enough for me.
I'm using so far the Version V3.08.01 (x64).

Erik fixed the little typing mistake...just try it again from the beginning or
just search for "Addlistener" inside your script and replace it with "AddListener".
That should solve your problem. If your script is still not working there must be another mistake.
You can post your script if you want and I will try to take a look BUT again I'm not a "programmer" ;-).
I just know some basics which are necessary and helpful for Ventuz.

Best regards
Rob

divin
Posts: 11
Joined: 28 Mar 2012, 02:53
Location: korea
Contact:

Re: ...Use LeapMotion in Ventuz

Post by divin » 12 Dec 2013, 06:32

thx for your reply, MrTompkins

this is what I did in Ventuz C# Node.

Code: Select all

using System;
using Ventuz.Kernel;
using System;
using System.Threading;
using Leap;

class SampleListener : Listener
{
	private Object thisLock = new Object ();

	private void SafeWriteLine (String line)
	{
		lock (thisLock) {
			Console.WriteLine(line);
		}
	}

	public override void OnInit (Controller controller)
	{
		SafeWriteLine("Initialized");
	}

	public override void OnConnect (Controller controller)
	{
		SafeWriteLine("Connected");
		controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
		controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
		controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
		controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
	}

	public override void OnDisconnect (Controller controller)
	{
		SafeWriteLine("Disconnected");
	}

	public override void OnExit (Controller controller)
	{
		SafeWriteLine("Exited");
	}

	public override void OnFrame (Controller controller)
	{
		Frame frame = controller.Frame();

		SafeWriteLine("Frame id: " + frame.Id
			+ ", timestamp: " + frame.Timestamp
			+ ", hands: " + frame.Hands.Count
			+ ", fingers: " + frame.Fingers.Count
			+ ", tools: " + frame.Tools.Count
			+ ", gestures: " + frame.Gestures().Count);

		if (!frame.Hands.IsEmpty) {
			Hand hand = frame.Hands[0];

			FingerList fingers = hand.Fingers;
			if (!fingers.IsEmpty) {
				// Calculate the hand's average finger tip position
				Vector avgPos = Vector.Zero;
				foreach (Finger finger in fingers) {
					avgPos += finger.TipPosition;
				}
				avgPos /= fingers.Count;
				SafeWriteLine("Hand has " + fingers.Count
					+ " fingers, average finger tip position: " + avgPos);
			}

			// Get the hand's sphere radius and palm position
			SafeWriteLine("Hand sphere radius: " + hand.SphereRadius.ToString("n2")
				+ " mm, palm position: " + hand.PalmPosition);

			// Get the hand's normal vector and direction
			Vector normal = hand.PalmNormal;
			Vector direction = hand.Direction;

			// Calculate the hand's pitch, roll, and yaw angles
			SafeWriteLine("Hand pitch: " + direction.Pitch * 180.0f / (float) Math.PI + " degrees, "
				+ "roll: " + normal.Roll * 180.0f / (float) Math.PI + " degrees, "
				+ "yaw: " + direction.Yaw * 180.0f / (float) Math.PI + " degrees");
		}

		// Get gestures
		GestureList gestures = frame.Gestures();
		for (int i = 0; i < gestures.Count; i++) {
			Gesture gesture = gestures[i];

			switch (gesture.Type) {
				case Gesture.GestureType.TYPECIRCLE:
					CircleGesture circle = new CircleGesture (gesture);

					// Calculate clock direction using the angle between circle normal and pointable
					String clockwiseness;
					if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4) {
						//Clockwise if angle is less than 90 degrees
						clockwiseness = "clockwise";
					} else {
						clockwiseness = "counterclockwise";
					}

					float sweptAngle = 0;

					// Calculate angle swept since last frame
					if (circle.State != Gesture.GestureState.STATESTART) {
						CircleGesture previousUpdate = new CircleGesture (controller.Frame(1).Gesture(circle.Id));
						sweptAngle = (circle.Progress - previousUpdate.Progress) * 360;
					}

					SafeWriteLine("Circle id: " + circle.Id
						+ ", " + circle.State
						+ ", progress: " + circle.Progress
						+ ", radius: " + circle.Radius
						+ ", angle: " + sweptAngle
						+ ", " + clockwiseness);
					break;
				case Gesture.GestureType.TYPESWIPE:
					SwipeGesture swipe = new SwipeGesture (gesture);
					SafeWriteLine("Swipe id: " + swipe.Id
						+ ", " + swipe.State
						+ ", position: " + swipe.Position
						+ ", direction: " + swipe.Direction
						+ ", speed: " + swipe.Speed);
					break;
				case Gesture.GestureType.TYPEKEYTAP:
					KeyTapGesture keytap = new KeyTapGesture (gesture);
					SafeWriteLine("Tap id: " + keytap.Id
						+ ", " + keytap.State
						+ ", position: " + keytap.Position
						+ ", direction: " + keytap.Direction);
					break;
				case Gesture.GestureType.TYPESCREENTAP:
					ScreenTapGesture screentap = new ScreenTapGesture (gesture);
					SafeWriteLine("Tap id: " + screentap.Id
						+ ", " + screentap.State
						+ ", position: " + screentap.Position
						+ ", direction: " + screentap.Direction);
					break;
				default:
					SafeWriteLine("Unknown gesture type.");
					break;
			}
		}

		if (!frame.Hands.IsEmpty || !frame.Gestures().IsEmpty) {
			SafeWriteLine("");
		}
	}
}

class Sample
{
	public static void Main ()
	{
		// Create a sample listener and controller
		SampleListener listener = new SampleListener ();
		Controller controller = new Controller ();
	
		// Have the sample listener receive events from the controller
		controller.AddListener(listener);

		// Keep this process running until Enter is pressed
		Console.WriteLine("Press Enter to quit...");
		Console.ReadLine();

		// Remove the sample listener when done
		controller.RemoveListener(listener);
		controller.Dispose();
	}
}

public class Script : ScriptBase, System.IDisposable
{
    
	private bool changed()  // 
	{
		SampleListener listener = new SampleListener();
		Controller controller = new Controller();
	}
    public Script()
    {
		Add controller.AddListener(listener);
        
    }  
    
    public virtual void Dispose()
    {
		controller.RemoveListener(listener); 
		controller.Dispose();
    }
    
    
    public override void Validate()
    {
        
    }
    
 
    public override bool Generate()
    {
		Frame frame = controller.Frame();
		Hand hand = frame.Hands[0];
		FingerList fingers = hand.Fingers;
		Fingers = fingers.Count;
		changed = true;
		
        if (changed)
        {
            changed = false;
            return true;
        }

        return false;
    }
}



Among "Script" class, inside of function Script()
there's " Add controller.AddListener(listener); "

I tried both w/ .Net4.0 and .Net3.5
Neither of them worked. if you can find anything wrong among my code, feel free to let me know. I'm trying to do exactly what you did.
"Fingers, Hands, PosX, PosY, PosZ, Pitch, Roll, Yaw, Circle.Progress, CircleRadius, Swipe.Left, Swipe.Right, Swipe.Up, Swipe.Down & Swipe.Speed."

I'm not a programmer, neither. Let me just keep going. :)

TobiTobsen
Posts: 93
Joined: 18 Jan 2012, 20:02

Re: ...Use LeapMotion in Ventuz

Post by TobiTobsen » 04 Jan 2014, 23:04

Hi,
I played around with the leap, find a quick test attached... Make sure you did install the LeapCSharp.NET4.0.dll to the GAC and copied the other dll's that Erik mentioned to your Ventuz Program folder.
Its all raw data, only hand position of the first hand and rotation as well as rotation of the first two pointables that are detected.
Pointables are still buggy, they jump around, looks like tracking fails at some point... propably on my side :-).

Tobi
Attachments
LeapTestExportS.vza
(16.67 KiB) Downloaded 409 times
http://www.radar-touch.com
http://www.prime-touch.com

Want to filter or transform TUIO data? http://code.google.com/p/tuiotoolbox/
Looking for a tool generating Testpattern for Softedge projections??? I can help: http://code.google.com/p/projection-calc/

TobiTobsen
Posts: 93
Joined: 18 Jan 2012, 20:02

Re: ...Use LeapMotion in Ventuz

Post by TobiTobsen » 04 Jan 2014, 23:27

@divin:
Actually there are a few things not correct in your code...
Try this:

Code: Select all

using System;
using Ventuz.Kernel;
using System;
using System.Threading;
using Leap;

class SampleListener : Listener
{
	private Object thisLock = new Object ();

	private void SafeWriteLine (String line)
	{
		lock (thisLock) {
			//Console.WriteLine(line);
			Ventuz.Kernel.VLog.Info(line); //Printing to Ventuz Messages Window
		}
	}

	public override void OnInit (Controller controller)
	{
		SafeWriteLine("Initialized");
	}

	public override void OnConnect (Controller controller)
	{
		SafeWriteLine("Connected");
		controller.EnableGesture(Gesture.GestureType.TYPECIRCLE);
		controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP);
		controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP);
		controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
	}

	public override void OnDisconnect (Controller controller)
	{
		SafeWriteLine("Disconnected");
	}

	public override void OnExit (Controller controller)
	{
		SafeWriteLine("Exited");
	}

	public override void OnFrame (Controller controller)
	{
		Frame frame = controller.Frame();

		SafeWriteLine("Frame id: " + frame.Id
			+ ", timestamp: " + frame.Timestamp
			+ ", hands: " + frame.Hands.Count
			+ ", fingers: " + frame.Fingers.Count
			+ ", tools: " + frame.Tools.Count
			+ ", gestures: " + frame.Gestures().Count);

		if (!frame.Hands.IsEmpty) {
			Hand hand = frame.Hands[0];

			FingerList fingers = hand.Fingers;
			if (!fingers.IsEmpty) {
				// Calculate the hand's average finger tip position
				Vector avgPos = Vector.Zero;
				foreach (Finger finger in fingers) {
					avgPos += finger.TipPosition;
				}
				avgPos /= fingers.Count;
				SafeWriteLine("Hand has " + fingers.Count
					+ " fingers, average finger tip position: " + avgPos);
			}

			// Get the hand's sphere radius and palm position
			SafeWriteLine("Hand sphere radius: " + hand.SphereRadius.ToString("n2")
				+ " mm, palm position: " + hand.PalmPosition);

			// Get the hand's normal vector and direction
			Vector normal = hand.PalmNormal;
			Vector direction = hand.Direction;

			// Calculate the hand's pitch, roll, and yaw angles
			SafeWriteLine("Hand pitch: " + direction.Pitch * 180.0f / (float) Math.PI + " degrees, "
				+ "roll: " + normal.Roll * 180.0f / (float) Math.PI + " degrees, "
				+ "yaw: " + direction.Yaw * 180.0f / (float) Math.PI + " degrees");
		}

		// Get gestures
		GestureList gestures = frame.Gestures();
		for (int i = 0; i < gestures.Count; i++) {
			Gesture gesture = gestures[i];

			switch (gesture.Type) {
				case Gesture.GestureType.TYPECIRCLE:
					CircleGesture circle = new CircleGesture (gesture);

					// Calculate clock direction using the angle between circle normal and pointable
					String clockwiseness;
					if (circle.Pointable.Direction.AngleTo(circle.Normal) <= Math.PI / 4) {
						//Clockwise if angle is less than 90 degrees
						clockwiseness = "clockwise";
					} else {
						clockwiseness = "counterclockwise";
					}

					float sweptAngle = 0;

					// Calculate angle swept since last frame
					if (circle.State != Gesture.GestureState.STATESTART) {
						CircleGesture previousUpdate = new CircleGesture (controller.Frame(1).Gesture(circle.Id));
						sweptAngle = (circle.Progress - previousUpdate.Progress) * 360;
					}

					SafeWriteLine("Circle id: " + circle.Id
						+ ", " + circle.State
						+ ", progress: " + circle.Progress
						+ ", radius: " + circle.Radius
						+ ", angle: " + sweptAngle
						+ ", " + clockwiseness);
					break;
				case Gesture.GestureType.TYPESWIPE:
					SwipeGesture swipe = new SwipeGesture (gesture);
					SafeWriteLine("Swipe id: " + swipe.Id
						+ ", " + swipe.State
						+ ", position: " + swipe.Position
						+ ", direction: " + swipe.Direction
						+ ", speed: " + swipe.Speed);
					break;
				case Gesture.GestureType.TYPEKEYTAP:
					KeyTapGesture keytap = new KeyTapGesture (gesture);
					SafeWriteLine("Tap id: " + keytap.Id
						+ ", " + keytap.State
						+ ", position: " + keytap.Position
						+ ", direction: " + keytap.Direction);
					break;
				case Gesture.GestureType.TYPESCREENTAP:
					ScreenTapGesture screentap = new ScreenTapGesture (gesture);
					SafeWriteLine("Tap id: " + screentap.Id
						+ ", " + screentap.State
						+ ", position: " + screentap.Position
						+ ", direction: " + screentap.Direction);
					break;
				default:
					SafeWriteLine("Unknown gesture type.");
					break;
			}
		}

		if (!frame.Hands.IsEmpty || !frame.Gestures().IsEmpty) {
			SafeWriteLine("");
		}
	}
}



public class Script : ScriptBase, System.IDisposable
{
	SampleListener listener;
	Controller controller;
	private bool changed;  //
	
	public Script()
	{
		listener = new SampleListener();
		controller = new Controller();
		controller.AddListener(listener); 
	} 
   
	public virtual void Dispose()
	{
		controller.RemoveListener(listener);
		controller.Dispose();
	}
   
   
	public override void Validate()
	{
}
 
	public override bool Generate()
	{		
		if (changed)
		{
			changed = false;
			return true;
		}
		return false;
	}
}
http://www.radar-touch.com
http://www.prime-touch.com

Want to filter or transform TUIO data? http://code.google.com/p/tuiotoolbox/
Looking for a tool generating Testpattern for Softedge projections??? I can help: http://code.google.com/p/projection-calc/

divin
Posts: 11
Joined: 28 Mar 2012, 02:53
Location: korea
Contact:

Re: ...Use LeapMotion in Ventuz

Post by divin » 07 Jan 2014, 08:17

hi, Tobi
thx for your posting.

I can see LeapCSharp.NET4.0 when I left-click on GAC Assemblies in script editor(C# node).
Does this mean I already add that dll file on GAC ?
If so, I think the vza what you upload must work with LeapMotion.

There's no problem when I use my LeapMotion via LeapMotionAirspace, which means LeapMotion is properly connected and works well.
Are you using 32 bit ventuz ? Is yours Ventuz3 or 4 ?
I'm doing with V4 64bit.
Does this matter?

Do I need to pay if I want to open your sealed node?
You can send me private message. :)
thx

TobiTobsen
Posts: 93
Joined: 18 Jan 2012, 20:02

Re: ...Use LeapMotion in Ventuz

Post by TobiTobsen » 07 Jan 2014, 20:51

Hi divin,
if you can see the .DLL in the script editor, the installation in gac was successful.
Did you copy the other DLL files (the ones that Erik mentioned) in the ventuz installation folder?

I am using win 7, 64 bit. Ventuz 4.
You have to make sure that you copy the correct DLL files depending on your operating system (32 or 64 bit).

If you open the scene I uploaded, right click on message window in ventuz and set message level to info. Now you see what happens in my script.
Clicking on the node, you see a start and stop event. Press start and check the messages.
What happens?

Cheers, Tobi
http://www.radar-touch.com
http://www.prime-touch.com

Want to filter or transform TUIO data? http://code.google.com/p/tuiotoolbox/
Looking for a tool generating Testpattern for Softedge projections??? I can help: http://code.google.com/p/projection-calc/

divin
Posts: 11
Joined: 28 Mar 2012, 02:53
Location: korea
Contact:

Re: ...Use LeapMotion in Ventuz

Post by divin » 09 Jan 2014, 09:05

I found the answer.
I put all the dll files ONLY except LeapCSharp.dll

thanks for your post Tobi :)

TobiTobsen
Posts: 93
Joined: 18 Jan 2012, 20:02

Re: ...Use LeapMotion in Ventuz

Post by TobiTobsen » 13 Jan 2014, 21:17

Perfect :-)
http://www.radar-touch.com
http://www.prime-touch.com

Want to filter or transform TUIO data? http://code.google.com/p/tuiotoolbox/
Looking for a tool generating Testpattern for Softedge projections??? I can help: http://code.google.com/p/projection-calc/

sheRRin

Re: ...Use LeapMotion in Ventuz

Post by sheRRin » 06 Aug 2014, 08:31

hi,
was having this error working with leap motion

3:20 PM 8/6/2014 Error : Script (C#.net Script): Script Validation failed: Exception has been thrown by the target of an invocation. / The type initializer for 'Leap.LeapPINVOKE' threw an exception. / The type initializer for 'SWIGExceptionHelper' threw an exception. / Unable to load DLL 'LeapCSharp': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Post Reply