Getting Colored pixels of humanStencilTexture from ARHumanBodyManger - unity3d

I am creating an AR application for iOs using Unity and ARKit 3.
I am using People occlusion sample to detect human bodies.
ARHumanBodyManger has a property called humanStencilTexture which return Texture2D which preview the human body in red and other things in black as shown in this image.
I want to identify the coloured pixels in this Texture.
I used humanStencilTexture.GetPixels() to get all pixels and when I checked these pixels they all black.
Can anyone help me how to check for red pixels?

Related

All shaders render black while using shadergraph in unity 2020 1.10f

I am doing a simple animation in unity and I wanted to add portal efecct using shadergraph 8.2.0 and everything renders black
like this
shader setings
I have no clue whatsoever what it is
I'm still learning the pipeline, however, I would think you need to scale up the texture on the top left, I can't read its name from the image. But you are getting the red/yellow mix, getting the swirl, but the area that's being blacked out is comparable to the texture I mentioned. Sorry I don't know how to put it exactly, but the white to grey to black gradient is not large enough so you are rendering the center fine just need to expand the white-grey area, I think scaling the texture up would produce the effect you want.

Unity 2D display "flash effect" above tiles

I want to apply a brighten effect above my scene.
My scene contains tiles, and I want to perform white flash for a few frames by code.
I have already tried this code:
private Tilemap tm;
...
tm = GetComponent<Tilemap>();
tm.color = new Color(0.5f,1.0f,1.0f,1.0f);
This code darkens the scene by a certain color amount, but I wish to brighten it.
Your code is not working because in Unity if you render an image (in your case tile) the original color of the image is when its color is white (255,255,255,255).
It means that if you change the color of an image it will add this color to this image.
For instance, if you set the color of an image to red, the image colors will become more similar to red than the original image.
As I see it you have 2 ways to perform the white flash:
A) Add another image of a white rectangle that covers all the screen and set it's alpha color to a low number (the lower the number the lighter flash effect).
In the editor disable this object's renderer and when you want to perform a flash effect enable this object from the code (You can improve this with animations or code to get a smooth flash animation).
B) Install the package "2D Light". This is an experimental package that allow you to render 2d light.
This package contains a lot of components that allow you to stimulate light.
I have found a way to do this.
I created a new PNG that only contains white shapes on a transparent background.
There are about 20 pieces that match the shapes of my level tilemap.
Now I just create a new (white) tilemap above the level tilemap in the shape of the highlight.
Then I set the alpha of the white tilemap in code.
It works :)

Incorrect white matte behind antialiasing on imported sprites

I'm importing a sprite into Unity, and adding it to a Screen Space Overlay canvas to use for a UI.
The image I'm importing looks exactly as I want it, but in Unity the anti-aliased edges look like they're going to a white background color, instead of just fading over whatever is actually behind them.
I'm using these import settings:
I'm using a default UI/Image component to add it to the canvas.
This is the image I'm importing - it's a 32 bit PNG exported from Fireworks: (also shown over a black background)
Just to confirm, this looks fine everywhere else in Unity, preview panels, pickers etc. I am packing this sprite using the built in Sprite Packer if that changes anything.
And the final result:
How can I get rid of these artifacts on the corners?
The problem was the RGB values of the transparent pixels. By default they are white, and any scaling operations cause this white color to be blended with the partially transparent pixels.
I essentially made a slightly larger version of the button background shape, put it in a layer behind everything, and then wrote back into the alpha channel making it transparent. This means that the neighboring pixels are then the same color as the partially transparent ones.
The end result:

Unity 2D: Irregular shape window to a different background world?

I want to make an irregular shape display its colors from a different set of images. Currently, I have a flashlight represented by an irregular shape (kite shaped) that when casted over an area, certain objects appear. When the shape is removed, the items disappear. Now, I want to have the background that is within this irregular shape to display an altered version of the background.
I am planning to use a RenderTexture to get its info from a camera that views the flashlight's corrosponding location in the other world, and then use this image as the basis of the flashlight's altered background. However, when I try this, the flashlight shows black instead of the other world. When I texture a plane, the RenderTexture works properly. Anyone have any ideas how to accomplish this?

How can i paint inside the bouandry of the PNG image

I have an PNG image with complete transparency. It has a picture of an animal , just bordered with black color.
Now , I want to paint the image as my finger move on the ipad Screen, but paint should only appear inside the bordered region not out side.
My Thinking -----
What i am thinking is to keep the color of the image inside the boundary line, a little bit differ from the out side. Then, Get the pixel of the image and for each pixel , the color component.
Keeping all the pixels of out side the boundary in an array and check for it when finger move on the iPad screen.
I am new to the concept of core graphic and open GL so not being able to think wisely. Please help.
First you should define where is "inside" to paint on your image.
I suggest to run a flood fill algortihm on the first touched place and define de desired "inside area" pixels. Notice that you will run the flood fill at the background on the original black and white image, not for actually painting the pixels, just to figure out the target ones.
For example; we want to paint the animals face and body to different colors. When user first toucehs the face and drags over, you can do a flood fill on black and white image to find the pixels of the face and only paint the intersection of the face area and the touched area. Then, when the user picks up her finger (changes the color) and retouches on the body and you do another flood fill operation to detect the pixels of the body and so on.
It was a long description, hope it makes sense.
Here are some flood fill sources that might help:
Floodfill in objective c
https://stackoverflow.com/questions/8121348/flood-fill-algorithm-objective-c-version
How to Implement FloodFill Algorithm in iphone