Enable the 5 cams at OpenCamera including 108Mpx mode

TF1920

Senior Member
Nov 23, 2019
68
14
0
Step by Step guide to enable the 5 cams using OpenCamara (probably can be extended for Gcam too)

1.- You need a unlocked Note 10
2.- Install TWRP-3.3.1-0709-XIAOMI_CC9-CN-wzsx150-fastboot or the last one
3.- Install Magix & The App Root Esentials for example
4.- Edit the file build.prop using for example Root Esentials
Edit this line :
vendor.camera.aux.packagelist=org.codeaurora.snapcam,com.xiaomi.runin,com.xiaomi.cameratest,com.xiaomi.factory.mmi,com.android.camera,org.lineageos.snap,net.sourceforge.opencamera,troop.com.freedcam
and add this one:
camera.aux.packagelist=net.sourceforge.opencamera
5.- reboot
6.- Install Android Studio or similar to edit the source code for opencamera
7.- Create the project from the opencamera git
https://sourceforge.net/p/opencamera/code/ci/master/tree/
8.- Edit the file MainActivity.java and fix the other cameras in this function
public void clickedSwitchCamera(View view) {
......
int cameraId = getNextCameraId();
if(cameraId==6)
cameraId=7;
if(cameraId==8)
cameraId=9;
if(cameraId==10)
cameraId=11;
if(cameraId==11)
cameraId=12;
if(cameraId==12)
cameraId=13;
( there are 14 cameras found, but some fail)
9.- Install the OpenCamera from AndroidStudio
To enable the 108Mpx mode keep reading the thread.
 
Last edited:

TF1920

Senior Member
Nov 23, 2019
68
14
0
hi I'm trying to import that link via vcs and git, but it tells me that the link was not found, what should I import on android studio?
In android studio Go to
File > New > Project from version control > Git >

Type:
Code:
https://git.code.sf.net/p/opencamera/code
Test and should go Green > then it will take a while to import all the needed sources
 

TF1920

Senior Member
Nov 23, 2019
68
14
0
And now with the 108Mpx Mode too!!!!

Finally was able to make the 108Mpx mode to work with OpenCamera too!

You need to edit the following files in the OpenCamera Source Code:

1.- build.gradle > to enable a bigger api level at least 26 sdk version

Code:
 defaultConfig {
        applicationId "net.sourceforge.opencamera"
        minSdkVersion 26
        targetSdkVersion 28

        renderscriptTargetApi 26
2.- Edit the file net\sourceforge\opencamera\cameracontroller\CameraController2.java

to override the streaming info for the new resolutions

this is code is around line 2017 of the file

Code:
StreamConfigurationMap configs;
        try {
            configs =CameraStreamConfigurations.getCustomStreamConfigurationMap(characteristics); // New to enable the 108Mpx mode to show
            // Updated for 108Mpx older was
            //configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
        }
3.- Add a new java file with the overriding code ( based on code found at https://gist.github.com/lgyjg/07fdc8146f1d472a0941dcd0e470c93d

You need to create a new file named CameraStreamConfigurations.java at
net\sourceforge\opencamera\cameracontroller\CameraStreamConfigurations.java

with the following code:

Code:
package net.sourceforge.opencamera.cameracontroller;

import android.annotation.SuppressLint;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.params.StreamConfigurationMap;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class CameraStreamConfigurations {

    @SuppressLint("PrivateApi")
    public static StreamConfigurationMap getCustomStreamConfigurationMap(CameraCharacteristics cameraCharacteristics) {

        try {
            Class<?> streamConfigurationArrayClazz = Class.forName("[Landroid.hardware.camera2.params.StreamConfiguration;");
            Class<?> cameraCharacteristicsKeyClazz = Class.forName("android.hardware.camera2.CameraCharacteristics$Key");
            Class<?>[] params = {String.class, Class.class};
            Object[] values = {"xiaomi.scaler.availableStreamConfigurations", streamConfigurationArrayClazz};
            Constructor<?> constructor = cameraCharacteristicsKeyClazz.getDeclaredConstructor(params);
            CameraCharacteristics.Key<?> MI_SCALER_AVAILABLE_STREAM_CONFIGURATIONS  = (CameraCharacteristics.Key<?>) constructor.newInstance(values);

            Object configurations = cameraCharacteristics.get(MI_SCALER_AVAILABLE_STREAM_CONFIGURATIONS);

            boolean listHighResolution = true;
        
            Object[] streamConfigurationMapValues = {
                    configurations,
                    cameraCharacteristics.get(getFiled("SCALER_AVAILABLE_MIN_FRAME_DURATIONS")),
                    cameraCharacteristics.get(getFiled("SCALER_AVAILABLE_STALL_DURATIONS")),
                    cameraCharacteristics.get(getFiled("DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS")),
                    cameraCharacteristics.get(getFiled("DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS")),
                    cameraCharacteristics.get(getFiled("DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS")),
                    cameraCharacteristics.get(getFiled("CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS")),
                    cameraCharacteristics.get(getFiled("SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP")),                  
                    listHighResolution
            };

            Constructor<?> streamConfigurationMapConstructor   = android.hardware.camera2.params.StreamConfigurationMap.class.getConstructors()[0];

            StreamConfigurationMap mStreamConfigurationMap    = (StreamConfigurationMap) streamConfigurationMapConstructor.newInstance(streamConfigurationMapValues);

            return mStreamConfigurationMap;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }


    static CameraCharacteristics.Key<Object> getFiled(String filed) {
        CameraCharacteristics.Key<Object> result = null;
        try {
            Field f = CameraCharacteristics.class.getField(filed);
            result =  (CameraCharacteristics.Key<Object>) f.get(null);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }

        return result;
    }
}
 
  • Like
Reactions: SiiXFX

picitup

Senior Member
Jan 9, 2011
205
65
0
Deal
Hi @TF1920

I just modded open camera as per your excellent instructions above and at first glance, 108mp jpeg works fine! Well done lol.

I can confirm that with your original camera-id shifting code, my open camera on EU rom crashes at camera 8->9 so I've limited the max camera ID to 5 on mine.

As you said, RAW doesn't work and on mine, if RAW is enabled, neither does jpeg. The camera only works when only jpeg is enabled. If you do choose RAW, there's a long delay where the photo canvas freezes and eventually it frees up.

I'll get some samples later.

---------- Post added at 11:30 AM ---------- Previous post was at 11:28 AM ----------

Oh, yes I forgot. Each time I install a new version of open camera, it defaults back to camera.api from camera2 and you can't get the high res photos.

It threw me for short while lol.
 

picitup

Senior Member
Jan 9, 2011
205
65
0
Deal
Hi Again

I just had a play with RAW mode turned on and tried it with all lenses. I tried them all with Storage Access Framework on and off and this made no difference to the results.

Raw ON
======
camera 0 - 108mp
Makes click sound then screen freezes for 60 seconds.
No jpeg or raw saved.
Video and camera switch icons missing. Choose Settings/About/Back and icons reappaer

Camera 1 - selfie
Toast Message: "Failed to save RAW photo"
Save jpeg and DNG but jpeg distorted and DNG is 0 bytes

Camera 2 - 2x zoom
No RAW text on screen (below ISO text).
jpeg saved OK, no RAW saved

Camera 3 - UltraWide
jpeg and RAW both saved OK

Camera 4 - Macro
jpeg and RAW both saved OK

Camera 5 - 5x zoom
No RAW text on screen (below ISO text).
jpeg saved ok, no RAW saved.


Cheers

Steve
 

TF1920

Senior Member
Nov 23, 2019
68
14
0
Good tests Steve, you can debug where raw fails in androidstudio , if you plug and build opencamera and run it from the play button of androidstuido without unplugin it take a look at the debug infor at the Logcat view, then try what fails and report possible errors there, I will keep looking too, also I am not sure of the quality at 108Mpx with OpenCam vs Stock need more tests., all the other stuff works well at 108Mpx with Jpg.

I my first test at 108Mpx the quality is similar as stock as long as you manual focus, easy with the 10X digital zoom with opencam once you focus go back to 0x zoom to avoid loss
 
Last edited:

picitup

Senior Member
Jan 9, 2011
205
65
0
Deal
Hi thanks for the tip. I'm still poking around Android Studio to get a feel for it. What I really need to do is build my own app from scratch. I'll give your suggestion a go in the next few days.

I'm intending to go out and get a few sample jpegs/raw with open camera and stock for comparison and will post them up but for some reason it's raining pretty much constantly here. I wonder why? Oh, yes I live in the UK. :)

I had a play with the stock cam to compare RAW support with open cam and got the following:

UltraWide - RAW
Wide 27MP - RAW
Macro RAW

Wide 108mp No RAW
TELE 2x No RAW
Tele 5x No RAW
 

TF1920

Senior Member
Nov 23, 2019
68
14
0
Thanks Steve, I still see a bit more resolution in the stock 108Mpx vs the OpenCam, maybe a bit more sharpen due to some post process or other things may need further research, I am testing the unlimited repeats of opencam and works quite well made 4200 108Mpx picts 80Gbs total of 20Mb each at 100% jpg in about 1,5h
 

D1G1TE

Senior Member
Dec 24, 2016
61
44
18
Hi everyone,

I have created Open Camera MOD for Xiaomi Note 10 based on latest OpenCamera GIT code, that DOES NOT REQUIRE ROOT OR CUSTOM RECOVERY to be able to use all 5 rear cameras. Note that 108MP code patch is not included since its breaking Camera 2 API switch in preferences and making camera app to crash when you try to switch to Camera 2 API.

How I did it?
I have refactored Open Camera app in Android studio. Using this guide https://stackoverflow.com/questions/16804093/rename-package-in-android-studio + some simple "replace in files" for leftover references to old package name. During refactoring I have changed package name from "net.sourceforge.opencamera" to "org.codeaurora.snapcam" since that one is white listed to use AUX cameras in build.prop without any changes required. I have also changed labels for cameras so instead showing ID1, ID2, etc... Every camera have now proper name.

I have used similar technique of changing package name for GCam ports and Hedge Camera 2 in past and it works quite well for me.

Link to APK: https://drive.google.com/open?id=14kYxCPGvBEe1KujD07BX2t5r-u-owaq2

I hope this will make you happy. :)
 
Last edited:

xterminater07

Senior Member
Dec 4, 2010
1,575
474
0
Hi everyone,

I have created Open Camera MOD for Xiaomi Note 10 based on latest OpenCamera GIT code, that DOES NOT REQUIRE ROOT OR CUSTOM RECOVERY to be able to use all 5 rear cameras. Note that 108MP code patch is not included since its breaking Camera 2 API switch in preferences and making camera app to crash when you try to switch to Camera 2 API.

How I did it?
I have refactored Open Camera app in Android studio. Using this guide https://stackoverflow.com/questions/16804093/rename-package-in-android-studio + some simple "replace in files" for leftover references to old package name. During refactoring I have changed package name from "net.sourceforge.opencamera" to "org.codeaurora.snapcam" since that one is white listed to use AUX cameras in build.prop without any changes required. I have also changed labels for cameras so instead showing ID1, ID2, etc... Every camera have now proper name.

I have used similar technique of changing package name for GCam ports and Hedge Camera 2 in past and it works quite well for me.

Link to APK: https://drive.google.com/open?id=14kYxCPGvBEe1KujD07BX2t5r-u-owaq2

I hope this will make you happy. :)
Do you have telegram? I want to see if you can get aux to expose in gcam properly because when I tried it did not work, only ultrawide works in gcam 7.2 with code aurora package
 

polfmarti

Member
Feb 24, 2013
13
1
0
Hi everyone,

I have created Open Camera MOD for Xiaomi Note 10 based on latest OpenCamera GIT code, that DOES NOT REQUIRE ROOT OR CUSTOM RECOVERY to be able to use all 5 rear cameras. Note that 108MP code patch is not included since its breaking Camera 2 API switch in preferences and making camera app to crash when you try to switch to Camera 2 API.

How I did it?
I have refactored Open Camera app in Android studio. Using this guide https://stackoverflow.com/questions/16804093/rename-package-in-android-studio + some simple "replace in files" for leftover references to old package name. During refactoring I have changed package name from "net.sourceforge.opencamera" to "org.codeaurora.snapcam" since that one is white listed to use AUX cameras in build.prop without any changes required. I have also changed labels for cameras so instead showing ID1, ID2, etc... Every camera have now proper name.

I have used similar technique of changing package name for GCam ports and Hedge Camera 2 in past and it works quite well for me.

Link to APK: https://drive.google.com/open?id=14kYxCPGvBEe1KujD07BX2t5r-u-owaq2

I hope this will make you happy. :)
Hi, I'm very interested in video recording with the x5 telephoto, since it's is not supported wit the stock camera. I couldn't install your apk, I have stock MIUI 11 and Android 9. What shoul I do in order to install it?
 

