public override Status PushInput(TextureFrame textureFrame) { base.PushInput(textureFrame).AssertOk(); graph.AddPacketToInputStream("input_width", new IntPacket(textureFrame.width, currentTimestamp)).AssertOk(); return(graph.AddPacketToInputStream("input_height", new IntPacket(textureFrame.height, currentTimestamp))); }
public override void LoadContent() { _content = BlackBoard.GetEntry <ContentManager>("ContentManager"); _graphicsDevice = BlackBoard.GetEntry <GraphicsDevice>("GraphicsDevice"); _camera = BlackBoard.GetEntry <CameraComponent>("Camera"); _map = BlackBoard.GetEntry <Map>("Map"); _texture = _content.Load <Texture2D>("Images/OryxEnv"); _effect = new BasicEffect(_graphicsDevice); _effect.TextureEnabled = true; _effect.Texture = _texture; _quads = new List <QuadShape>(); for (int z = 0; z < _map.Height; z++) { for (int x = 0; x < _map.Width; x++) { Vector3 quadOrigin = new Vector3(x, 0, z); TextureFrame textureFrame = new TextureFrame(0.375f, 0, 0.0625f, 0.0625f); QuadShape quad = new QuadShape(quadOrigin, Vector3.Up, Vector3.Forward, textureFrame); _quads.Add(quad); } } }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { this.handTrackingValue = FetchNextHandTrackingValue(); // this.handLandmarks = handTrackingValue.HandLandmarkLists RenderAnnotation(screenController, handTrackingValue); screenController.DrawScreen(textureFrame); }
private static void CreateSkins() { // auto create Skins var skins = new List <Skin>(); skins.AddRange(Skin.CreateFromXml(@"../../../Media/Gfx/GUI/skins.xml", null)); skins.AddRange(Skin.CreateFromXml(@"../../../Media/Gfx/Cursor/CursorSkin.xml", null)); // manual create Skins var logo = new Skin("Logo"); var rect = RectangleF.FromLTRB(0, 0, 1, 1); var frame1 = new TextureFrame("Logo1.png", rect, 1000); var frame2 = new TextureFrame("Logo2.png", rect, 800); var frame3 = new TextureFrame("Logo3.png", rect, 600); var frame4 = new TextureFrame("Logo4.png", rect, 400); var frame5 = new TextureFrame("Logo5.png", rect, 200); logo.SubSkins["Logo"] = new Miyagi.Common.Resources.Texture(frame1, frame2, frame3, frame4, frame5) { FrameAnimationMode = FrameAnimationMode.ForwardBackwardLoop }; skins.Add(logo); Skins = skins.ToDictionary(s => s.Name); }
private IEnumerator WaitForTextureFrame(Action <TextureFrame> callback) { TextureFrame nextFrame = null; lock (((ICollection)availableTextureFrames).SyncRoot) { yield return(new WaitUntil(() => { return poolSize > frameCount || availableTextureFrames.Count > 0; })); while (availableTextureFrames.Count > 0) { var textureFrame = availableTextureFrames.Dequeue(); if (!IsStale(textureFrame)) { nextFrame = textureFrame; break; } } if (nextFrame == null) { nextFrame = CreateNewTextureFrame(); } } callback(nextFrame); lock (((ICollection)textureFramesInUse).SyncRoot) { textureFramesInUse.Add((UInt64)nextFrame.GetNativeTexturePtr(false), nextFrame); } }
public IButton SetFrame(TextureFrame frame) { Frame = frame; Sprite = (ButtonSprite) new ButtonSprite(frame) .SetSize(Width, Height); return(this); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var detections = FetchNextOutputDetections(); RenderAnnotation(screenController, detections); screenController.DrawScreen(textureFrame); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var poseTrackingValue = FetchNextPoseTrackingValue(); RenderAnnotation(screenController, poseTrackingValue); screenController.DrawScreen(textureFrame); }
public Animation(TextureFrame frame, int startIndex, int stopIndex, bool loop = false, bool hold = false) { Frame = frame; StartIndex = startIndex; StopIndex = stopIndex; Loop = loop; Hold = hold; }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var faceMeshValue = FetchNextFaceMeshValue(); RenderAnnotation(screenController, faceMeshValue); screenController.DrawScreen(textureFrame); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var detections = FetchNextFaceDetectionsPresence() ? FetchNextFaceDetections() : new List <Detection>(); RenderAnnotation(screenController, detections); screenController.DrawScreen(textureFrame); }
public void SetupOutputPacket(TextureFrame textureFrame) { if (configType != ConfigType.OpenGLES) { throw new InvalidOperationException("This method is only supported for OpenGL ES"); } destinationTexture = textureFrame; outputGpuBufferPacket = new GpuBufferPacket(destinationTexture.BuildGpuBuffer(GpuManager.glCalculatorHelper.GetGlContext())); }
public Image(int width, int height, TextureFrame spriteTexture) { //Position = position; Width = width; Height = height; Sprite = new PictureSprite(spriteTexture); //Sprite.SetPosition(position); Sprite.SetSize(Width, Height); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var handTrackingValue = FetchNextHandTrackingValue(); RenderAnnotation(screenController, handTrackingValue); UpdateGestureModel(handTrackingValue); screenController.DrawScreen(textureFrame); }
public void DrawScreen(TextureFrame src) { if (!isWebCamReady) { return; } // TODO: size assertion src.CopyTexture(outputTexture); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { var hairMask = FetchNextHairMask(); var texture = screenController.GetScreen(); texture.SetPixels32(textureFrame.GetPixels32()); RenderAnnotation(screenController, hairMask); texture.Apply(); }
public void Animate(TextureFrame defaultFrame) { if (Animation != null && (Animation.Animate() || Animation.Hold)) { SetFrame(Animation.Frame); } else { ClearAnimation(); SetFrame(defaultFrame); } }
public QuadShape(Vector3 origin, Vector3 normal, Vector3 up, TextureFrame textureFrame, float width = 1.0f, float height = 1.0f) { Origin = origin; Normal = normal; Up = up; TextureFrame = textureFrame; Width = width; Height = height; UpdateVertexData(); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { lock (outputImageLock) { if (outputImage == null) { return; } screenController.DrawScreen(outputImage); outputImage.Dispose(); outputImage = null; } }
public override Status PushInput(TextureFrame textureFrame) { base.PushInput(textureFrame).AssertOk(); graph.AddPacketToInputStream("sticker_sentinel", new IntPacket(stickerSentinelId, currentTimestamp)).AssertOk(); stickerSentinelId = -1; var stickerRoll = new StickerRoll(); stickerRoll.Sticker.Add(currentSticker); graph.AddPacketToInputStream("sticker_proto_string", new StringPacket(stickerRoll.ToByteArray(), currentTimestamp)).AssertOk(); graph.AddPacketToInputStream("imu_rotation_matrix", new FloatArrayPacket(imuRotationMatrix, currentTimestamp)).AssertOk(); return(Status.Ok()); }
public override void Draw(GameTime gameTime, Renderer renderer) { if (!Visible) { return; } if (IsHovered) { if (Tooltip != null) { Tooltip.Draw(gameTime, renderer); } if (TextureFrameHovered != null) { TextureFrameHovered.Draw(Position.X, Position.Y); } } if (IsClicked || IsSelected) { if (TextureFrameSelected != null) { TextureFrameSelected.Draw(Position.X, Position.Y); } } if (!IsHovered && !IsClicked && !IsSelected) { TextureFrame.Draw(Position.X, Position.Y); } if (Icon != null) { Icon.Draw(gameTime, renderer); } if (Label != null) { Label.Draw(gameTime, renderer); } }
public static void Render(ContentManager content, GraphicsDevice graphicsDevice, TransformComponent transform, CameraComponent camera, BasicEffect effect) { if (_quad == null) { _texture = content.Load <Texture2D>("Images/OryxChar"); TextureFrame textureFrame = new TextureFrame(0.292f, 0.031f, 0.042f, 0.031f); Vector3 normal = camera.Rotation.Forward * -1; Vector3 up = camera.Rotation.Up; _quad = new QuadShape(transform.Position, normal, up, textureFrame, 0.5f, 0.5f); } _quad.Origin = transform.Position + new Vector3(0, _quad.Height / 2.0f, 0); _quad.UpdateVertexData(); effect.Texture = _texture; graphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalTexture>(PrimitiveType.TriangleList, _quad.Vertices, 0, 4, _quad.Indexes, 0, 2); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { #if UNITY_ANDROID // MediaPipe renders to the texture directly. return; #else if (!outputStreamPoller.Next(outputPacket)) { Debug.LogWarning("Failed to fetch an output packet, rendering the input image"); screenController.DrawScreen(textureFrame); return; } using (var gpuBuffer = outputPacket.Get()) { ImageFrame imageFrame = null; gpuHelper.RunInGlContext(() => { var gpuBufferFormat = gpuBuffer.Format(); var sourceTexture = gpuHelper.CreateSourceTexture(gpuBuffer); imageFrame = new ImageFrame( gpuBufferFormat.ImageFormatFor(), gpuBuffer.Width(), gpuBuffer.Height(), ImageFrame.kGlDefaultAlignmentBoundary); gpuHelper.BindFramebuffer(sourceTexture); var info = gpuBufferFormat.GlTextureInfoFor(0); Gl.ReadPixels(0, 0, sourceTexture.width, sourceTexture.height, info.glFormat, info.glType, imageFrame.MutablePixelData()); Gl.Flush(); sourceTexture.Release(); return(Status.Ok(false)); }).AssertOk(); if (imageFrame != null) // always true { screenController.DrawScreen(imageFrame); } } #endif }
public Status AddTextureFrameToInputStream(TextureFrame textureFrame) { var status = AddTextureFrameToInputStream(inputStreamName, textureFrame); if (!status.ok) { return(status); } var stickerSentinelId = isTracking ? -1 : currentStickerSentinelId; status = AddPacketToInputStream(stickerSentinelStreamName, new IntPacket(stickerSentinelId, currentTimestamp)); if (!status.ok) { return(status); } isTracking = true; return(AddPacketToInputStream(initialAnchorDataStreamName, new Anchor3dVectorPacket(anchors, currentTimestamp))); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { #if UNITY_ANDROID && !UNITY_EDITOR // MediaPipe renders the result to the screen directly. #elif UNITY_IOS using (var imageFrame = FetchNext(outputStreamPoller, outputPacket, outputStream)) { screenController.DrawScreen(imageFrame); } #else lock (outputImageLock) { if (outputImage == null) { return; } screenController.DrawScreen(outputImage); outputImage.Dispose(); outputImage = null; } #endif }
protected override void AddTextureFrameToInputStream(TextureFrame textureFrame) { graphRunner.AddTextureFrameToInputStream(textureFrame); }
public PictureSprite(TextureFrame frame) : base(frame) { }
public static int Load(string fileNameOrg, long lColorKey, int iMaxWidth, int iMaxHeight, bool persistent) { string fileName = GetFileName(fileNameOrg); string cacheKey = fileName.ToLowerInvariant(); if (String.IsNullOrEmpty(fileName)) { return(0); } CachedTexture cached; if (_cacheTextures.TryGetValue(cacheKey, out cached)) { return(cached.Frames); } string extension = Path.GetExtension(fileName).ToLowerInvariant(); if (extension == ".gif") { Image theImage = null; try { try { theImage = ImageFast.FromFile(fileName); } catch (FileNotFoundException) { Log.Warn("TextureManager: texture: {0} does not exist", fileName); return(0); } catch (Exception) { Log.Warn("TextureManager: Fast loading texture {0} failed using safer fallback", fileName); theImage = Image.FromFile(fileName); } if (theImage != null) { CachedTexture newCache = new CachedTexture(); newCache.Name = fileName; FrameDimension oDimension = new FrameDimension(theImage.FrameDimensionsList[0]); newCache.Frames = theImage.GetFrameCount(oDimension); int[] frameDelay = new int[newCache.Frames]; for (int num2 = 0; (num2 < newCache.Frames); ++num2) { frameDelay[num2] = 0; } // Getting Frame duration of an animated Gif image try { int num1 = 20736; PropertyItem item1 = theImage.GetPropertyItem(num1); if (item1 != null) { byte[] buffer1 = item1.Value; for (int num2 = 0; (num2 < newCache.Frames); ++num2) { frameDelay[num2] = (((buffer1[(num2 * 4)] + (256 * buffer1[((num2 * 4) + 1)])) + (65536 * buffer1[((num2 * 4) + 2)])) + (16777216 * buffer1[((num2 * 4) + 3)])); } } } catch (Exception) { } for (int i = 0; i < newCache.Frames; ++i) { theImage.SelectActiveFrame(oDimension, i); //load gif into texture using (MemoryStream stream = new MemoryStream()) { theImage.Save(stream, ImageFormat.Png); ImageInformation info2 = new ImageInformation(); stream.Flush(); stream.Seek(0, SeekOrigin.Begin); Texture texture = TextureLoader.FromStream( GUIGraphicsContext.DX9Device, stream, 0, 0, //width/height 1, //mipslevels 0, //Usage.Dynamic, Format.A8R8G8B8, GUIGraphicsContext.GetTexturePoolType(), Filter.None, Filter.None, (int)lColorKey, ref info2); newCache.Width = info2.Width; newCache.Height = info2.Height; newCache[i] = new TextureFrame(fileName, texture, (frameDelay[i] / 5) * 50); } } theImage.SafeDispose(); theImage = null; newCache.Disposed += new EventHandler(cachedTexture_Disposed); if (persistent && !_persistentTextures.ContainsKey(cacheKey)) { _persistentTextures[cacheKey] = true; } _cacheTextures[cacheKey] = newCache; //Log.Info(" TextureManager:added:" + fileName + " total:" + _cache.Count + " mem left:" + GUIGraphicsContext.DX9Device.AvailableTextureMemory.ToString()); return(newCache.Frames); } } catch (Exception ex) { Log.Error("TextureManager: exception loading texture {0}", fileName); Log.Error(ex); } return(0); } try { int width, height; if (MediaPortal.Util.Utils.FileExistsInCache(fileName)) { Texture dxtexture = LoadGraphic(fileName, lColorKey, iMaxWidth, iMaxHeight, out width, out height); if (dxtexture != null) { CachedTexture newCache = new CachedTexture(); newCache.Name = fileName; newCache.Frames = 1; newCache.Width = width; newCache.Height = height; newCache.Texture = new TextureFrame(fileName, dxtexture, 0); newCache.Disposed += new EventHandler(cachedTexture_Disposed); if (persistent && !_persistentTextures.ContainsKey(cacheKey)) { _persistentTextures[cacheKey] = true; } _cacheTextures[cacheKey] = newCache; return(1); } } } catch (Exception) { return(0); } return(0); }
public Status AddTextureFrameToInputStream(TextureFrame textureFrame) { return(AddTextureFrameToInputStream(inputStreamName, textureFrame)); }
public override void RenderOutput(WebCamScreenController screenController, TextureFrame textureFrame) { // MediaPipe renders to the texture directly. return; }