Je vous écris une application qui nécessite la suppression de fond (où le joueur est), et masquer le corps de l'utilisateur avec une couleur ou un caractère (comme https://stackoverflow.com/questions/10599658/how-to-create-kinect-avatar).
Merci à l'avanceKinect Couleur du corps
1
A
Répondre
0
Le tutoriel à Channel 9, même si l'ancien est en version bêta 2, est facile à convertir. Voici le code final (converti)
public static class KinectExtensions
{
public static WriteableBitmap CreateLivePlayerRenderer(this KinectSensor sensor)
{
if (sensor.DepthStream.FrameWidth == 0)
throw new InvalidOperationException("Either open the depth stream before calling this method or use the overload which takes in the resolution that the depth stream will later be opened with.");
return CreateLivePlayerRenderer(sensor, sensor.DepthStream.FrameWidth, sensor.DepthStream.FrameHeight);
}
public static WriteableBitmap CreateLivePlayerRenderer(this KinectSensor sensor, int depthWidth, int depthHeight)
{
AllFramesReadyEventArgs d = new AllFramesReadyEventArgs();
using (DepthImageFrame depthImage = d.OpenDepthImageFrame())
{
WriteableBitmap target = new WriteableBitmap(depthWidth, depthHeight, 96, 96, PixelFormats.Bgra32, null);
var depthRect = new System.Windows.Int32Rect(0, 0, depthWidth, depthHeight);
sensor.DepthFrameReady += (s, e) =>
{
Debug.Assert(depthImage.Height == depthHeight && depthImage.Width == depthWidth);
};
sensor.ColorFrameReady += (s, e) =>
{
// don't do anything if we don't yet have a depth image
DepthImageFrame colorImage = depthImage;
if (colorImage.BytesPerPixel == null) return;
byte[] color = new byte[sensor.ColorStream.FramePixelDataLength];
e.OpenColorImageFrame().CopyPixelDataTo(color);
byte[] output = new byte[depthWidth * depthHeight * 4];
// loop over each pixel in the depth image
int outputIndex = 0;
for (int depthY = 0, depthIndex = 0; depthY < depthHeight; depthY++)
{
for (int depthX = 0; depthX < depthWidth; depthX++, depthIndex += 2)
{
short[] bits = new short[colorImage.BytesPerPixel];
depthImage.CopyPixelDataTo(bits);
// combine the 2 bytes of depth data representing this pixel
short depthValue = (short)(bits[depthIndex] | (bits[depthIndex + 1] << 8));
// extract the id of a tracked player from the first bit of depth data for this pixel
int player = bits[depthIndex] & 7;
// find a pixel in the color image which matches this coordinate from the depth image
int colorX, colorY;
ColorImagePoint colorPoint = depthImage.MapToColorImagePoint(depthImage.Width, depthImage.Height, sensor.ColorStream.Format);
// ensure that the calculated color location is within the bounds of the image
colorX = colorPoint.X;
colorY = colorPoint.Y;
output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 0];
output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 1];
output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 2];
output[outputIndex++] = player > 0 ? (byte)255 : (byte)0;
}
}
target.WritePixels(depthRect, output, depthWidth * PixelFormats.Bgra32.BitsPerPixel/8, 0);
};
return target;
}
}
}
Et ma réponse à https://stackoverflow.com/questions/10599658/how-to-create-kinect-avatar/10600919#10600919 explique comment créer le caractère. Bonne chance! J'espère que cela t'aides!
Questions connexes
- 1. Kinect Couleur Frame Form
- 2. IE8 CSS Couleur du fond du corps
- 3. Modifier la couleur du corps UIPickerView
- 4. Kinect V2 SDK 2 ré-identifier les corps
- 5. Flux de couleur rouge séparé du flux vidéo de caméra couleur Microsoft Kinect
- 6. changer la couleur du fond du corps contenu dans wordpress
- 7. Kinect One & Unity - numéro de cadre BodyIndexSource, dessinant une "ombre du corps" en utilisant le BodyIndexSource
- 8. Réutilisation du code Kinect v1 avec Kinect v2
- 9. Kinect reconnaissance de geste
- 10. changer la couleur du corps sur le changement de diapos
- 11. Couleur d'arrière-plan du corps basée sur les pixels
- 12. enlever la couleur de fond du corps de iframe
- 13. Kinect SDK: aligner les trames de profondeur et de couleur
- 14. Enregistrer une vidéo couleur et profondeur KINECT C#
- 15. Afficher l'image couleur en kinect en plein écran
- 16. Utilisation de kinect sdk sans caméra kinect
- 17. Kinect Hand Gestures
- 18. Kinect Audio avec Kinect SDK et C++
- 19. Peinture Kinect C#, WPF, SDK Kinect
- 20. Chargement de l'animation de Kinect dans Unity3D
- 21. Utilisation de LESS & jQuery pour changer la couleur du texte du corps en fonction de la couleur d'arrière-plan?
- 22. La couleur d'arrière-plan du pied de page n'est pas la même que celle du corps
- 23. MFC & Kinect: tracer une ligne sur l'image de Kinect
- 24. Comment zoomer Caméra Kinect?
- 25. Longueur du corps FLV
- 26. Mesure dans Kinect
- 27. Kinect SDK 1.0 namespaces
- 28. Threading avec le Kinect
- 29. Body Kinect Tracking GetAndRefreshBodyData renvoie l'erreur
- 30. Plusieurs Kinect utilisant Kinect pour Windows SDK 1.5
Je ne comprends absolument pas ce dont vous avez besoin – Fixus
Voir http://channel9.msdn.com/coding4fun/kinect/Display-Kinect-color-image-containing-only-players-aka-background-removal et http : //stackoverflow.com/questions/10599658/how-to-create-kinect-avatar/10600919#10600919 –
@ravithejag: Les gens vous downvoting parce que vous ne l'avez pas posé une question. Quel est le problème? Quel est le problème? Qu'essayez-vous de faire avec? Qu'avez-vous essayé? Quel code as-tu essayé? –