Measuring body measurements with BodyPIX

970 views
Skip to first unread message

sampath jayashantha

unread,
Jun 26, 2020, 12:05:15 PM6/26/20
to TensorFlow.js Discussion
Hi All,

Anybody has a clue of measuring body measurements by BodyPIX. What is the logic behind it?

Jason Mayes

unread,
Jun 26, 2020, 12:13:21 PM6/26/20
to sampath jayashantha, TensorFlow.js Discussion
Hello there,

If you are referring to the demo I created essentially if you know the user's height you can figure out how many pixels represent that height in the webcam. If you know the ratio for that and compute it very fast - many times a second - because if a person moves the ratio will change, you can then calculate the size of any other measurement in the scene too.

All I needed to do then was figure out where the key parts of the body were that I needed to measure, and then simply measure the distance between those points.

Jason

On Fri, Jun 26, 2020 at 9:05 AM sampath jayashantha <esam...@gmail.com> wrote:
Hi All,

Anybody has a clue of measuring body measurements by BodyPIX. What is the logic behind it?

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/a1592c49-c2f7-4927-b600-895f0b1d557fo%40tensorflow.org.


--




     
  •  Jason Mayes
  •  Senior Developer Advocate, TensorFlow.js
  •  Google
     Follow my discoveries or contribute your own

   

This email may be confidential and privileged. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


sampath jayashantha

unread,
Jun 26, 2020, 12:30:21 PM6/26/20
to TensorFlow.js Discussion, esam...@gmail.com
Hi Jason,

Thank you for your quick response. Yes, I was referring to the same project. Yes, absolutely I can understand how we can calculate how many pixels represent that height. But unfortunately, still, It's not clear for me how I can calculate his chest or collar size from it :(


On Friday, June 26, 2020 at 9:43:21 PM UTC+5:30, Jason Mayes wrote:
Hello there,

If you are referring to the demo I created essentially if you know the user's height you can figure out how many pixels represent that height in the webcam. If you know the ratio for that and compute it very fast - many times a second - because if a person moves the ratio will change, you can then calculate the size of any other measurement in the scene too.

All I needed to do then was figure out where the key parts of the body were that I needed to measure, and then simply measure the distance between those points.

Jason

On Fri, Jun 26, 2020 at 9:05 AM sampath jayashantha <esam...@gmail.com> wrote:
Hi All,

Anybody has a clue of measuring body measurements by BodyPIX. What is the logic behind it?

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tf...@tensorflow.org.

Jason Mayes

unread,
Jun 26, 2020, 1:06:44 PM6/26/20
to sampath jayashantha, TensorFlow.js Discussion
If you draw out the points that body pix provides for pose you can do some mathematics to figure out how to intersect the regions of the body you are trying to target and from that you can then scan horizontally or vertically to figure out what size that part is from the given segmentation data.

To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/47fdfa33-4139-458b-8fa1-c8d926f36b16o%40tensorflow.org.

sampath jayashantha

unread,
Jun 28, 2020, 12:14:53 AM6/28/20
to Jason Mayes, TensorFlow.js Discussion
HI Jason,

Your code is available for the public? 

Jason Mayes

unread,
Jun 28, 2020, 12:15:57 AM6/28/20
to sampath jayashantha, TensorFlow.js Discussion
No, not yet. 

sampath jayashantha

unread,
Jun 28, 2020, 2:17:15 AM6/28/20
to Jason Mayes, TensorFlow.js Discussion
HI Jason,

Np. I will try my stuff and get back to you if I come across any issue.

Thx

sampath jayashantha

unread,
Jun 29, 2020, 5:17:36 AM6/29/20
to Jason Mayes, TensorFlow.js Discussion
Hi Jason,

Locating the waist measurement exactly on the data array, did you get help from key-point locations? If so which key-point?
--
..........................................................................................

There is always some one who know more Than us out there.

Wê Lïvê †ð §hårê : Wê Lðvê †ð §hårê



SAM

Jason Mayes

unread,
Jun 29, 2020, 3:20:22 PM6/29/20
to sampath jayashantha, TensorFlow.js Discussion
You need to research the proportions of the human body to be able to estimate this. Computer science is often the understanding of another discipline to understand how to create something. From this you can narrow down a range in which the widest waist point probably  lies and then you can simply scan this region in x to find the largest width and use that as the waist in 1 dimension. You will then need to do the same for side of body and then you can calculate an estimate in 3 dimension.

J

sampath jayashantha

