Bonsoir,
alors voilà mon problème, si quelqu'un est de taille et de motivation à s'y intéresser.
J'ai à travers un package, un code qui me permet d'établir un Match Moving. Ce fichier a une spécificité qui permet de récupérer seulement les mouvements de l'utilisateur sous forme de couleurs. Ces couleurs sont ensuite encadrées par une rectangle de type "shape".
Là ou ça ce complique est que j'ai ajouté un clip
( var clip : IRM = new IRM) exporté par action script devant le rendu de caméra
(_output).
Or le rectangle qui encadre les mouvements reste au-dessus du clip.
Mon but est de transformer ce rectangle
(_bounds) en masque vis à vis du clip, et que le clip soit visible qu'à l'intérieur du rectangle.
(le principe même du masque).
Le gros problème est que je ne suis pas une grosse bête de concours en programmation et que je ne sais même pas s'il est possible de transformer un graphics de type
"shape" en masque.
Qui plus est un graphics (rectangle) instable puisse qu'il embrasse sans cesse la grandeur et la déplacement de votre mouvement.
Voici un aperçu du code :
(n'hésiter à me demander plus d'information si le l'aprçu n'est pas assez complet, c'est plutôt urgent, merci.)
private var _motionTracker : MotionTracker;
private var _mask : Shape;
private var _clip: MovieClip;
private var _target : Shape;
private var _bounds : Shape;
private var _output : Bitmap;
private var _source : Bitmap;
private var _video : BitmapData;
private var _matrix : ColorMatrix;
private var _blurLabel : Label = new Label();
private var _brightnessLabel : Label = new Label();
private var _contrastLabel : Label = new Label();
private var _minAreaLabel : Label = new Label();
private var _blurSlider : Slider = new Slider();
private var _brightnessSlider : Slider = new Slider();
private var _contrastSlider : Slider = new Slider();
private var _minAreaSlider : Slider = new Slider();
private function initTracking() : void
{
var camW : int = 500;
var camH : int = 500;
// Create the camera
var cam : Camera = Camera.getCamera();
cam.setMode(camW, camH, stage.frameRate);
// Create a video
var vid : Video = new Video(camW, camH);
vid.attachCamera(cam);
// Create the Motion Tracker
_motionTracker = new MotionTracker(vid);
// We flip the input as we want a mirror image
_motionTracker.flipInput = true;
/*** Create a few things to help us visualise what the MotionTracker is doing... ***/
_matrix = new ColorMatrix();
_matrix.brightness = _motionTracker.brightness;
_matrix.contrast = _motionTracker.contrast;
// Display the camera input with the same filters (minus the blur) as the MotionTracker is using
_video = new BitmapData(camW, camH, false, 0);
_source = new Bitmap(_video);
_source.scaleX = -1;
_source.x = 0 + camW;
_source.y = 0;
_source.filters = [new ColorMatrixFilter(_matrix.toArray())];
addChild(_source);
// Show the image the MotionTracker is processing and using to track
_output = new Bitmap (_motionTracker.trackingImage);
_output.x = -50;
_output.y = -0;
_output.height = 500;
_output.width = 500;
// A shape to represent the tracking point
_target = new Shape();
_target.graphics.lineStyle(0, 0xFFFFFF);
_target.graphics.drawCircle(0, 0, 30);
//addChild(_target);
// A box to represent the activity area
_bounds = new Shape();
_bounds.x = _output.x;
_bounds.y = _output.y;
_
bounds.mask = clip;
var clip: IRM = new IRM ();
clip.x = -50;
clip.y = -100;
clip.height = 530;
clip.width = 500;
//_bounds.cacheAsBitmap=true;
addChild(_output);
addChild(clip);
addChild(_bounds);
private function onEnterFrameHandler(event : Event) : void
{
// Tell the MotionTracker to update itself
_motionTracker.track();
// Move the target with some easing
_target.x += ((_motionTracker.x + _bounds.x) - _target.x) / 10;
_target.y += ((_motionTracker.y + _bounds.y) - _target.y) / 10;
_video.draw(_motionTracker.input);
// If there is enough movement (see the MotionTracker's minArea property) then continue
if ( !_motionTracker.hasMovement ) return;
// Draw the motion bounds so we can see what the MotionTracker is doing
_bounds.graphics.clear();
_bounds.graphics.lineStyle(0, 0xFFFFFF);
_bounds.graphics.drawRect(_motionTracker.motionArea.x, _motionTracker.motionArea.y, _motionTracker.motionArea.width, _motionTracker.motionArea.height);