Kinect 4 Windows v2.0 Plugin

[=Ingrid W.;370053]
Thanks for the fast response.
But I’m still getting the same compiling error in VS…
[/]

Any chance that you have an instance of the engine running? I know this is strange question but I think I encountered it before on my machine.

[=;370056]
Any chance that you have an instance of the engine running? I know this is strange question but I think I encountered it before on my machine.
[/]

Not exactly sure what you mean with “an instance of the engine running”, but the engine I use is the Released binary, installed by the Launcher, and I don’t have other custom built engines.

This same issue will also occur when I don’t have any other Unreal projects or editor running at the time.

In visual right click KinectDemoRoom project and click on rebuild.

[=;369575]
You gave me some material to think about and I just tested a new method of retrieving camera frames, and from what I see here it boosted the performance by about 20 FPS.
I did so by completely throwing away the update events and therefore the scope locks
Now you retrieve the camera data by getting a pointer to a texture that is being updated directly from the sensor thread by enqueuing the texture update in the rendering thread.
The next step would be to broadcast an event from the rendering after which you would be able to access the data safely (this is similar to the OnHud event).

You can find it here (the body index frame is still using the old model, will update it later today).
[/]

Awesome.
This is might be scary for some but in my opinion is much more understandable. we can in this way get read of the middle texture too. Just amazing

hi:)
tnx for your awesome work!
i have downloaded the demo and the movement of hand ang leg bones work fine but the spine, head, neck and foot doesn’t work
can you help me with them?

hello lion
tnx for your awesome work!
i have downloaded the demo and it works fine with legs and arms but the spine and head neck foot doesn’t work
can you help me with them?

[=;361531]
Hey All!

So I know I am promising you 4.8 for a while but due to time it took to fix various performance issue, better avateering support the up coming 4.9 I skipped 4.8 and ported the plugin to 4.9.

Also there is a new example demo room, it is still wip but I know you waited for a long time for it so there it is:

You will need the latest 4.9 engine to build it.

Enjoy!
[/]

Am I correct to assume that since the texture you populate is of a type RGBQUAD then the 13bits of information are spread between R and G since in RGBQUAD the size for each color component is one byte and kinect data needs two ?

[=;370080]
In visual right click KinectDemoRoom project and click on rebuild.
[/]

Hi Leon032,
I have notice that in your code you actually put away 8 bits of the depth data which is quite crucial for my project since I need to measure the exact distance.
however when I try to pass the other 8 byte to the green channel, and compile it nothing changes in the project. do you have any idea by any chance ?
here is the section of the code I am talking about.

// To convert to a byte, we’re discarding the most-significant
// rather than least-significant bits.
// We’re preserving detail, although the intensity will “wrap.”
// Values outside the reliable depth range are mapped to 0 (black).

		// Note: Using conditionals in this loop could degrade performance.
		// Consider using a lookup table instead when writing production code.
	BYTE intensity = static_cast<BYTE>((depth >= minDepth) && (depth <= maxDepth) ? (depth % 256) : 0);

	pRGBX->rgbRed = intensity;
	pRGBX->rgbGreen = intensity;
        pRGBX->rgbBlue = intensity;

Hi Leon32

Another question : I cannot use kinect when I run the game in the standalone mode. do you know what could be the cause ?
thanks

Dose it work in Editor mode?

[=;386072]
Dose it work in Editor mode?
[/]

yeap. it just workin editor mode. for you everything is ok ?

[=plangton;386102]
yeap. it just workin editor mode. for you everything is ok ?
[/]

I think the issue could be that I have to compile the plugin in the development mode too, because now it is just compiled in Development_editor
last night I started porting to your new update and I should say it is very cool. It is good that now some pooling method is there too.
Additionally I wanted to suggest something forr you plugin:

instead of the following section for normalizing the depth
BYTE intensity = static_cast<BYTE>((depth >= minDepth) && (depth <= maxDepth) ? (depth % 256) : 0);

		pRGBX-&gt;rgbRed = intensity;
		pRGBX-&gt;rgbGreen = intensity;
		pRGBX-&gt;rgbBlue = intensity;

I suggest the following
BYTE intensity = static_cast<BYTE>((depth >= minDepth) && (depth <= maxDepth) ? (depth % 256) : 0);

		pRGBX-&gt;rgbRed = depth % 256;
		pRGBX-&gt;rgbGreen = depth / 256;
		pRGBX-&gt;rgbBlue = intensity;

