Kinect test v2 jouer de la music avec kinect

Description

voila une petit évolution grâce au mouvement que on fait on peu faire des note de music dans le programme c'est le buzzer qui fait les note, j'en et mi 3 pour commencer do re mi j'arrive a faire au claire de la lune avec sans fausse note ,si vous étés motivée a m'aider a améliorer le code car il y a des partie c'est vraiment pas fiable du tout mai cela fonctionne donc vila
j'attends vos commentaire avec impatience

cordialement FFcast

Source / Exemple :


unit kinect;

interface

uses Windows, Graphics;

type
  CLNUIMotor = record
    Handle: ^integer;
  end;

type
  CLNUICamera = record
    Handle: ^integer;
  end;

type
  pLigScan = ^tLigScan;
  tLigScan = array [Word] of TRGBTriple;

type
  CLNUIDepth = record
    tableau: array [0 .. 640, 0 .. 480] of ^byte;
  end;

type
  CLNUIcolor = record
    tableau: array [0 .. 640, 0 .. 480] of ^byte;
  end;

function CreateNUIMotor(): CLNUIMotor; cdecl; external 'CLNUIDevice.dll';
function CreateNUICamera(): CLNUICamera; cdecl; external 'CLNUIDevice.dll';
function DestroyNUIMotor(Pointe: CLNUIMotor): Boolean; cdecl;
external 'CLNUIDevice.dll';
function DestroyNUICamera(Pointe: CLNUICamera): Boolean; cdecl;
external 'CLNUIDevice.dll';
function GetNUIMotorSerial(Pointe: CLNUIMotor): Pansichar; cdecl;
external 'CLNUIDevice.dll';
function SetNUIMotorPosition(Pointe: CLNUIMotor; Valeur: integer): Boolean;
  cdecl; external 'CLNUIDevice.dll';
function GetNUIMotorAccelerometer(Pointe: CLNUIMotor; var Valeur_X: short;
  var Valeur_Y: short; var Valeur_Z: short): Boolean; cdecl;
external 'CLNUIDevice.dll';
function SetNUIMotorLED(Pointe: CLNUIMotor; Valeur_Led: byte): Boolean; cdecl;
external 'CLNUIDevice.dll';
function StartNUICamera(Pointe: CLNUICamera): Boolean; cdecl;
external 'CLNUIDevice.dll';
function StopNUICamera(Pointe: CLNUICamera): Boolean; cdecl;
external 'CLNUIDevice.dll';
function GetNUICameraDepthFrameRAW(Pointe: CLNUICamera; var pData: CLNUIDepth;
  waitTimeout: integer = 2000): Boolean; cdecl; external 'CLNUIDevice.dll';
function GetNUICameraDepthFrameRGB32(Pointe: CLNUICamera;
  var pData: CLNUIDepth; waitTimeout: integer = 2000): Boolean; cdecl;
external 'CLNUIDevice.dll';
function GetNUICameraColorFrameRAW(Pointe: CLNUICamera; var pData: CLNUIcolor;
  waitTimeout: integer = 2000): Boolean; cdecl; external 'CLNUIDevice.dll';
function GetNUICameraColorFrameRGB24(Pointe: CLNUICamera;
  var pData: CLNUIcolor; waitTimeout: integer = 2000): Boolean; cdecl;
external 'CLNUIDevice.dll';
function GetNUICameraColorFrameRGB32(Pointe: CLNUICamera;
  var pData: CLNUIcolor; waitTimeout: integer = 2000): Boolean; cdecl;
external 'CLNUIDevice.dll';

procedure BytesArrayToBitmapDepth(const BytesArray: CLNUIDepth;
  const w, h: integer; Bitmap: TBitmap);
procedure BytesArrayToBitmapColor(const BytesArray: CLNUIcolor;
  const w, h: integer; const PixelFormat: TPixelFormat; Bitmap: TBitmap);
procedure RotationPicture(PictureSource, PictureCible: TPicture);
procedure BmpCopierSauf(const bmpSrc: TPicture; Seuil: integer;
  bmpfinal: TPicture);

// var

implementation

uses unit1;

procedure BmpCopierSauf(const bmpSrc: TPicture; Seuil: integer;
  bmpfinal: TPicture);
var
  X, Y: integer;
  LigS, LigD: pLigScan;
  Coleur: Tcolor;
  imgtempon: TBitmap;
