EOS M3 porting - page 44 - DryOS Development - CHDK Forum

EOS M3 porting

  • 746 Replies
  • 426834 Views
*

Offline lapser

  • *****
  • 1093
Re: EOS M3 porting
« Reply #430 on: 09 / September / 2017, 20:05:36 »
Advertisements
Looking at this a bit more, I don't think the error lapser saw was due to incorrect definition in CHDK, the script just has to ensure it doesn't go outside the active area.
That's true, and I fixed that problem in the script. But there's still incorrect definitions in the M3 port.

I wrote a test script that holds the shutter down in continuous mode saving jpegs, and draws a rectangle just inside the height and width of the JPEG area (6000x4000). The upper left corner of the rectangle starts at the active area left,top postion. Then I move one pixel down and to the right for each new picture afterwards. Looking at the jpeg images, I found the x and y coordinates where a rectangle is visible on all sides. On my M3, those coordinates are:

x=92, y=49

The script draws a rectangle at that position in the last photo (after you press menu to stop the script.

I noticed that the JPEG and ACTIVE areas are identical, an obvious error.

Aleft=84 Atop=46 Awidth=6000 Aheight=4000
Jleft=84 Jtop=46 Jwidth=6000 Jheight=4000

Jleft should be 92, and Jtop 49, so the active area has to extend to at least:
6092 rowpix and 4049 rows (if I'm understanding correctly).

I'll attach the script, which should work with any camera. Here's the log produced:
Code: [Select]
Camera:m3 f/w:120f platformID:12953 bit/pixel:14
version:CHDK 1.5.0 built on Sep  8 2017 23:08:23
Sat Sep  9 16:25:55 2017
x=84 y=46 w=6000 h=4000
Aleft=84 Atop=46 Awidth=6000 Aheight=4000
Jleft=84 Jtop=46 Jwidth=6000 Jheight=4000
ishots=1 x=84 y=46
ishots=2 x=85 y=47
ishots=3 x=86 y=48
ishots=4 x=87 y=49
ishots=5 x=88 y=50
ishots=6 x=89 y=51
ishots=7 x=90 y=52
ishots=8 x=91 y=53
ishots=9 x=92 y=54
ishots=10 x=93 y=55
ishots=11 x=94 y=56
ishots=12 x=95 y=57
ishots=13 x=96 y=58
ishots=14 x=97 y=59
ishots=15 x=98 y=60
ishots=16 x=99 y=61
ishots=17 x=100 y=62
ishots=18 x=101 y=63
ishots=19 x=102 y=64
ishots=20 x=103 y=65
ishots=21 x=104 y=66
ishots=22 x=92 y=49
*** Done ***
[edit]
It looks like camera_sensor.jpeg.x and camera_sensor.jpeg.y are 0?
My tests show they should be 8, and 3. Is that correct?
Code: [Select]
static int rawop_get_jpeg_left(lua_State *L) {
    lua_pushnumber(L,camera_sensor.active_area.x1 + camera_sensor.jpeg.x);
    return 1;
}
static int rawop_get_jpeg_top(lua_State *L) {
    lua_pushnumber(L,camera_sensor.active_area.y1 + camera_sensor.jpeg.y);
    return 1;
}
« Last Edit: 09 / September / 2017, 20:21:21 by lapser »
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline reyalp

  • ******
  • 14125
Re: EOS M3 porting
« Reply #431 on: 09 / September / 2017, 20:35:44 »
I noticed that the JPEG and ACTIVE areas are identical, an obvious error.
Right now the active area is defined as the same size as the jpeg area (as mentioned in my earlier post.) If the actual active area is different, then that's not correct, but you need to look at a CHDK raw image to determine the actual size of the active area.

edit:
On P&S, the CHDK "jpeg area" may not correspond very well to the real jpeg area, because the cameras do a lot of distortion correction in software. I'd be surprised if ILCs did this but I guess with Canon lenses they could
« Last Edit: 09 / September / 2017, 20:45:55 by reyalp »
Don't forget what the H stands for.

Re: EOS M3 porting
« Reply #432 on: 09 / September / 2017, 21:56:40 »
@Ant can you please attach the code you used to view your Edmac channels?

*

Offline lapser

  • *****
  • 1093
Re: EOS M3 porting
« Reply #433 on: 09 / September / 2017, 22:38:39 »
On P&S, the CHDK "jpeg area" may not correspond very well to the real jpeg area, because the cameras do a lot of distortion correction in software. I'd be surprised if ILCs did this but I guess with Canon lenses they could
I drew 6000x4000 rectangles with your raw rectangle function using only the M3 body (no lens). The rectangle edges are perfectly straight in the jpeg images. To see the rectangle on all edges, I had to move down 3 and right 9 pixels. So I suggest setting camera_sensor.jpeg.x=9 and camera_sensor.jpeg.y=3 in the port. That way when I meter the jpeg area, I'm measuring correctly. If you don't want to fix it, I'll have to live with it, but I spent a number of hours writing the script to find out the correction. It would be nice if that information was used in the port.

I'm aware of the lens distortion correction at wide angles. It goes away with a zoom camera zoomed all the way in.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline Ant

  • *****
  • 509
Re: EOS M3 porting
« Reply #434 on: 10 / September / 2017, 05:24:46 »
I'd be surprised if ILCs did this but I guess with Canon lenses they could
Yes, they can do some correction. Not sure about image distosion:


@Ant can you please attach the code you used to view your Edmac channels?
I use slightly modified srsa_4c's patch for revision 4755.
Modern CHDK versions are using double sized fonts. I don't know how disable it wihout huge code modificatoin.
My version in attachmet is not finished yet. At least Canon changed the numbering of EDMAC channels for Digic6.

« Last Edit: 10 / September / 2017, 05:27:54 by Ant »

Re: EOS M3 porting
« Reply #435 on: 10 / September / 2017, 13:23:36 »
Quote
I use slightly modified srsa_4c's patch for revision 4755.
Modern CHDK versions are using double sized fonts. I don't know how disable it wihout huge code modificatoin.
My version in attachmet is not finished yet. At least Canon changed the numbering of EDMAC channels for Digic6.
thanks.
I see you have added additional bases...that's useful information for me.
Code: [Select]
{ 0xC0F04000, 0xC0F26000, 0xC0F30000, 0xC0F57000, 0xC0F58000 };
Also trying to find stubs, like these...I don't know what firmware these are for so I can't compare to my firmware...suggestions?
Code: [Select]
NSTUB(0xFF5F3354, PackMem_RegisterEDmacCompleteCBRForMemorySuite)
http://pastebin.com/sMjiN7Ei
/** experimental EDMAC research **/
NSTUB(0xFF9F8F84 - RAM_OFFSET, CreateMemorySuite)
NSTUB(0xFF9F8D7C - RAM_OFFSET, DeleteMemorySuite)


/** EDMAC routines */
NSTUB(0xFFA00758 - RAM_OFFSET, SetEDmac)
NSTUB(0xFFA00A70 - RAM_OFFSET, StartEDmac)
//NSTUB(0xFFA00C98 - RAM_OFFSET, PopEDmac)  //~ idk, ported anyways.
NSTUB(0xFFA00C04 - RAM_OFFSET, PopEDmac)
NSTUB(0xFFA00BBC - RAM_OFFSET, AbortEDmac)
NSTUB(0xFFA00804 - RAM_OFFSET, ConnectWriteEDmac)
NSTUB(0xFFA008C8 - RAM_OFFSET, ConnectReadEDmac)
NSTUB(0xFFA00C5C - RAM_OFFSET, EDMAC_RegisterCompleteCBR)

/** register/unregister CBR names **/
NSTUB(0xFFA00C5C - RAM_OFFSET, RegisterEDmacCompleteCBR)
NSTUB(0xFFA00D44 - RAM_OFFSET, RegisterEDmacAbortCBR)
NSTUB(0xFFA00DD8 - RAM_OFFSET, RegisterEDmacPopCBR)
NSTUB(0xFFA00C98 - RAM_OFFSET, UnregisterEDmacCompleteCBR)
NSTUB(0xFFA00D80 - RAM_OFFSET, UnregisterEDmacAbortCBR)
NSTUB(0xFFA00E14 - RAM_OFFSET, UnregisterEDmacPopCBR)


NSTUB(0xFF5810A0, PackMem_RegisterEDmacCompleteCBRForMemorySuite)
NSTUB(0xFF58113C, PackMem_RegisterEDmacPopCBRForMemorySuite)
NSTUB(0xFF580DB4, PackMem_SetEDmacForMemorySuite)
NSTUB(0xFF580FD0, PackMem_PopEDmacForMemorySuite)
NSTUB(0xFF580EC8, PackMem_StartEDmac)



*

Offline lapser

  • *****
  • 1093
Re: EOS M3 porting
« Reply #436 on: 10 / September / 2017, 14:07:56 »
Here's the code in camera_info.c that calculates the value for camera_sensor.jpeg.x and camera_sensor.jpeg.y:
Code: [Select]
#if defined(CAM_CROP_ORIGIN_X)
        CAM_CROP_ORIGIN_X,
#else
        (CAM_ACTIVE_AREA_X2-CAM_ACTIVE_AREA_X1-CAM_JPEG_WIDTH)/2,
#endif
#if defined(CAM_CROP_ORIGIN_Y)
        CAM_CROP_ORIGIN_Y,
#else
        (CAM_ACTIVE_AREA_Y2-CAM_ACTIVE_AREA_Y1-CAM_JPEG_HEIGHT)/2,
#endif
In my tests, I determined that jpeg.x needs to increase by 8, and jpeg.y needs to increase by 3. You can do this by increasing CAM_ACTIVE_AREA_X2 and CAM_ACTIVE_AREA_Y2 by twice those amounts.

So platform.camera.h for the M3 should use these values:
    #define CAM_ACTIVE_AREA_X2                  6100 // not 6084 - lapser
    #define CAM_ACTIVE_AREA_Y2                  4052 // not 4046 - lapser
   
That's still within range on the sensor according to the definitions below, and will more accurately correspond with the actual active area.

    #define CAM_RAW_ROWPIX                      6112 //6096
    #define CAM_RAW_ROWS                        4060 //4056

The jpeg values are really only used for shot metering. Digital correction of lens distortion at short focal lengths (i.e. fish-eye lenses) will distort the metering area, but it's better to have this distorted area centered than not. Long focal length lenses, i.e. zoomed in, don't show much distortion, so correcting the jpeg.x and jpeg.y values will make the metering more accurate.

I've attached the corrected platform_camera.h with the above changes. I hope this is helpful.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

*

Offline Ant

  • *****
  • 509
Re: EOS M3 porting
« Reply #437 on: 10 / September / 2017, 14:27:08 »
I see you have added additional bases...that's useful information for me.
IMO these bases no more needed. Now they use addresses from the structure. See "edmac_struct"


Quote
Also trying to find stubs, like these...I don't know what firmware these are for so I can't compare to my firmware...suggestions?

I use EOS M3 fw101a. Here you can find some EDMAC functions:
Code: [Select]
CaptureSystem.c_02_EDMAC_0x02_0x1E  FC1539AE
ConnectReadEDmac                    FC369DC8
ConnectWriteEDmac                   FC369DB6
EDmacCompleteCBR                    FC369FFE
EDmacCompleteCBR_0                  FC213866
EDmacCompleteCBR_0x02               FC153938
EDmacCompleteCBR_0x1E               FC1538C4
ReadEDmac1LoadMicroCodeCompleteCBR  FC57FFE4
ReadEDmac1WRSramCompleteCBR(A)      FC58003E
ReadEDmac1WRSramCompleteCBR(B)      FC580010
ReadEDmacCompleteCBR_SAFRAW         FC543A1A
ReadEDmacCompleteCBR_SHOOT          FC544004
RegisterEDmacCompleteCBR            FC369DFA
StartEDmac                          FC36946A
TestReadEDmac1WRSramCompleteCBR     FC580BF8
TestWriteEDmacRDSramCompleteCBR     FC580D4A
WriteEDmacCORCompleteCBR            FC5800B8
WriteEDmacCompleteCBR               FC581028
WriteEDmacCompleteCBR_SAFRAW        FC5439FC
edmac_set_addr                      FC369540
edmac_set_flags_0x1000              FC369756
edmac_set_flags_0x400000            FC3697D0
edmac_set_flags_0x40000000          FC36973E
edmac_set_flags_0x400000_0          FC36988A
edmac_set_flags_0x7                 FC3694CA
edmac_set_flags_0x800000            FC36979E
edmac_set_flags_0x800000_0          FC369860
edmac_set_flags_0xC00000            FC369838
edmac_set_size                      FC36956A
edmac_struct                        FC6AF930
edmac_struct_10C                    FC6AFA3C

It could be great if capdis could detect argumets for various functions like it was done for propcases. Some functions are called hundreds of times and it's need to find where are them called from with certian argument.
« Last Edit: 10 / September / 2017, 14:28:52 by Ant »

*

Offline c_joerg

  • *****
  • 1251
Re: EOS M3 porting
« Reply #438 on: 11 / September / 2017, 02:01:14 »
Yes, they can do some correction. Not sure about image distosion:

I couldn’t see any differences on my lenses (EF-M 22, EF-M 15-45, EF-S 55-250, EF-S 10-18 ) between ‚enable‘ and ‘disable’.  With

Code: [Select]
exiftool -OpcodeList3

I can’t find any opcode on my M3 RAW’s. On all my other P&S there is opcode.
 
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline c_joerg

  • *****
  • 1251
Re: EOS M3 porting
« Reply #439 on: 12 / September / 2017, 03:23:07 »
I have sometimes the problem, the CHDK after the boot does not start (Bootable SD Card Method). This is already noticeable with the second SD card. This happens approximately every 5 - 10 times. When I turn off the camera and turn it back on again, overthink works fine. Is someone else already noticed?
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

 

Related Topics


SimplePortal © 2008-2014, SimplePortal