unread,
Jul 9, 2020, 11:42:11 PM7/9/20
to Jason Mayes, TensorFlow.js Discussion
Hi Jason,

I am still struggling to achieve this. :( Do you think your code will be available to the public any sooner ?

Jason Mayes

unread,
Jul 10, 2020, 1:35:57 PM7/10/20
to sampath jayashantha, TensorFlow.js Discussion
If and when it gets approved I will announce on my social media (Twitter / LinkedIn) so feel free to follow there for updates.

sampath jayashantha

unread,
Jul 10, 2020, 9:50:42 PM7/10/20
to Jason Mayes, TensorFlow.js Discussion
Hi Jason,

Thank you very much. It seems that calculating the measurements on the fly would make some issues. Because every user does not have fast enough computers to run these algorithms. Also I am no any good at js. So my approach is user have to click two pictures thru the web page and those two pictures will be uploaded to the server. Once the pictures are uploaded I am trying to do the maths using python to do the measurement calculation.
Actually I am a system guy. My father has a local custom tailor business. Because of this covid issue customers are afraid to come to give the measurements. Accurate measurement is the key factor of this business. What I am trying to do it take his business online while addressing the key barrier which he has for the online measurement taking part.
Thx Jason. Will update you the progress. 

Jason Mayes

unread,
Jul 13, 2020, 1:24:53 PM7/13/20
to sampath jayashantha, TensorFlow.js Discussion
No need to upload to the server though - even if slow, it would only take maybe a couple of seconds or so to get a result on older devices when I last checked for bodypix using highest quality settings.

You can simply have a nice preloader animation whilst it is crunching the data. That way you can write code once, and if it is a slow device you can simply request a image upload to front end, wait for results, and show user, and if it is fast, you can offer live calculation like I did.  If you want to get started with JS check out Code Academy that offers free course to learn JS pretty fast: 


Also for privacy reasons given the use case I would encourage doing client side so people who are sending photos of their bodies are not sending to some server which could be intercepted or if not removed and destroyed from the server hard drive properly could be an issue. 

By doing all on the client side their data never leaves their own computer so keeps user data images private,  is destroyed after inference is complete, and potentially could cost you less too as you do not need to keep a server running for people who do choose to use the live calculation version if they are on laptop or such. You can simply host the model on a CDN which is much cheaper.

PS yes your use case makes complete sense.  I would love to see the final result when it is ready!

Jason

sampath jayashantha

unread,
Jul 14, 2020, 11:19:49 PM7/14/20
to Jason Mayes, TensorFlow.js Discussion
Hi Jason,

Thank you very much for the motivational reply. It means a lot to me. For the waist and chest calculation part I did some research on the internet and found a few research papers which tried to extract human body measurements from 2G images. I tried those formulas and applied them on the front and side images. Unfortunately the predicted value is two to three inches differ from the real measurement. Below I have mentioned the different equations which I tried myself. But I saw on your demonstration the difference was below 1cm which is quite impressive. If you don't mind may I know what exact resource you used for the waist measurement calculation ?

Formulas which I tried :

image.png+ Conversion factor

image.png
image.png

Jason Mayes

unread,
Jul 15, 2020, 4:04:14 PM7/15/20
to sampath jayashantha, TensorFlow.js Discussion
I invented my own algorithm. I did not use any paper so I have no reference here - though I was reading up on human anatomy to understand the ratios of most human bodies to allow me to estimate what my search area was for given parts of the body to narrow it down and to be more efficient. 

Main thing is to notice how the segmentation can be noisy and to average over time to find the max bounds for things. Also I use CM for user height (not inches) as the better estimation of true user height leads to more accurate results too. Inches are just not a very precise unit.  Hope that helps.

Sanskar

unread,
Jul 24, 2021, 10:13:41 PM7/24/21
to TensorFlow.js Discussion, Jason Mayes, TensorFlow.js Discussion, sampath jayashantha
I am earnestly interested in this feature.  I tried using bodypix but could only reach up to segmentation and coloring part. I want to get the height of a user and their waist and chest size. I have a codesandbox as well. Can anyone help me where should I fiddle to get the size? Any help is highly appreciated. 

https://codesandbox.io/s/tsflow-body-segmentation-forked-etjni?file=/src/App.js

Mohammed Jabir

unread,
Oct 4, 2021, 4:45:22 AM10/4/21
to TensorFlow.js Discussion, sampath jayashantha, TensorFlow.js Discussion
Is your source code is public ?
Reply all
Reply to author
Forward
0 new messages