D1G1TE

Senior Member
Dec 24, 2016
61
44
18
Hi, I'm very interested in video recording with the x5 telephoto, since it's is not supported wit the stock camera. I couldn't install your apk, I have stock MIUI 11 and Android 9. What shoul I do in order to install it?
I am also on stock MIUI 11 / Android 9 - Global ROM. What error do you get?

---------- Post added at 02:30 AM ---------- Previous post was at 02:26 AM ----------

Do you have telegram? I want to see if you can get aux to expose in gcam properly because when I tried it did not work, only ultrawide works in gcam 7.2 with code aurora package
I am no expert in GCam, sorry. :) I don't even have GCam source code.
 
Last edited:

polfmarti

Member
Feb 24, 2013
13
1
0
I am also on stock MIUI 11 / Android 9 - Global ROM. What error do you get?

It says that the app could not be installed.

Edit: It is not installed because of its package name. I'm trying to solve it.

Edit 2: It couldn't be installed because I had UltraCam installed and it was using the same package name. I uninstalled it and now I'm able to use it.
 

Attachments

Last edited:

FloZee

New member
Mar 1, 2020
1
0
0
---------- Post added at 08:33 PM ---------- Previous post was at 08:22 PM ----------

[/COLOR]
Hi everyone,

I have created Open Camera MOD for Xiaomi Note 10 based on latest OpenCamera GIT code, that DOES NOT REQUIRE ROOT OR CUSTOM RECOVERY to be able to use all 5 rear cameras. Note that 108MP code patch is not included since its breaking Camera 2 API switch in preferences and making camera app to crash when you try to switch to Camera 2 API.

How I did it?
I have refactored Open Camera app in Android studio. Using this guide + some simple "replace in files" for leftover references to old package name. During refactoring I have changed package name from "net.sourceforge.opencamera" to "org.codeaurora.snapcam" since that one is white listed to use AUX cameras in build.prop without any changes required. I have also changed labels for cameras so instead showing ID1, ID2, etc... Every camera have now proper name.

I have used similar technique of changing package name for GCam ports and Hedge Camera 2 in past and it works quite well for me.

Link to APK:

I hope this will make you happy. :)
I was searching exactly for this! After testing Hedgecam 2 and Open Camera because I want more control for my videos, I was immediately dissapointed by the lack of support for ultra wide and 5x cameras. Your version of open cam works flawless! Thanks and wish you the best,
Flo
 
Last edited:
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone