Kinect input to Unity3d output - c#

I'm creating the Game using "Kinect xbox 360" and Unity3d. I have created the link between Kinect and Unity so that the character in Unity3d do the same actions[Movements] that what we do from Kinect sensor.
Now my question is how to take that actions[Movements] as input for UNITY3d?
For Example: If I do up my Right hand the character will walk or run or jump whatever it's.
How can I check that Hand is Moved up in Script [ UnityScript or C# ]
For Example :
if(GameObject.transform == "RightHand")
{
------------------------
------------------------
}
I searched out all sites through google but No result....
I have connected the Kinect through ZIGFU with Unity3d.
Lets see which Adroit will answer for this . . .!

Well, that heavily depends on the gesture you want to check for. There also is an SDK that comes with some gestures to recognize. Have a look at the code: https://www.assetstore.unity3d.com/#/content/7747
An example: You want to check for a hand being held up. Get the object of a handbone and check if it stays over a certain value of the z axis for a couple of milliseconds or seconds.

Related

How to access the HoloLens2 Origin SpatialCoordinateSystem

The problem:
I've been working on trying to create a 3D position in Worldspace based on a 2D face RGB face detection, similar to this Microsoft example. I am using Unity 2020.3.16f1, MRTK 2.8.2 and C# for the Unity scripts. I have been able to convert the C++ code shown in the link to C# with a lot of success. One final issue is accessing the HoloLens 2 origin SpatialCoordinateSystem to be used in the Transform between the camera's 2D coordinate system and the 3D worldspace system.
The SO question at this link asks a very similar question, and I have tried to use SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem() as the answers suggest. I call this function in Unity's "Awake" method, to ensure it is set as early as possible, as shown below.
private void Awake()
{
worldSpatialCoordinateSystem = SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation().CoordinateSystem;
}
Problem is that, if the user's headset is moving while the application starts, I notice an offset in the 3D locations commensurate with the direction/position of the head when the application was starting. I have narrowed the problem down to the fact that the HL2 and Unity set an origin SpatialCoordinateSystem just before the function in Awake is called, accounting for the offset between what I expect and what I see.
What I've tried:
I have tried using some of the other solutions listed here as well. I cannot use UnityEngine.Windows.WebCam.PhotoCapture becuase of the way I am create still image captures, and (SpatialCoordinateSystem)Marshal.GetObjectForIUnknown(WorldManager.GetNativeISpatialCoordinateSystemPtr()) appears to be deprecated and unusable. Finally, I tried CreateStationaryFrameOfReferenceAtCurrentLocation(Vector3, Quaternion), and used the inverse of the current Camera.main position and rotation, hoping to compensate for the offset, but it did not appear to work (NumericsConversionExtensions is the UnityEngine-to-System.Numerics converver found here). That code is below.
worldSpatialCoordinateSystem = SpatialLocator.GetDefault().CreateStationaryFrameOfReferenceAtCurrentLocation(NumericsConversionExtensions.ToSystem(Camera.main.transform.position*-1),
NumericsConversionExtensions.ToSystem(Quaternion.Inverse(Camera.main.transform.rotation))).CoordinateSystem;
My question:
Is there either another way to access the origin spatial coordinates or possibly to compensate for the offset when the user is moving their head before Awake is called?
I spent 3 days working on the solution, and found one 1 hour after asking SO. For those who come here, use the code below, originally found here.
using Microsoft.MixedReality.OpenXR;
worldSpatialCoordinateSystem = PerceptionInterop.GetSceneCoordinateSystem(Pose.identity) as SpatialCoordinateSystem;

How to create 2D image in Console without using any existing solutions in C#?

I'm beginner in programming
So, I want to reinvent the wheel. I'm planing to create my own 2D game like Mario etc using only Console in C#. My question is, how to create/draw pixels in Console to make an image? Or the only way is to use Unicode characters?
I know that Mario(or any other games like it) was created on assembly language (of cource without any libs like OpenGL =) ).
Is it possible to create something like that on C#?
I don't want to use WinForms apps, Unity, OpenGL etc etc etc
You can print only characters to the console.
Box-drawing characters allow you to create frames and other primitive geometric forms. Examples:
│ ┃ ┄ ┅ ┆ ┇ ┈ ┉ ┊ ┋ ┌ ┍ ┎ ┏
┐ ┑ ┒ ┓ └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟
┠ ┡ ┢ ┣ ┤ ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┯
┰ ┱ ┲ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ┼ ┽ ┾ ┿
╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╌ ╍ ╎ ╏
═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟
╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ╭ ╮ ╯
With ASCII Art you print charaters with different densities of to create shadings. (Art by Normand Veilleux, detail)
_______
_,,ad8888888888bba,_
,ad88888I888888888888888ba,
,88888888I88888888888888888888a,
,d888888888I8888888888888888888888b,
d88888PP"""" ""YY88888888888888888888b,
,d88"'__,,--------,,,,.;ZZZY8888888888888,
,8IIl'" ;;l"ZZZIII8888888888,
,I88l;' ;lZZZZZ888III8888888,
,II88Zl;. ;llZZZZZ888888I888888,
,II888Zl;. .;;;;;lllZZZ888888I8888b
,II8888Z;; `;;;;;''llZZ8888888I8888,
II88888Z;' .;lZZZ8888888I888b
II88888Z; _,aaa, .,aaaaa,__.l;llZZZ88888888I888
II88888IZZZZZZZZZ, .ZZZZZZZZZZZZZZ;llZZ88888888I888,
II88888IZZ<'(##>Z| |ZZZ<'(##>ZZZZ;;llZZ888888888I88I
,II88888; `""" ;| |ZZ; `""" ;;llZ8888888888I888
II888888l `;; .;llZZ8888888888I888,
,II888888Z; ;;; .;;llZZZ8888888888I888I
III888888Zl; .., `;; ,;;lllZZZ88888888888I888
II88888888Z;;...;(_ _) ,;;;llZZZZ88888888888I888,
II88888888Zl;;;;;' `--'Z;. .,;;;;llZZZZ88888888888I888b
]I888888888Z;;;;' ";llllll;..;;;lllZZZZ88888888888I8888,
II888888888Zl.;;"Y88bd888P";;,..;lllZZZZZ88888888888I8888I
II8888888888Zl;.; `"PPP";;;,..;lllZZZZZZZ88888888888I88888
II888888888888Zl;;. `;;;l;;;;lllZZZZZZZZW88888888888I88888
`II8888888888888Zl;. ,;;lllZZZZZZZZWMZ88888888888I88888
II8888888888888888ZbaalllZZZZZZZZZWWMZZZ8888888888I888888,
`II88888888888888888b"WWZZZZZWWWMMZZZZZZI888888888I888888b
`II88888888888888888;ZZMMMMMMZZZZZZZZllI888888888I8888888
`II8888888888888888 `;lZZZZZZZZZZZlllll888888888I8888888,
II8888888888888888, `;lllZZZZllllll;;.Y88888888I8888888b,
,II8888888888888888b .;;lllllll;;;.;..88888888I88888888b,
II888888888888888PZI;. .`;;;.;;;..; ...88888888I8888888888,
or outlines (example by ejm97)
w c(..)o (
\__(-) __)
/\ (
/(_)___)
w /|
| \
m m
You can set the cursor position with
Console.SetCursorPosition(left, top);
and also set foreground/background colors, console size etc.
You can only print characters. Here i suggest an architecture for coding your game:
Design the whole game map as a 2D integer array, rows and columns. Each value define the block, it can be empty or can be an obstacle or a coin. For example, "0" is nothing, means in this area there is no block. "1" is a block, and "2" is a coin. Here is a sample of the array:
[0][0,0,0,0,0]
[1][0,2,0,0,0]
[2][1,1,1,1,1]
This array defines the game map. In rendered output (witch i will explain) we have this:
O
[][][][][]
The brackets are blocks that the game character can walk on them. And the "O" is the coin that character can collect it. And the first row we have nothing, as we defines it in our array.
After we built our game map, we need to update frames of game.
We need to update frames when player pushed a button. For that, we need a layer of program to parse array to characters, it can be a method witch take the array as parameter and return a string of output value.
For the next layer, after player pushed button and the frame updated, we have to update the current position of the game character, for example, character is in "row 1" and "column 0" before player push a button. The player push the Right button, so we have to move the character to "row 1" and "column 1".
As i said, when character moved by player, we need a layer to recognize the character and is he crashed to a obstacle or coin? In above example, our character reached to the coin position on the map, so in this layer of process, we have to increase player coins.
This is a very very simple example of an architecture of a console game. Of course you need to work on details and codes and create something funny :) . I hope it helped;

3rd person character not moving in unity.

I have imported Unity Standard assets to Unity 5.6.0, I drag the 3rd person character to the scene, it keeps animating but it does not move on AWSD or Left/Right keys.
This is happening in only one project, it works on all other projects. I have searched from the net, but non of the solution seems to work.
Just try to reimport the asset with the unity third-person controller the import could have gone wrong in some place or try to build the game under build settings to see if that helped
Your character controller is made up of multiple pieces (animation files/model/script and possibly other files). There could be a problem with how you are loading the 3rd person character to the scene. I would try creating a prefab of the 3rd person character within a project and then export it as a prefab. Could be missing the script attached to the object as well. The prefab helps prevent you leaving any pieces behind that make up your character/objects. Helpful for level construction as well.
Take a look here if it helps: https://docs.unity3d.com/Manual/Prefabs.html
Another possible explanation could be how you have your input settings setup within that Unity Project. Try comparing the two inputs of the working instance, and the non-working instance.
Try looking here for a more detailed approach : https://docs.unity3d.com/Manual/class-InputManager.html
I had this problem too and in the end it was because I had my project set up to run on IOS in Build Settings. I Switched Platform to macOS and it worked.
Why? It seems that Unity's Virtual Controller expected the input to be from a Mobile Device (seems obvious now) and the CrossPlatformInputManager was not expecting WSAD.
A workaround in IOS mode is to edit the ThirdPersonCharacter/Scripts/ThirdPersonUserControl.cs and replace the ThirdPersonUserControl.cs with Input
e.g.
// read inputs
//float h = CrossPlatformInputManager.GetAxis("Horizontal");
//float v = CrossPlatformInputManager.GetAxis("Vertical");
// read inputs from default input
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
I found this when I was digging around an realised the Update function in the script was getting called, however CrossPlatformInputManager.GetAxis("Horizontal") was always returning 0.
It might be worth inspecting both at runtime.
i had the same issue today, even though this thread is ancient.
for me it was because i was using my own camera and did not have the "MainCamera" tag set on it.

Visualize x-y-z position

I use a Kinect SDK V2 sensor to capture point cloud.The output of my program is a double array that contains X-Y-Z position points for every frame(0,0,0 is the center of the sensor). Now i would like to visualize the data for example for one frame. Is any fast/easy way just to visualize the data?Any .dll?
P.S:I tried with Unity but it was to difficult and time consuming for me.I thought that code does not need it because question it too general(if code would be helpful i could upload parts).
Thank you

filter pornography in a video/picture c# library

How can you filter pornography in a video/picture?
Is there a library I can use? Commercial or open source is OK.
For Video:
You would analyze the sound waves from the video. If there's lot of grunting and moans, find a way to recognize those patterns and label it as porn. However, you might get false tags for women's tennis match.
For Image:
Build a simulation model of a human brain which signals arousal from viewing erotic pictures. Some paramters would be excessive curves, and image recognition of the human anatomy. This is far more difficult.
If it is not a real-time, you could use Amazon's Mechanical Turk to do the work. You'll have to pay the workforce, but it's a very cheap way to get menial jobs like this done.
See, Porn Detection is not a very easy.
But there is surely a range of color that identifies the human skin. And you need to make a threshold of the color to identify the picture as porn. Say you take it as 70 %, so you go through all the pixel on the current screen and determine whether 70% of the pixels comes within the range of human skin color.
There is already few algorithm prepared for Face detection like :
http://www.codeproject.com/KB/cs/Face_Detection_processing.aspx
I hope this would help you to find a way on your point.

Categories