Tue, Feb 18, 1:03 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Moderators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2025 Feb 18 7:53 am)



Subject: Paging Python Maestro Ockham! Simple adaptation of Smoother script possible?


Tguyus ( ) posted Tue, 25 July 2006 at 10:18 AM · edited Tue, 18 February 2025 at 10:22 AM

Hi Ockham!  Long time no "see"! 

I was toying with some BVH files the other day, trying to smooth out the jerkiness.  Your great Smoother script definitely improved many of the motions, and for some others I was able to get the effect I needed with your Emphasparsizer script (you may recall this as the script you made which embedded the Sparsifier script inside the Emphasizer script... which I use ALL the time).

However, there were some motions where neither of the scripts helped me get the motion changes I sought, and I realized it was because both are focused on comparisons of the current frame with adjacent frames.  It occurred to me that what I needed was a sparsifying process which instead simply kept every 3rd or 4th or 5th keyframe and deleted all intervening keyframes (i.e., more of a sampling approach).  For some motions, more frequent keyframe sampling would be best while for others a sparser sampling would be better.

So here's my idea:

1.  Start with the Smoother shell, which starts by letting the user choose one or more target body parts (I don't think it's worth the trouble to go down to the individual parameter level, and given that it is arms and hands and fingers which are of most interest it would be much better to be able to operate on multiple body parts in one python run).

2.  An entry box lets the user specify the periodicity of the sampling (i.e., preserve every 3 keyframes or every 4 keyframes or whatever number is entered).

