Simple fix for avatar head shots

Announcements and discussion regarding any projects related to Cyan Worlds' Plasma Engine including (but not limited to) CyanWorlds.com Engine, Drizzle, OfflineKI, PyPRP, and libHSPlasma.
johnsojc
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Simple fix for avatar head shots

Post by johnsojc »

From a question about problems with avatar head shots I came up with this fix to xAvatarCustomization.py which fixes the aspect ratio.

(change 4/3 to 4/4) and
(1024, 768 to 1024, 1024)

Code: Select all

                   elif btnID == kAvatarCameraID:
                        print "ACA: Taking a picture!"
                        picCam = ptCamera()
                        picCam.setAspectRatio(4/4)
                        AvCustGUI.dialog.hide()
                        PtStartScreenCapture(self.key, 1024, 1024)


and (change 200 to 250)

Code: Select all

        if currentgender == 1:
            print "Female Screenshot"
            TestMap.textmap.drawImageClipped(0, 0, image, 55, 250, 512, 512, 0)
Tsar Hoikas
Councilor of Technical Direction
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
MOULa KI#: 23335
Location: South Georgia
Contact:

Re: Simple fix for avatar head shots

Post by Tsar Hoikas »

I'll give it a shot! If things look good, I can commit this to the git repository (and open a pull request on the OU code as well) for you. Can you PM me an email address we can use for author information in the repository? We do like to maintain some credit in our history :)
Image
johnsojc
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Simple fix for avatar head shots

Post by johnsojc »

After chasing thru all the code for screen grabs for about 3 hours, it suddenly dawned on me that the code was grabbing a 4x3 rectangle and outputting a 4x4 square jpeg... (duh!). Once that idea sunk in, it took about 3 minutes to fix it plus a couple of more tries to get the female avvie clip coordinates right.
Tsar Hoikas
Councilor of Technical Direction
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
MOULa KI#: 23335
Location: South Georgia
Contact:

Re: Simple fix for avatar head shots

Post by Tsar Hoikas »

This code is really crazy. I had the pleasure of fixing FOV calculations many moons ago and totally overlooked this. :roll:

I've committed your patch to our git repository and will open a PR on OpenURU's repository as well. I'm sure this change will be well received in the next updates :)
Image
johnsojc
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Simple fix for avatar head shots

Post by johnsojc »

Makes me wonder about the screen grabs that the KI makes. I recall thinking those weren't quite right as well. Something to look at when I get bored this weekend.
Tsar Hoikas
Councilor of Technical Direction
Posts: 2180
Joined: Fri Nov 16, 2007 9:45 pm
MOULa KI#: 23335
Location: South Georgia
Contact:

Re: Simple fix for avatar head shots

Post by Tsar Hoikas »

Bad news. The females don't work on MOULa. I suspect the FOV fixes will need to be backported.
Image
Christian Walther
Posts: 443
Joined: Sun Jun 08, 2008 3:10 am
MOULa KI#: 0
Location: Switzerland

Re: Simple fix for avatar head shots

Post by Christian Walther »

From just looking at the changed Python code, I don’t quite understand yet why this is supposed to fix it. If everything is working as expected under the hood (which it apparently isn’t), then surely taking a 1024x768 picture with a 4:3 camera should result in an equally undistorted result as taking a 1024x1024 picture with a 1:1 camera?

Maybe I’ll take a look at the C++ code and experiment a bit myself.
johnsojc
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Simple fix for avatar head shots

Post by johnsojc »

I opined that the problem might be in the conversion of the 4x3 image to a 4x4 jpeg. I will check using other jpeg converters to see if this is an issue with jpeg. Simply resizing a 4x3 image and converting it to 4x4 jpg in an image editor should give a clue.

Alternately, it might be in the C code as you suggest. I would probably start with the draw image clipped where the 512x512 output is set.
Christian Walther
Posts: 443
Joined: Sun Jun 08, 2008 3:10 am
MOULa KI#: 0
Location: Switzerland

Re: Simple fix for avatar head shots

Post by Christian Walther »

OK – in other words, you don’t understand it either. :) You just happened on a way that appears to work by experimentation. That’s fine. Thanks!
johnsojc
Posts: 246
Joined: Sun Dec 07, 2008 10:27 am

Re: Simple fix for avatar head shots

Post by johnsojc »

It does not make me happy to find a solution just by fiddling with the values. Something is definitely wrong in the way the code handles the images. As you said, it SHOULD work as originally written. I just manually grabbed a 4x3 screenshot in my closet, clipped a 512x512 image of it at (55,60) for the male avvie, and saved as a JPEG. Perfect image.

Now how is the code actually doing it? The only way I can think that the image is being distorted is the clipping function does not actually get 512x512 pixels but some 4x3 ratio that causes the save to jpeg to distort. I will see if I can duplicate the distortion by playing with some conversion tests. Maybe we can following the results back to the code that produces them (yeah, I always work backwards from the result to the code :) ).

Now I'm wondering if the raw pixel stream has a 1 to 1 correspondence with the displayed pixels when a particular resolution is specified. Is it scaling raw pixels to displayed pixels? If so then what is being cropped?

EDIT :Ah ha! I found where the distortion happens! When you press the camera button, the screen flashes as the screen grab occurs. That image is distorted and the cropping is simply grabbing the distorted image. I used a FRAPS movie to actually see this but so far have not been able to grab that frame to show you. I will post the image if I can get it (Why did my video editing software have to be on my laptop that died :().

Here is the distorted image... this is what pops up when you click the camera button. I couldn't get the video to upload <snarl>
Show Spoiler
Last edited by johnsojc on Sat Jul 13, 2013 5:28 am, edited 2 times in total.
Post Reply

Return to “Plasma Development”