Detect if face is within a circle [closed] - swift

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Currently I am working on face detection app. I have implemented face detection part using Apple's Vision.
And app has custom white circle drawn over the screen (you can see in below image).
Now, how can I detect if face is within that custom white circle or not?

I have also done similar project for fun. Link here: https://github.com/sawin0/FaceDetection
For those who don't want to dive into repo.
I have quick suggestion for you, if you have path of circle and face as CGPath then you can compare circle's and face's bounding box using contains(_:using:transform:) .
Here is a code snippet
let circleBox = circleCGPath.boundingBox
let faceBox = faceRectanglePath.boundingBox
if(circleBox.contains(faceBox)){
print("face is inside the circle")
}else{
print("face is outside the circle")
}
I hope this helps you and others too.
P.S. If there is any better way to do this then please feel free to share.

Related

Unity2D Simulating height with Top Down Shadows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
So the problem is the following:
I have been trying to make this flying simulator little phone game, the problem is i cant make the shadow change with a smooth transition...
That White squared is a cloud, and the objective is to have the shadow change size while in the cloud...
I don´t really know were to start, i tried shaders, but i´m not that good with that...
Thx :))
If you are not into shaders, I would look into Masks. Masks basically limit a sprite to only draw within it's boundaries.
In this example, you could have a mask on the cloud. To make it work, have the "nearer" shadow be always drawn, but only in the mask's boundaries (In this case - the cloud) Relevant Youtube Tutorial

cant get Image or Texture of UI.Image in Unity [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
m_Image = GetComponent<Image>();i am trying to put a list of images and whenever clicked i want to replace clicked image to a plain . as i am a beginner in unity please share your thoughts,,
As shown here the pen image should be replaced in the floor
I believe you should use
GetComponent<Image>().sprite
and set a sprite instead of an Image.
You should use Sprite instead of an image(sprite is a part of images components in unity)
GetComponent<Image>().sprite;
Read more about Sprites
Unity Manual

SceneKit - Xcode 9: removing the box's line border [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am new to SceneKit, currently playing around with it.
I use 4 boxes as walls to create a sort of skybox.
Each box/wall has its own starfield texture. Currently this causes the borders of the walls to be visible. I want to remove these line borders, any idea?
That is a result of the texture you use, which is not seamless. Look into "seamless tileable" textures. A much better approach to do what you are trying to do however, is to use the scene’s background property as explained in the answer of this question: How to set contents of scenekit background to cube map

Generate a grid in Swift using Sprite Kit [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an app idea so mocked it up in C# because that's my most fluent language. I now want to port this over to Swift if possible, how hard will it be to generate a grid of 6x6 blocks, each block needs to be separate from each other as I need to change they're properties and detect touches on them. This is the grid I've currently got running on Windows.
Thanks for any help.
There are a lot of different ways to approach this problem, so you need to provide more details. You could do it with a single custom UIView, drawing the current representation of your model in the drawRect method and it would also be able to handle all of the touch events since you can just calculate where the user did the touch in the same way that you calculated drawing the grid and coloring the squares.
But if you want to use SpriteKit, then this tutorial will show you all the details of doing a 2D array, using sprites, tiles, etc.
http://www.raywenderlich.com/75270/make-game-like-candy-crush-with-swift-tutorial-part-1

How to create walls and up/down/right/left code for maze [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I created a border of black patches and the rest of the "walls" of the maze are purple. How would I code the maze so that it won't walk into the walls? And also how would you code the up/down/left/right buttons to control the turtle that walks through the maze. Thanks so much! I tried so much but I can't seem to get it to work.
I think you will find everything you need in this example model in NetLogo Model library
(File => Model Library => Pac- Man