Open mhamilt opened 2 years ago
Since you've now got a GitHub repo you can track all your issues here. Instead of having disparate collection of notes in your Notes.app, Teams, email, on bits of paper &c... collect together all problems into issues here of which you can then easily keep track.
You have a couple of different models to work with (model in this case being a form and structure of data)
In the simplest case you will be using:
ARSkeleton2D
ARFrame.detectedBody
ARSkeleton2D.landmark(for:)
to get the location of a given joint in the ARFrame
...ARSkeleton.JointName
of which there are 8.jointLandmarks
directlyARSkeleton2D.jointLandmarks
is your data. This is the thing you want to know everything about, how big it is, what shape it is, what type it is.
One quirk is that accessing jointLandmarks
directly appears to yield more data than using ARSkeleton2D.landmark(for:)
Connecting things together is very much "knee bone is connected to the hip bone" stuff. That is to say, there is a fixed order of things and so long as you are sensible, connecting lines (paths) between joints won't be too taxing.
Also, one thing that isn't leveraged is the ARSkeletonDefinition
object, which might save you a bit of heavy lifting.
If you can get a circle for every joint, the next stage is adding a single Path
updateJointScreenPositions
is where you will want to start looking when it comes to drawing. You'll want to create a new view and add it in the same way as the circles are.
[TwoDBodyJoint : UIView]
- I’m really confused as to what that means.
If you are uncertain what something is, print it. Print its type and print its contents.
in this case it is simply a dictionary literal
in the updateJointScreenPosition the jointLandmark
is of type CGPoint with x,y coordinates of type CGFloat. These are normalised pixel coordinates (0,0 top-left, 1,1 bottom-right) so the x,y values are always 0. something.
In the for loop though, these values are transformed to screen-space coordinates and stored in jointScreenPositions
array of CGPoints.
What I struggle to understand is how to Access that jointScreenPositions
array. It seems like if I print it out from within the updateJointScreenPosition
it constaldnly prints the updated version of every joint, which is great. But if I try to create a function outside of this area, the jointScreenPositions
array contains (0,0) values.
Also I don't understand how the bodyTracker.attach function works. It takes in 2 parameters:
1 - thisView
of type UIView. I'm not sure if I understand what that actually means in plain English, as in thisView
there's a circle being passed.
2 - toThisJoint thisJoint: TwoDBodyJoint
- I'm confused about this syntax. The parameter is toThisJoint
, the type TwoDBodyJoint
, but what's thisJoint
doing / meaning? In plain English I understand that essentially is saying - attach this circle to this joint but I do not understand how the code actually finds the location of the joint based on the name alone.
Ideally I should be able to use a similar function and "attach" a line (instead of a circle) between two joints - right? So I would need a function similar to makeCircle but for "makeLine" perhaps that takes in parameters of two joints to determine the distance between them in order to draw it?
First I need to draw a simple line between two joints. I have an array that I don't understand where / how to access values of, and can't seem to reverse engineer the already existing function for applying graphics (circle) to a joint.
in the updateJointScreenPosition the jointLandmark is of type CGPoint
jointLandmark
is a simd_float2
, not a CGPoint, so be careful there.
These are normalised pixel coordinates (0,0 top-left, 1,1 bottom-right) so the x,y values are always 0. something.
correct
What I struggle to understand is how to Access that jointScreenPositions array
Like this
But if I try to create a function outside of this area, the jointScreenPositions array contains (0,0) values.
It depends on where and how you are doing this, I'd need to see an example.
Also I don't understand how the bodyTracker.attach function works. It takes in 2 parameters: 1 - thisView of type UIView. I'm not sure if I understand what that actually means in plain English, as in thisView there's a circle being passed.(https://github.com/csabau/BTracking/blob/9cba6cd650fe3d50fb30d53a3a791f1e0fcd21ff/Sources/BodyTracking/BodyTracker2D.swift#L86-L92) function works. It takes in 2 parameters: 1 - thisView of type UIView. I'm not sure if I understand what that actually means in plain English, as in thisView there's a circle being passed.
The UIView is the circle. "Animation" is achieved by moving the position of the same circle, not by wiping the screen and redrawing a new circle as you might be used to.
You'd need to the same with your Paths. You would create a bunch of UIViews that are paths and simply update their properties each time you get new data.
2 - toThisJoint thisJoint: TwoDBodyJoint - I'm confused about this syntax.
This is a little bit of syntactic sugar to make your declaration read nicely, but make the variable names in the function useable.
In long form
public func attach
create a function called attach
which can be used outside the class.
thisView: UIView
The first argument is called thisView
and is of type UIView
toThisJoint thisJoint: TwoDBodyJoint
The second argument is toThisJoint
but is aliased in the function to simply thisJoint
and is of type TwoDBodyJoint
Look at the function
notice it uses thisJoint
and not toThisJoint
Ideally I should be able to use a similar function and "attach" a line (instead of a circle) between two joints
I'd actually edit the current attach
function. Your Paths will be based on your joints after all.
So I would need a function similar to makeCircle but for "makeLine" perhaps that takes in parameters of two joints to determine the distance between them in order to draw it?
That's correct, probably using it somewhere around here
First I need to draw a simple line between two joints.
First you need to just draw a simple line if you haven't already. Then you can look at doing one between joints.
Within this there are probably 3 or 4 issues. I'd look to create them so you can segment the discussion a little bit. Otherwise you end up with answers like above where you're going to have to jump around a little
Probably an issue each for
jointLandmark
reliablymakePath
functionattach
function to include PathsThis also still doesn't address how you are going to compare one set of data to another
Within this there are probably 3 or 4 issues. I'd look to create them so you can segment the discussion a little bit. Otherwise you end up with answers like above where you're going to have to jump around a little
Probably an issue each for
- [ ] Draw a Path
- [ ] Print out
jointLandmark
reliably- [ ] create
makePath
function- [ ] draw Path between two specific joints
- [ ] draw Path between arbitrary joints
- [ ] edit
attach
function to include Paths- [ ] remove extraneous comments and failed functions (as they aren't doing you any favours)
I now understand what you mean by having different “issues” I will open them separately later on today and will focus first on just getting a line drawn