0

I wanted to translate a set of reference points on contour to a set of corresponding target points. There are total 8 points on each contour.

reference and corresponding target points

In order to calculate the rotation & translation vector, I was using Math.Net Numerics library to perform SVD calculation - The idea came from this URL (page 3-7):

But somehow I noticed that transformation done using result from SVD calculation seems inaccurate. The result as shown below:

Unity result after applied translation vector calculated from SVD

The transform supposed to move reference points to target points as close as possible, but as highlighted, it moves far away from target point.

In addition, I also did a simple test whereby I calculated centroid for both contours and perform deduction: (TargetCentroid - RefCentroid = translation vector). The final transformation result is the same as going through SVD.

Am I did something wrong? Can anyone suggest a better solution to transform ref point to target point?

Edit: 1. Garment transformation from reference model to various target models

Garment transformation

mcmc
  • 11
  • 6
  • umm .. just adjust the **scale** in the Inspector. if you attach a marker to say the elbow, after you adjust the **scale**, the marker will be in the new correct position. – Fattie Mar 03 '16 at 11:53
  • @JoeBlow This has to be done on-the-fly at runtime - The problem is all the target models are scaled at (0,0,0) despite the size during import. The fitting shouldn't be hard-coded as the target models' size is different. – mcmc Mar 04 '16 at 02:56
  • This has to be done on-the-fly at runtime? **Unity works at runtime**. of course just adjust the `Transform` in code dude. – Fattie Mar 04 '16 at 03:51
  • All models have proper measurement in centimeter in each part, as well as those garments, it is not as straightforward as adjusting scaling through inspector or procedurally – mcmc Mar 04 '16 at 04:10
  • as I say you use marker objects, say 10cm apart, on the items. It's completely standard. Unity works in actual meters. obviously if you want t increase a (say) diamater by a factor, of course you increase the (say) radius using a basic geometrical formula, (example, d=r2pi, etc) – Fattie Mar 04 '16 at 12:53

1 Answers1

0

This seems like an over complicated solution to the problem.

If you have the target points, you can just Lerp the given points to their corresponding target points.

Or if the target is the same mesh but of different scale and rotation as in the picture, you can just Lerp the transform values, scale and rotation respectfully, without the need to go over all the points individually.

Using Vector3.Lerp

Edit: Additionally, lerping will cause all the points to reach their targets at the same time, which is, in most cases, the desired behavior.

Max Izrin
  • 938
  • 1
  • 11
  • 17
  • Thanks for your reply. Actually I am building up a virtual fitting room app. The reason why I am not using Vector3.Lerp is because I need to get the translation vector so that the respective points will be able to translate to target points. The translation vector will be used later to transfer the garment from reference model to target model as well. – mcmc Mar 03 '16 at 10:48
  • @mcmc You can also try making the garment be a child of the model with transform.setParent( , true). Passing true to for the second argument should keep the garment location in world coordinates, and you can lerp that offset to 0 to make it glide onto the model. Saving the local coordinates of the garment as the desired vector before you do. – Max Izrin Mar 03 '16 at 10:56
  • Thanks for your suggestion. The target model has dynamic size and mesh. Lerping may be able to glide the garment onto model, yes, visually it might solve the problem, but it seems couldn't get the realistic "fitting" data, eg: if user tries to put on smaller garment, it should highlight tight section - the real measurement is key ;) – mcmc Mar 03 '16 at 11:09
  • @mcmc In that case I would store measurement data in the same way tailors do, circumference of things and such (I don't really know the terms). I'm into game development, so my first though is how to cut corners with these kinds of calculations, if it works visually, that'd be good for me :) and the rest is hidden numeric data that's handled separately. – Max Izrin Mar 03 '16 at 12:12
  • Also, if it's for mobile, how much of this detail the user is actually going to see? – Max Izrin Mar 03 '16 at 12:21
  • Yup, you are right, bulk of the data are pre-processed and stored separately. Data loaded on demand and the actual visualization takes about 1 sec for now, SVD alone took ~20ms. I wish to avoid those heavy calculation as well - If I able to map out the translation vector that translate all points from ref to target model, most of my problem gone ;) I did consider Iteractive Closest Point(ICP), but I guess it's for unknown corresponding point pairs? – mcmc Mar 03 '16 at 12:48
  • @mcmc How do you know which points correspond to which? I would add anchor points to the garments and models, and use those to attach the garments to models, and calculate using the hidden values if it fits right or not. – Max Izrin Mar 03 '16 at 14:36
  • After the garment is attached, you can get the distances between its anchor points to see if it's being stretched or not. And the hidden values of circumferences and such will determine if it's stretching around the model's limbs. – Max Izrin Mar 03 '16 at 14:39
  • Sorry, I don't really get the idea, can you elaborate more on adding the anchor points? Assuming there are S, M, L size garments on reference models and these 3 garments will virtually fit(transform) on various target models (bigger or smaller user body size than reference model) - Have you previously done similar stuff before? – mcmc Mar 03 '16 at 15:28
  • Added visual garment transformation image as reference in my question. – mcmc Mar 03 '16 at 15:49
  • "clothing" is a totally well-explored field in Mixamo and Mecanim. it's impossible you'd start implementing this from scratch – Fattie Mar 04 '16 at 03:53
  • @JoeBlow - you are right. To visualize the garment only, Mixamo or 3D garment object simulation are more than enough. Btw, I will be using Physx to simulate the transformed garment on target model – mcmc Mar 04 '16 at 04:14
  • @JoeBlow - Can you elaborate more on applying anchors on meshes? I am not so sure how others deal with real measurement garment fitting problem ;) – mcmc Mar 04 '16 at 04:17
  • @mcmc Sorry for disappearing for a while, forget the anchors thing, not a good idea, my bad. Something else instead: You seem to be able to fit the garments on the models well, it's just the measurements that are unknow, right? Can you compare a fitted garment mesh with an unfitted one? or maybe to a fitted one that you know fits perfectly? Check the distances between points on the 2 meshes, and using a variable for elasticity of each fabric type, determine if the fit is "tight" or "loose". – Max Izrin Mar 04 '16 at 17:46