3.  Keep keyframe 1 but delete all keyframes for all parameters of that body part until the next "keep" keyframe (with the next keep keyframe defined as frame (1 + sampling value) so for a sampling value of 3 we would keep frames 1, 4, 7, 10, etc.

I have the sense that you may be focused more on non-Python stuff these days, but after two hours of trying to figure out how to adapt the Smoother or Sparsifier code myself, I thought I should return to the master once more and see if I've hit my lifetime limit on python favors yet!  Heaven knows you've done so many such favors for me (and all of us), that I certainly understand if the idea isn't inspiring.  But thanks for at least considering it!

cheers.... Tguyus

 


ockham ( ) posted Wed, 26 July 2006 at 2:30 PM

Yeah, I don't hang here much since the forum switched to

its present virus-like software.  Better chance of catching me

lately at 3DCommune, which doesn't reboot my computer.

 

I'll try what you're proposing.  It's certainly possible,

but we'll have to try it out to see if the 'periodicity' will actually

do what you're after.   Reminds me of some tricks I used to

do in pitch-detection and speech processing..... 

 

My python page
My ShareCG freebies


ockham ( ) posted Wed, 26 July 2006 at 4:13 PM

Hmm.  Could you send me the version of Smoother you're using?

The latest Smoother doesn't go by two's at all......

http://ockhamsbungalow.com/Python/Smoother3.zip

My python page
My ShareCG freebies


Tguyus ( ) posted Wed, 26 July 2006 at 9:54 PM

Quote - Hmm.  Could you send me the version of Smoother you're using?

The latest Smoother doesn't go by two's at all......

http://ockhamsbungalow.com/Python/Smoother3.zip

Hi ockham!  Great to hear from you!

The version I was tinkering with is the version of Smoother3 I got from Vanishing Point.  I double-checked and the file is the same Jan 31 / 8:51am vintage as the version at the link you pasted in above.

BTW, I did succeed in adapting Smoother to get close to accomplishing another routine I needed.  This crude prototype, momentarily dubbed "Foot DeKinker", takes the Smoother script and changes the conditional tests in the frames run to instead do the following:

if (ThisVal > 60): NeedsDelete.append(f)
elif (ThisVal < -60): NeedsDelete.append(f)

My purpose here was to eliminate all the whacked out chunks of keyframe for Twist, Side-Side, and Bend on the feet which happen when you turn on IK for an existing animation (like from a BVH), do some pose mods, and turn IK back off. 

NOTE: the reason I'm doing this is that some pose files I bought from Eclipse animate the buttocks.  By turning on IK for the feet then zeroing out the x, y, and z rotations of the buttocks, then turning IK back off I can get (virtually) the same leg motions and foot placements without using buttocks motions.

By running the script after turning IK back off again, and choosing only the feet from the body parts list, all the keyframes where x, y, z rotations of the feet exceed an absolute value of 60 just get deleted.  Since the whacked out chunks tend to be short, the resulting spline interpolations tend to to be satisfactory.

Next I'm going to try doing a hardwire limiting of the body parts list to include just the feet.  I think I can guess how to do that by studying the code you used to specify just the chest body part in the hardwired Jiggles script you so kindly made for me a year or so ago (which still works GREAT!).

When I tinker with these scripts of yours, though, I feel like a kid with fingerpaints dabbing at a Rembrandt.

cheers... Tguyus


Tguyus ( ) posted Wed, 26 July 2006 at 10:07 PM

Quote - I'll try what you're proposing.  It's certainly possible,

but we'll have to try it out to see if the 'periodicity' will actually

do what you're after.   Reminds me of some tricks I used to

do in pitch-detection and speech processing..... 

 

I did some experiments earlier today to test the principle.  My goal was elimination of jerky hand and arm motions from a BVH-derived animation.  The steps I took to eliminate all but every 4 keyframes:

1.  Start with 325 frame animation.  Save the pose to the library.

2.  Retime entire animation to 81 frames (that is, roughly 1/4 compression).

3.  Retime animation back from 81 to 325 frames.  Result: all but every 4th keyframe gone.

4.  Save "arms" pose to library, selecting only collar outward parts.

5.  Reset animation to 1 frame.

6.  Reapply main pose file.

7.  In animation pallette, delete all keyframes for collar outward.

8.  Apply "arms" pose.  Result = original animated pose with arms keyframes reduced to 1 in 4 periodicity.

At least for the test animation, the effect was excellent!  Very smooth arm and hand movements which still tracked very closely to the original motions.

But as you can see, using the above process is WAY too cumbersome, so a python script to do keyframe sampling on selected body parts would be GREAT!

Thanks for giving this some thought!


ockham ( ) posted Thu, 27 July 2006 at 9:04 AM

Okay, see if this does the job.  I don't have any present animations long

enough to try it meaningfully!

 

http://ockhamsbungalow.com/PPP/Smoother4.zip

My python page
My ShareCG freebies


Tguyus ( ) posted Fri, 28 July 2006 at 12:05 PM

Quote - Okay, see if this does the job.  I don't have any present animations long

enough to try it meaningfully!

 

http://ockhamsbungalow.com/PPP/Smoother4.zip

Well, I think the pieces are almost there!  I ran Maximum Densifier to fill a long animation with keyframes then ran the script with a Period of 4.  Basically, it deleted just 1% or so of the total keyframes. 

I went into the script and saw that the conditional tests to determine which keyframes should go into the delete bin were the same as Sparsifier: i.e., checking neighbors to see if a given keyframe was a local max or local min.  And very few keyframes were chosen because I guess the tests were only applied to those keyframes which met the "Period" term.

I then changed the script so every frame passed to the conditional tests would be deleted.  That is, I wanted to see ihow the Period term was classifying the keyframes.   I ran the modified script with a Period of 4 and saw that every 4th keyframe was deleted and all the intervening keyframes were kept.

So I guess the question is: can the delete bin test be coded so that all keyframes tagged as meeting the terms of the Period test are KEPT, then all OTHER keyframes deleted?  So rather than NeedsDelete.append(F), is there a command which does something like NeedsKeep.append(F) then another command which deletes all keyframes except those in the NeedsKeep bin?

That would do the straight period sampling I was hoping for.

Many thanks again for being willing to explore this!

Tguyus


ockham ( ) posted Fri, 28 July 2006 at 12:19 PM

So, you just want every Nth keyframe to remain, regardless

of any other conditions?

My python page
My ShareCG freebies


ockham ( ) posted Fri, 28 July 2006 at 12:24 PM
Tguyus ( ) posted Fri, 28 July 2006 at 1:08 PM

Quote - So, you just want every Nth keyframe to remain, regardless

of any other conditions?

Yes, that's it!


Tguyus ( ) posted Fri, 28 July 2006 at 1:09 PM

Quote - As in this one, f'rinstance?

 

http://ockhamsbungalow.com/PPP/Smoother5.zip

Hmmm... I ran it once with and once without specifying Period and it didn't delete any keyframes for the selected body part for either run.


ockham ( ) posted Fri, 28 July 2006 at 2:07 PM

Hmm.  I'll check it......

My python page
My ShareCG freebies


ockham ( ) posted Fri, 28 July 2006 at 2:20 PM
Tguyus ( ) posted Fri, 28 July 2006 at 7:20 PM

Quote - As the optometrist says, "Better this way?"

http://ockhamsbungalow.com/PPP/Smoother6.zip

YES!  Works perfectly!  Ockham, old friend, you are, and shall always be, the man. 

You might want to think of another name for this really useful script, though, since Smoother provides another very useful, but different, function. 

In the interim, I've embedded it in my python utility menu as ... (drum roll) ... "Periodizer."  Ok, ok.  I'm sure someone can think of a better name, though I kind of like how short yet descriptive it is.  Other options might be "Keyframe Cleaner" or, in the spirit of Emphasparsifizer, "Periodicitizer." (grin)

Anyway, I heartily recommend this script for anyone who is trying to smooth out BVH-based animations, though I recommend applying it mostly to body parts from the Abdomen upward.  Users might also want to grab the Maximum Densifier script to make sure they can lock in keyframes for all frames, when needed, before running the Periodizer.  That way they'll get keyframes at all the frames which meet the required periodicity.

Again, thank you VERY much.  My models are moving MUCH more smoothly already! 

cheers!  Tguyus


ockham ( ) posted Fri, 28 July 2006 at 8:38 PM

Periodizer is a good name.   I'll rename the ZIP and add a readme.

Sorry for the confusion; the Smoother actually does a more complicated

thing than what you were talking about, and I was looking more closely at the

code than at your request!

 

Incidentally, you're right in assuming that I've been out of the herpetology

cage lately.  Mainly working on house models to be sold at 3DC, and other

architecture-type stuff.

My python page
My ShareCG freebies


ockham ( ) posted Fri, 28 July 2006 at 8:43 PM

For reference, here's the ZIP with the readme.

 

http://ockhamsbungalow.com/PPP/Periodizer.zip

My python page
My ShareCG freebies


BastBlack ( ) posted Sat, 29 July 2006 at 1:18 PM

Wow. This looks really useful. Thanks. :D btw, Where can one find the Emphasparsizer script? Tguyus, care to post some render samples? I'm curious about the effects of each script on cleaning up BVH. bB


Tguyus ( ) posted Wed, 02 August 2006 at 12:59 PM · edited Wed, 02 August 2006 at 1:00 PM

Quote - Wow. This looks really useful. Thanks. :D btw, Where can one find the Emphasparsizer script? Tguyus, care to post some render samples? I'm curious about the effects of each script on cleaning up BVH. bB

Ok, I'll try to post a brief WMV animation clip.  I hadn't really fine-tuned this animation, but did apply several of the scripts I use for BVH imports, including the Periodizer script Ockham just created.

The Emphasparsizer was a special script Ockham made when I asked him if it was possible to embed the Sparsifier function within his Emphasizer script.  I'm not sure if he ever meant this to be one of the scripts he distributes, but as the copyright holder he'd be the one to check with.

Here goes on the animation attempt...

cheers...


Tguyus ( ) posted Wed, 02 August 2006 at 1:03 PM

ok, the file was too big

I trimmed it down to a mere 200x150, 256 frames.

hope this works...


Tguyus ( ) posted Wed, 02 August 2006 at 1:11 PM

file_349860.wmv

Geez.  How small do these files have to be?  3rd attempt with really low bit rate


BastBlack ( ) posted Wed, 02 August 2006 at 10:00 PM

That bites. ;p You might want to get a Photobucket account or YouTube for uploading video. Both sites convert to streaming flash and they're free. But the best streaming video is at Cyworld. CyworldUSA just opened, but they haven't added the video feature yet. It's hard to see the details in the animation, but I think I get what you are working on. I think I've seen that bvh. Some of them are really jerky. I didn't know it was possible to smooth them out, but I bet it's tricky knowing what to leave and what to take out. I think if I were to do it, I would figure out what the keyframes are each limb (left leg, hip, right arm, head, etc), and eliminate the in-betweens based on each limb's key frames. Make sense? bB


Tguyus ( ) posted Fri, 04 August 2006 at 10:03 PM

Quote - That bites. ;p You might want to get a Photobucket account or YouTube for uploading video. Both sites convert to streaming flash and they're free. But the best streaming video is at Cyworld. CyworldUSA just opened, but they haven't added the video feature yet. It's hard to see the details in the animation, but I think I get what you are working on. I think I've seen that bvh. Some of them are really jerky. I didn't know it was possible to smooth them out, but I bet it's tricky knowing what to leave and what to take out. I think if I were to do it, I would figure out what the keyframes are each limb (left leg, hip, right arm, head, etc), and eliminate the in-betweens based on each limb's key frames. Make sense? bB

Yes, I should figure out some way to post animations which are actually viewable.  The version I posted was pretty bad.  I'll check out the sites you suggested.. and thanks for the recommendations!

As for choosing keyframes to keep or ditch, if you look at most splines in the animation graph it seems like you can often remove all but every 2nd or 3rd or 4th without the spline shifting significantly.  I think you can usually eyeball the spline and get a sense of how much you can sparsify the keyframes for a particular motion and still keep it close to the original spline (but smoother).  There are other tools available, such as ockham's sparsifier, which are also great for some situations such as eliminating all but local minimums and maximums.  I figure I'll use the periodizer script where I need to smooth a motion but can't just stick with local mins and maxes.  My experience is that most motions look smooth enough if you use spline interpolation between every 3 or 4 keyframes.  But yes, it seems like a bit of an art, this smoothing out of BVHs.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.