Bone tracks pixel colour.

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Bone tracks pixel colour.

Post by chucky »

Bone tracks pixel colour from image layer.:shock:
You see where I'm going with this?

Ok, Ive been searching scripting the forum and I can't find anything on this little topic (besides debates on the artistic merit of motion capture, elsewhere in the forums.)
I've also been scouring the web for lua's in existence for other apps, that do something in this vein but- no banana.
Ok so I can see that I will never be able to write a script myself, although I have played with Vern's excellent gravity/ collision script -very cool Vern.

Is it possible ? That' what I'm really asking. If the consensus is yes, then I might try harder to piece together snippets of code for the experts here to examine. Waddyareckon? :twisted:
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

It is possible... I think... maybe...

I remember stumbling across that in the script reference. You can evaluate the opacity and color of a pixel at a specific spot but I think it's "all or nothing"... meaning, it's either 100% opaque or not... it's either black or white. I maybe wrong. I don't think you can specifically check for an exact color... at least I don't have a clue.

It could be problematic though... a script like that would have to run constantly. What happens if the "pixel" isn't there? How would it find it?

The bigger question... why? There are so many easier ways to animate why do you need it based on an image? Is it for following a path? Sticking to a point on the image? Both of those things are static elements. You could do the same thing using regular animation techniques in AS.

-vern
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

I think Chucky is referring to motion capture. If a bone could follow a specific color pixel, then you might be able to do the whole ping-pong ball kind of thing.

Sounds interesting, but I think you'd need a separate color for each following bone. Even if you could specify color, the video quality would have to be really consistent. Or each bone would have to cover a hexadecimal range.

I think you'd be better off manually matching vector points to the video in lieu of ping-pong balls, then maybe have a script that can follow this point motion.

Actually now that I think about it, a script that makes bones follow point motion could be really useful. It may be a way to match one character or element's movement to another.

Just thinking out loud here. :wink:
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

Yes that what im thinking, motion capture, like the ping pong ball thing.
I have no special preference for this but I think it could be very cool using anime.

it would be easy enough to make a video reference file plain black and white, or a limited palette of multicoloured balls. I have found a detect colour range lua, so I think that's not so hard to replicate or modify that part of the concept and append it with the bone tracking element. I guess the trick is to get the numbered bones to match the X/Y transformation/position of the average centre of the x/y position of the colour ranges from the movie file.It might take an embedded script on both the bone and image/movie layer to do it, but hell I actually don't have the foggiest about this stuff yet, clearly.

I know roto would be an obvious solution, but I love the idea of the immediacy of the mocap option, I think it could produce some cheeky and funny animations, plus imagine if we could get bone length to follow suit. :!:
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

D'oh!

I had a brain freeze. Motion capture. Now I get it. Normally this kind of thing wouldn't appeal to me... but I can see how it might be useful.

Would your idea need to be applied to animated images? Like a movie file inserted into an image layer in AS? That would make the most sense to me for motion capture.

I still get stuck on how to "track" the movement in AS using lua. I think this is why motion tracking software has been expensive up until recently. It takes a lot of effort and computational power to get accurate and "smooth" motion from motion capture.

If the spot being tracked moves from one frame to the next or it is intended to "follow" a line of color, the script would need to evaluate all the pixels in a radius around a specific pixel, then do this over and over on subsequent frames.

It could bog down.

In most scripts the location of something is already "known". Yes things move and change but you can reference the moving items and get their properties or new locations and apply it to something else.

In this case the script would need to FIND the location of an unknown pixel value somewhere on the screen. It sounds complicated to me. Not something really simple or easy to pull off.

-vern
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

You got it Vern, I understand this could get complicated if applied to every frame, maybe if it did the computation once to follow the centre of the pixel colour range location and then pas the information to a vector which minimises the keys like in the draw stroke settings of anime? I hope this makes some kind of sense.

I am continuing my search for coordinate mapping of pixel scripts, I will post them when I get the best relevance to this mocap idea.
Last edited by chucky on Thu May 29, 2008 1:54 pm, edited 1 time in total.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Regardless if the motion capture would represent a lot of effort to the AS script capabilities and the technical difficulties for a proper implementation, how can it be implemented?
I don't see any scripting interface to evaluate a pixel color in the current loaded image layer... If it would exists I prefer to develop a color picker instead a motion traker ;)

-G
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

woah , and I thought the colour evaluation would be the easy part. :cry:
That's too bad, now I understand why there isn't a colour picker in anime.
What a bummer.
Weird though that the swatches are png's and we can pick the colours from there. The mysterious world of coding is a mysterious one indeed.
Phew, thanks Genete you saved me from a frenzy of excitement. :lol:
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

You could program motion of an object in AS according to a rotoscope if you really want to.

Let's assume that you have a pure-color dot moving in a video file... you haven't explained where it came from or why, but we'll take you at your word.

Let's further suppose that you've cleaned out the frames so the pure color dot is against a pure color background.

OK, then, dump each frame as a bitmap and digitize them using Inkscape, Illustrator, Corel, or a fabulous subscription to VectorMagic.com (highly recommended).

Save them to SVG format, which is as close to English as graphics will ever be.

Look for the x and y values of the dot in each frame.

Use that in your Lua script.

How does that sound?
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Post by synthsin75 »

Look for the x and y values of the dot in each frame.

Use that in your Lua script.
So basically what I said above about a script that will make bones follow vector points, right? :? :)
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

synthsin75 wrote:So basically what I said above
Exactly.

Minus the part about "how do I make a fresh pot of coffee and establish world peace, all without ever leaving Anime Studio"

:lol:
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

chucky wrote:woah , and I thought the colour evaluation would be the easy part. :cry:
That's too bad, now I understand why there isn't a colour picker in anime.
What a bummer.
Weird though that the swatches are png's and we can pick the colours from there. The mysterious world of coding is a mysterious one indeed.
Phew, thanks Genete you saved me from a frenzy of excitement. :lol:
Unfortunately not all the written code has a scripting interface. This is double edge tool for this software. Mor Scripting interface makes it more flexible for add pluggins (what would love a lot of users where of course Vern is included) but it could convert the program to a community developed one that wont make earn more money to a software company. So yes, script interface but not so much ;)
-G
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Post by chucky »

Thats a pretty cool idea human, nice one.
But I guess rotoscoping is the quickest and most enjoyable if there's no way to automate the pixel tracking in anime.
I like how you thought around the idea though . 8)
If Mike had more time and resources he could do a 'super pro' version, I'd gladly pay more for any of the features that I hear about ...in the forum.
I know it's pretty cool now, I'm just greedy for features especially more shape fx. :)
Post Reply