Page 1 of 2

Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 10:40 am
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)

Re: Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 4:06 pm
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 :)

Re: Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 5:47 pm
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.

Re: Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 6:12 pm
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 :)

Re: Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 6:40 pm
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.

Re: Simple fix for avatar head shots

PostPosted: Fri Jul 12, 2013 6:58 pm
by Tsar Hoikas
Bad news. The females don't work on MOULa. I suspect the FOV fixes will need to be backported.

Re: Simple fix for avatar head shots

PostPosted: Sat Jul 13, 2013 2:20 am
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.

Re: Simple fix for avatar head shots

PostPosted: Sat Jul 13, 2013 3:29 am
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.

Re: Simple fix for avatar head shots

PostPosted: Sat Jul 13, 2013 3:57 am
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!

Re: Simple fix for avatar head shots

PostPosted: Sat Jul 13, 2013 4:16 am
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