this way the user has access to both real depth of each pizel and a normalized value.
rgbRed will be the low byte and rgbGreen the high value byte and rgbBlue the normalized one.

we can even first shift the data by 3 bytes to right and then do this. like the following, and after ***

         depth =  ( 0x1FFF & depth ) &gt;&gt; 3;
         BYTE intensity = static_cast&lt;BYTE&gt;((depth &gt;= minDepth) && (depth &lt;= maxDepth) ? (depth % 256) : 0);

     pRGBX-&gt;rgbRed = depth % 256;
         pRGBX-&gt;rgbGreen = depth / 256;
     pRGBX-&gt;rgbBlue = intensity;

Hello ,

I wonder if you provide the Kinect V2 plugin for unreal engine 4.8 now? Thanks a lot!

[=Willlee95;386479]
Hello ,

I wonder if you provide the Kinect V2 plugin for unreal engine 4.8 now? Thanks a lot!
[/]

I am using the plugin via 4.8 . you need to do the following modification for it to work

in /Plugins/KinectV2/Source/KinectV2/KinectV2.Build.cs comment “AnimGraphRuntime”
in /Plugins/KinectV2/Source/KinectV2Editor/KinectV2Editor.Build.cs comment “BlueprintGraph”,“AnimGraph”,“AnimGraphRuntime”,
in /Plugins/KinectV2/Source/KinectV2Editor/Private/KinectV2EditorModulePCH.h comment #include “AnimGraphDefinitions.h” #include “Kismet2/BlueprintEditorUtils.h” #include “AnimGraphNode_SkeletalControlBase.h” #include “AnimGraphNode_KinectV2Retarget.h”

then you can simply go to visual and combile your project from there. restart UE4 and everything should be fine

[=plangton;386501]
I am using the plugin via 4.8 . you need to do the following modification for it to work

in /Plugins/KinectV2/Source/KinectV2/KinectV2.Build.cs comment “AnimGraphRuntime”
in /Plugins/KinectV2/Source/KinectV2Editor/KinectV2Editor.Build.cs comment “BlueprintGraph”,“AnimGraph”,“AnimGraphRuntime”,
in /Plugins/KinectV2/Source/KinectV2Editor/Private/KinectV2EditorModulePCH.h comment #include “AnimGraphDefinitions.h” #include “Kismet2/BlueprintEditorUtils.h” #include “AnimGraphNode_SkeletalControlBase.h” #include “AnimGraphNode_KinectV2Retarget.h”

then you can simply go to visual and combile your project from there. restart UE4 and everything should be fine
[/]

Thank you I really appreciate your help.

@

Hi,
I was testing with your new modification but I faced some problems. I thought first you made some polling functionality but since the access will be given to the texture of kinect directly the issue is that I cannot freeze the texture to be able to manipulate it.
neither I managed to lock it to be able to make a snapshot and work on that. how then do you solve a issue if I want to read one frame and process that then read the next.

Sorry for the delay, I have pretty busy week fortunately there is a holiday till the end of the week and hope to get to all of your issues by the weekend :slight_smile:

[=;388232]
Sorry for the delay, I have pretty busy week fortunately there is a holiday till the end of the week and hope to get to all of your issues by the weekend :slight_smile:
[/]

Hi ,
I think the issue with multithreading with your plugin comes from this section :
if (pTexture && pData){

	UTexture2D* Texture = pTexture;
	
	const size_t Size = SizeX * SizeY* sizeof(RGBQUAD);

	uint8* Src = (uint8*)pData;

	uint8* Dest = (uint8*)Texture-&gt;PlatformData-&gt;Mips[0].BulkData.Lock(LOCK_READ_WRITE);

	FMemory::Memcpy(Dest, Src, Size);

	Texture-&gt;PlatformData-&gt;Mips[0].BulkData.Unlock();

//here is the issue ;

	Texture-&gt;UpdateResource();

}

so when the texture is getting unlocked with your code it might jump to another thread (like mine ) which locks the texture and then upon jumping back to this code since it wants to update the resources and the texture is locked then what happens is a deadlock. I suggest two solution, whether a polling functionality for reading the frames, or having an accessible lock that I make sure update resource is already done

This section is inactive in the new threading modle

[=;391522]
This section is inactive in the new threading modle
[/]

yes But as I mentioned before your new model is not an actual polling as well, which causes complication too.
so I will get a texture, and for working on it in a another thread I have to make another copy from it which since it is constantly getting updated it is tricky too.
what is your suggestion for the new plugin ?