begin
  if bmpSrc = nil then
    EXIT;
  imgtempon := TBitmap.Create;
  with imgtempon do
  begin
    PixelFormat := pf24Bit;
    width := bmpSrc.width;
    height := bmpSrc.height;
  end;
  try
    for Y := 0 to bmpSrc.height - 1 do
    begin
      LigS := bmpSrc.Bitmap.ScanLine[Y];
      LigD := imgtempon.ScanLine[Y];
      for X := 0 to bmpSrc.width - 1 do
      begin
        Coleur := RGB(LigS[X].rgbtRed, LigS[X].rgbtGreen, LigS[X].rgbtBlue);
        LigD[X].rgbtBlue := 0;
        LigD[X].rgbtGreen := 0;
        LigD[X].rgbtRed := 0;
        if (Coleur >= Seuil) then
        begin
          LigD[X] := LigS[X];
        end;
        if (Coleur >= Seuil + 1) then
        begin
          LigD[X].rgbtBlue := 255;
          LigD[X].rgbtGreen := 0;
          LigD[X].rgbtRed := 0;
        end;
      end;
    end;
    bmpfinal.Assign(imgtempon);
  finally
    imgtempon.Free;
  end;
end;

procedure RotationPicture(PictureSource, PictureCible: TPicture);
type
  TRGBArray = ARRAY [0 .. 10000] of TRGBTriple;
  pTRGBArray = ^TRGBArray;
  TArrayLigneCible = Array [0 .. 10000] of pTRGBArray;
var
  BmpTempSource, BmpTemCible: TBitmap;
  X, Y: integer;
  LigneSource, LigneCible: pTRGBArray;
begin
  BmpTempSource := TBitmap.Create;
  BmpTemCible := TBitmap.Create;
  try
    BmpTempSource.Assign(PictureSource.Graphic);
    BmpTempSource.PixelFormat := pf24Bit;
    BmpTemCible.PixelFormat := pf24Bit;
    BmpTemCible.height := BmpTempSource.height;
    BmpTemCible.width := BmpTempSource.width;
    for Y := 0 to BmpTempSource.height - 1 do
    begin
      LigneSource := BmpTempSource.ScanLine[Y];
      LigneCible := BmpTemCible.ScanLine[BmpTempSource.height - Y - 1];
      for X := 0 to BmpTempSource.width - 1 do
      begin
        LigneCible[X] := LigneSource[BmpTempSource.width - 1 - X];
      end;
    end;
    PictureCible.Assign(BmpTemCible);
  finally
    BmpTempSource.Free;
    BmpTemCible.Free;
  end;
end;

procedure BytesArrayToBitmapColor(const BytesArray: CLNUIcolor;
  const w, h: integer; const PixelFormat: TPixelFormat; Bitmap: TBitmap);
var
  TBmp: TBitmap;
  pX: ^byte;
  LZ: integer;
begin
  TBmp := TBitmap.Create;
  try
    case PixelFormat of
      pf8bit:
        LZ := (Bitmap.width * Bitmap.height);
      pf16bit:
        LZ := (Bitmap.width * Bitmap.height) * 2;
      pf24Bit:
        LZ := (Bitmap.width * Bitmap.height) * 3;
      pf32Bit:
        LZ := (Bitmap.width * Bitmap.height) * 4;
    end;
    TBmp.PixelFormat := PixelFormat;
    TBmp.width := w;
    TBmp.height := h;
    pX := TBmp.ScanLine[TBmp.height - 1];
    CopyMemory(pX, @BytesArray.tableau[0], LZ);
    Bitmap.Assign(TBmp);
  finally
    TBmp.Free;
  end;
end;

procedure BytesArrayToBitmapDepth(const BytesArray: CLNUIDepth;
  const w, h: integer; Bitmap: TBitmap);
var
  TBmp: TBitmap;
  pX: ^byte;
  LZ: integer;
begin
  TBmp := TBitmap.Create;
  try
    LZ := (Bitmap.width * Bitmap.height) * 4;
    TBmp.PixelFormat := pf32Bit;
    TBmp.width := w;
    TBmp.height := h;
    pX := TBmp.ScanLine[TBmp.height - 1];
    CopyMemory(pX, @BytesArray.tableau[0], LZ);
    Bitmap.Assign(TBmp);
  finally
    TBmp.Free;
  end;
end;

end.

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.