Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: 1% on February 18, 2013, 01:14:44 AM

Title: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: 1% on February 18, 2013, 01:14:44 AM
I've been trying to fix the high res silent pics but have a few Qs.

In consts.h

Real Sensor res:
#define SENSOR_RES_X 5472
#define SENSOR_RES_Y 3648

5x zoom buffer size is size is 1104x736 so multiplied by 5
#define SENSOR_RES_X 5520
#define SENSOR_RES_Y 3680

But from printing afframe[2], afframe [3] coordinates for center in regular lv and "x1" zoom mode are 2460 x 1456
In 5x mode this changes to 2184x1456
In 10x its 2640x1648

So I set it by the formula of center *2 for 5x mode
#define SENSOR_RES_X 4368
#define SENSOR_RES_Y 2912

Is this correct?

Also notice that when AF is off vs on the lowest X you can move to changes. In 5x it starts at 24, in 1x its 0.
The Y is weird, its 285 in x1 mode and 301 in x5 mode.

So when I change

    int x0 = (SENSOR_RES_X - NC * 1104) / 2;
    int y0 = (SENSOR_RES_Y - NL * 736) / 2;

do I have to subtract these values? to get correct 0,0? I can get the pics lined up with the 5x sensor res but they repeat the first line and move over a column.

From playing with it more, it seems a math problem. The size doesn't want to divide evenly by 5 and not sure if the LV buffer size matches with coordinates in the zoom box.

I think the above line sets the start point and then it moves in the loop below it.
Title: Re: Fixing high res pics on other cameras: LV coordinates.
Post by: 1% on February 18, 2013, 05:20:51 PM
I've found the zoom box is offset from the buffer. I found the offset by getting the center points and comparing the "real" size center to allowed center.

Also think that the 10x buffer is the same as the 5x buffer just allows different zoom positions. I took the exact same shot in 10x as 5x. Will post some test pics of what I'm getting. I can line up a 5x image but have extra garbage around it. Image is smaller than what multiplying out the buffer size would lead you to believe.
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: 1% on February 18, 2013, 06:15:10 PM
Regular Silent Pic
(http://i.imgur.com/vyBQNxAh.jpg)

5X offset 5x Zoom

(http://i.imgur.com/ADOw4vmh.jpg)

5x Offset 10x zoom

(http://i.imgur.com/TjSjOMhh.jpg)


10x Offset 5x Zoom

(http://i.imgur.com/gU0bjRfh.jpg)

10x Offset 10x Zoom

(http://i.imgur.com/Po5Wwhuh.jpg)
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: 1% on February 19, 2013, 03:41:43 AM
Alignment is fixed. There can only be 4 rows of height but 5 rows of width

#define SENSOR_RES_X 4368
#define SENSOR_RES_Y 2912


#if defined(CONFIG_6D)
    int x0 = ( (SENSOR_RES_X + 1152  - NC * 1104 ) / 2);
    int y0 = ( (SENSOR_RES_Y + 768 - NL * 736 ) / 2 ) + 300;
#else
int x0 = (SENSOR_RES_X - NC * 1024) / 2;
    int y0 = (SENSOR_RES_Y - NL * 680) / 2;
#endif
#if defined(CONFIG_6D)
   for (i = 0; i < NL-1; i++) // Needs to be 5:4
#else
   for (i = 0; i < NL; i++)
#endif
    {
        for (j = 0; j < NC; j++)
        {
            // afframe[2,3]: x,y
            // range obtained by moving the zoom window: 250 ... 3922, 434 ... 2394 => upper left corner
            // full-res: 5202x3465
            // buffer size: 1024x680
            bmp_printf(FONT_MED, 100, 100, "Psst! Taking a high-res pic [%d,%d]      ", i, j);
#if defined(CONFIG_6D)
            afframe[2] = x0 + 1081 * j;
            afframe[3] = y0 + 736 * i;

#else
            afframe[2] = x0 + 1024 * j;
            afframe[3] = y0 + 680 * i;
#endif
            prop_request_change(PROP_LV_AFFRAME, afframe, 0);
            //~ msleep(500);
            msleep(silent_pic_sweepdelay);
#if defined(CONFIG_6D)
            FIO_WriteFile(f, vram->vram, 1104 * 736 * 2);
#else
            FIO_WriteFile(f, vram->vram, 1024 * 680 * 2);
#endif
            //~ bmp_printf(FONT_MED, 20, 150, "=> %d", ans);
            msleep(50);
        }
    }
   
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: Michael Zöller on February 19, 2013, 09:33:25 AM
Great work. thanks for looking into it! On what cameras should this work now?
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: 1% on February 19, 2013, 03:34:55 PM
So far lined up for 6D. Will it work on 5d3?
(http://i.imgur.com/ZRid4Brl.jpg) (http://imgur.com/ZRid4Br)
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: a1ex on February 19, 2013, 03:55:38 PM
I must be drunk then... I see some double letters :P

What about using HD buffer size (vram_hd.width/height) instead of hardcoded numbers? This should make the code more portable.

Also check the NL-1, it's probably the autofocus bug (on 550D you can only use 4x5 and 5x5 in MF, but not in AF).
Title: Re: Fixing high res pics on other cameras: LV coordinates. [Example Pics]
Post by: 1% on February 19, 2013, 04:19:42 PM
I'm using MF only. The ratio is different, they are 5:4 not 4:5. I'll try it a different way, changing the L and C first and figure out a way to do non hard-coded numbers. The problem is translating allowed zoom window coordinates so there is no doubling/overlap.

0,0 is actually 24, 301