Open Julientaming opened 3 years ago
You will probably need to reverse engineer .so files with IDA or Ghidra (camera libs), this process is pain in the ass.
Alright so I tried with IDA, OMG, so difficult for me, lost in thousands of lines. I tried to look at some files libdualCamera_calibration.so, android.hardware.camera.device@1.0.so, camera.kirin970.so, libdcamera_capture.so such a mess ! Some weird functions too "unLinkToDeath"
Ask help on XDA Developers there are developers that reverse engineer camera libs they can help you.
Hi. Normaly its not needed to have root or edit libs on cam2 devices. The oem trend is to use hidden keys and they are stored inside the apk. Pls check if you see in setting, on the right panel on bottom, a dualsensor mode. There you can switch between mono,color and dual. I know its working on p9,p10 and p20. With p30 huawei changed the api. If the dual sensor mode dont work for you, then best practise is to pull the stock camera apk and decompile it. Jadx is a nice tool to translate the dex into readable java. But it complain about the dex version mostly. Its easy to fix with a hexeditor changing dex version to 35. After that jadx can decompile the dex. Leica itself created the lens and calibrated the sensor. Good luck
Hi. Normaly its not needed to have root or edit libs on cam2 devices. The oem trend is to use hidden keys and they are stored inside the apk. Pls check if you see in setting, on the right panel on bottom, a dualsensor mode. There you can switch between mono,color and dual. I know its working on p9,p10 and p20. With p30 huawei changed the api. If the dual sensor mode dont work for you, then best practise is to pull the stock camera apk and decompile it. Jadx is a nice tool to translate the dex into readable java. But it complain about the dex version mostly. Its easy to fix with a hexeditor changing dex version to 35. After that jadx can decompile the dex. Leica itself created the lens and calibrated the sensor. Good luck
Hidden keys ?? I cam switch to mono or color, but I can't take any raw or full size jpg with the mono, it becomes black or freeze.I can do raw with the color one so Im guessing its deeper than that. I was thinking maybe trick the app by changing id of the sensor and invert what is the main and second camera ?
Ask help on XDA Developers there are developers that reverse engineer camera libs they can help you.
I will try thanks
oem trend ? I see a oem folder inside the app with hwcamera2.vdex and hwcamera2.odex ?
From my experience some features are blocked inside the ROM from Huawei. I had three different P20 Pro (for work) and all of them behaved differently. I have one which does everything. Using mono for video and RAW capturing (at full frame-size). I don't know if a rooted phone helps. It looks as if they changed their Cam API.
Wow so can you tell me please which rom and build number etc this p20 pro is using ? So its somewhere in the rom I will need to dive in
@Julientaming AOSP ROMs usually don't port the camera libs so I think they perform worse than stock Huawei ROMs, if I remember correctly from porting, they usually focus on making the main sensor work.
@Julientaming AOSP ROMs usually don't port the camera libs so I think they perform worse than stock Huawei ROMs, if I remember correctly from porting, they usually focus on making the main sensor work.
So, maybe if I delete the right lib I could unlock everything?
@Julientaming the Build-Number which works (so far) is the following: EMUI 9.1.0.328
You have access to raw mono with the stock camera app or with freedcam ?
With freedcam. But only a version before the recent major update. I can check once I'm back.. something from march does the trick. Also if you look into the branch cellstorm, this should also work.
On Sun, 23 Aug 2020, 15:45 Julientaming, notifications@github.com wrote:
You have access to raw mono with the stock camera app or with freedcam ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KillerInk/FreeDcam/issues/124#issuecomment-678776426, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBE5OBQKHS3AXBYYKSDAILSCEMQXANCNFSM4QIGNKXA .
Sorry what is the branch cellstorm ? another app ? I just modified too deep lol my phone doesnt boot anymore I will need to flash it
I cam switch to mono or color, but I can't take any raw or full size jpg with the mono
take a mono jpeg with stock cam and check the size. after that set same size inside freedcam and try it again. hopefully its then working. mono raw is offical not supported by huawei(? p9 stock cam cant capture it, only support jpeg)
So, maybe if I delete the right lib I could unlock everything?
dont delete libs, it ends in bootloop. but you can try to copy over the libs from EMUI 9.1.0.328.
Sorry what is the branch cellstorm
cellstorm is a extra module for freedcam to stream cropped rawdata. https://github.com/KillerInk/FreeDcam/tree/cellstorm
@Julientaming AOSP ROMs usually don't port the camera libs so I think they perform worse than stock Huawei ROMs, if I remember correctly from porting, they usually focus on making the main sensor work.
So, maybe if I delete the right lib I could unlock everything?
That will brick your Phone DO NOT do that, you will need to patch the libs or downgrade as someone pointed out. Also moving old libs to new Android Version probably will result in bootloop.
@Julientaming AOSP ROMs usually don't port the camera libs so I think they perform worse than stock Huawei ROMs, if I remember correctly from porting, they usually focus on making the main sensor work.
So, maybe if I delete the right lib I could unlock everything?
That will brick your Phone DO NOT do that, you will need to patch the libs or downgrade as someone pointed out. Also moving old libs to new Android Version probably will result in bootloop.
You can try using Dual Boot Patcher (https://github.com/chenxiaolong/DualBootPatcher) and install the older rom on other partition on your phone or sd and use it like that.
Yes too late I had to flash the stock rom again so I lost the root and its lock again :( I still have the bootloader unlock code but I cant turn on oem unlock its grey in developper options
Ok, I managed to unlock it again. I will try the freedcam March version
So with the version 4.1beta9, I can select raw with the monochrome and click on the shutter but the file is a black image in dng.
Sorry but I don't understand how I can add the module cellstorm to Freedcam ?
I cam switch to mono or color, but I can't take any raw or full size jpg with the mono
take a mono jpeg with stock cam and check the size. after that set same size inside freedcam and try it again. hopefully its then working. mono raw is offical not supported by huawei(? p9 stock cam cant capture it, only support jpeg)
So, maybe if I delete the right lib I could unlock everything?
dont delete libs, it ends in bootloop. but you can try to copy over the libs from EMUI 9.1.0.328.
Sorry what is the branch cellstorm
cellstorm is a extra module for freedcam to stream cropped rawdata. https://github.com/KillerInk/FreeDcam/tree/cellstorm
How I can install this camera2_hidden_keys java?
Sorry but I don't understand how I can add the module cellstorm to Freedcam ?
clone the branch and build it.
How I can install this camera2_hidden_keys java?
no need to install them. they are inside the source.
So with the version 4.1beta9, I can select raw with the monochrome and click on the shutter but the file is a black image in dng.
then your emui has broken raw stream. but you can try to copy over the libs from EMUI 9.1.0.328.
Sorry but I don't understand how I can add the module cellstorm to Freedcam ?
clone the branch and build it.
How I can install this camera2_hidden_keys java?
no need to install them. they are inside the source.
So with the version 4.1beta9, I can select raw with the monochrome and click on the shutter but the file is a black image in dng.
then your emui has broken raw stream. but you can try to copy over the libs from EMUI 9.1.0.328.
I don't think so, it was always like that no matter which rom I have, it's a limitation on mate series and p series. It's why raw mono isn't available with the stock app. Also there isn't a 9.1.0.138 for mate 10. That's for a p20 pro. But this particular rom might have a bug and doesn't come with this limitation. How could I copy the lib if I don't have a P20 Pro?
Well then you are lost. About that emui version, i thought we are talking in meantime about a p20. dont copy libs from p20 to the mate. it ends in bootloop. i wouldnt say that this version is a bug. its more a correct working hal imho. all sensors can capture raw, but in your case its restricted by the overlaying software. maybe its fixable with modding the libs, but that have nothing todo with freedcam. good luck
I meant a bug because a "normal" p20 can't shoot raw with all cameras, just the main one. Which lib should I look into ? There are tons, like android.hardware.camera.common android.hardware.camera.device camera.device camera.kirin970 camerafactoryservice cameraserver libcamera_algo libcamera_client libcameraservice libcamera_capture libdualcamera_calibration vendor.huawei.hardware.camera.camRessource
So, I opened the hwcamera2.apk the stock app with android studio on my pc, I saw that in AndroidManifest.xml : <uses-feature android:name="android.hardware.camera2" android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.level.full"
android:required="false" />
Should it be on true ? Is it possible to recompile the app with those values ?
i would look into:
if one of them is only a wrapper you have to figure out to wich lib its pointing.
search for "com.huawei.capture.metadata.dualSensorMode" and from that try to follow it to the part where streams get created. its not a easy task. and depending on your skills it could be impossible.
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.level.full"
android:required="false" />
are only feature checks what the device need to support to install the apk. front cam is most time fixed focus. most huawei devices are level 3. non of it should be true.
I wanted to have a look at it anyway since the newer version of freedcam does not seem to like the mono mode in the p20 anymore. I'll check it once I get back to my computer!
Thank you !! I will check that, also I found a function recordRawData2File(char ,char const,int) .text 00000000000F6BC4 0000011C 00000030 FFFFFFFFFFFFFFF8 R . . . . T . in libcamera_capture
Oh crap, I start to feel hopeless. I tried a custom rom openkirin on lineageOS 16. So no emui, same thing. Dng are empty, only jpg works in monochrome. With freedcam or the camera app included. How its possible its not the same camera lib?
Oh crap, I start to feel hopeless. I tried a custom rom openkirin on lineageOS 16. So no emui, same thing. Dng are empty, only jpg works in monochrome. With freedcam or the camera app included. How its possible its not the same camera lib?
LineageOS uses basic Camera drivers for the cameras
So the "stock" camera app still uses com.huawei.camera, but freedcam uses troop.com.freedcam. I will try to root it again
thats equal. its only the app namespace. huawei dont care about.
you can try to check if the correct raw size get set, freedcam does it here:
wich get used then here: https://github.com/KillerInk/FreeDcam/blob/09ad4395c717bb13c524c7219554c5f82f2281c9/app/src/main/java/freed/cam/apis/camera2/modules/PictureModuleApi2.java#L339
try to harcoded the values for the mono camera, if it works with the hardcoded value then u are lucky. but i tend to say its a broken rawstream
maybe a dumpsys can help you to find the correct size
adb shell dumpsys media.camera > info.txt
get then saved into the folder where adb is
all the huawei stuff is based on a p9. on p9 mono and color sensor have the same size. there i have only to set the dualcamera key to mono without recreating the imagereaders. i dont remember with wich devices they started use different sensor sizes for mono and color.
So I tested a bit and in the very last version, everything seems to be working fine again. I had some problems with the permission manager on the P20, but manually setting it did the job in the end.
Thanks!
I think the 20 meg is marketing bullshit, on the specs sheet the IMX386 is 12 meg, also on the stock app, 12 meg are sharper than 20 meg mode. I think both sensors are 12 meg and Huawei did a kind of pixels binning to get a larger image. I actually found a file talking about binning somewhere. Only the aperture changed since th P9, not even sure it's a true f1.6 vs f2.2. Could you send me a raw mono from your P20 if everything works now please ?
thats equal. its only the app namespace. huawei dont care about.
you can try to check if the correct raw size get set, freedcam does it here:
wich get used then here: https://github.com/KillerInk/FreeDcam/blob/09ad4395c717bb13c524c7219554c5f82f2281c9/app/src/main/java/freed/cam/apis/camera2/modules/PictureModuleApi2.java#L339
try to harcoded the values for the mono camera, if it works with the hardcoded value then u are lucky. but i tend to say its a broken rawstream
maybe a dumpsys can help you to find the correct size
adb shell dumpsys media.camera > info.txt
get then saved into the folder where adb isall the huawei stuff is based on a p9. on p9 mono and color sensor have the same size. there i have only to set the dualcamera key to mono without recreating the imagereaders. i dont remember with wich devices they started use different sensor sizes for mono and color.
From the specs sheet, the resolution should be 4032 x 3016? On raw colors, the size is actually 3952x2960, which is different from the jpeg of both sensors 3968x2976. Maybe if the size 3952x2960 could be added it would work ?
I saw a raw monochrome from the Nokia 9 and the image is 4032x3016.
i dont know. you have to try.
i dont have that devices.
install android studio, clone freedcam, hardcode the size and be prepared for freez/crash.
adb shell dumpsys media.camera > info.txt
gives you mostly the needed information. feel free to attach that file. then its alot lesser guessing.
if (subsize.length > 2) { // if this is null it crash correct
output.raw_width = 4032;
output.raw_height = 3016;
} else {
output.raw_width = 4032; ;
output.raw_height = 3016;
}
just as sample the dump from p9 https://github.com/KillerInk/FreeDcam/blob/master/Camera1Parameters/eva-09_dump.txt p20 https://github.com/KillerInk/FreeDcam/blob/master/Camera1Parameters/huawei_p20pro.txt mate9 https://github.com/KillerInk/FreeDcam/blob/master/Camera1Parameters/huawei%20mate9.txt
Ok I will try, thank you. If you need any file from the mate 10 tell me I can send it 😃
Something I don't understand, I shot raw with the color sensor, the dng size is 3952x2960 (16 pixels difference from 3968x2976), but after edit with an app (photo editor pro), the exported jpg size is 5126x3840 ??
there is the image with and height: 3968x2976 then there is a default crop origin: 8x8 wich removes on top,bottom,left,right 8 pixels for demosaic. so default crop size is then 3952x2960. on my dngs ps use the cropsize. no idea how you get 5126x3840
pls dump the camera and attach the file here.
adb shell dumpsys media.camera > info.txt
So I found out Huawei realised the source code for my phone, would it be possible to create a modified rom from that ?
I did the file info.txt
By the way, how come Freedcam is the only app to be able to access the monochrome sensor ? Any other app I tried, I can't access it, even basics rooted camera info app, tells me everything about the main sensor but nothing about the second sensor.
So from the info file, I need to access to com.huawei.device.capabilities or com.huawei.capture.metadata but even rooted I can't find them
Also I found the imx386hybird.c file in the source code "Hisilicon K3 SOC camera driver source file" would it be possible to invert the sensors ID so I get raw on the mono and jpg on the color one ?
Any suggestion ? I can send other files if needed
By the way, how come Freedcam is the only app to be able to access the monochrome sensor ? Any other app I tried, I can't access it, even basics rooted camera info app, tells me everything about the main sensor but nothing about the second sensor.
huawei use the same camera id for all back cameras. due that only the color sensor is visible by default.
to switch between color/mono you must use the key com.huawei.capture.metadata.dualSensorMode
from the info.txt; color sensor:
android.sensor.info.activeArraySize (f0000): int32[4]
[0 0 3968 2976 ]
mono sensor:
com.huawei.device.capabilities.hwSubActiveArraySize (800100c2): int32[4]
[0 0 5120 3840 ]
Notes:
Phone Model: Huawei Mate 10 ALP-L29 8.0.0.141 rooted
FreeDcam Version: 4.3.3
Problem Description:
So, it's not really a problem but I am wondering how on Earth I could enable raw capture on the monochrome sensor ? I do have a rooted + unlocked phone, so I can access to every file, or I can flash a different rom, I don't care about other features, I just want raw on both cameras (street photographer here :) ). I know Huawei locked it in some ways but having a rooted phone, maybe there is a solution ? I also saw that the phone AGM X2 SE got the same IMX386 sensors, would it be possible to do raw on this phone ? Can't find any good review on this weird phone. If the sensor is Sony, Leica is a bit of a stretch here on Huawei, it's basically just the tiny optics ?
Kind regards,