Skip to content

Commit

Permalink
Fixed CameraManager2, updated alignment noise model
Browse files Browse the repository at this point in the history
  • Loading branch information
eszdman committed Sep 12, 2021
1 parent 9550807 commit 053885c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class Wrapper {

public static native void loadInterpolatedGainMap(ByteBuffer GainMap);

public static native ByteBuffer processFrame(float DistMin, float DistMax, float ElFactor, float BLr,float BLg,float BLb, float WLFactor,
public static native void outputBuffer(ByteBuffer outputBuffer);
public static native void processFrame(float DistMin, float DistMax,float Smooth, float ElFactor, float BLr,float BLg,float BLb, float WLFactor,
float wpR,float wpG, float wpB,int CfaPattern);
public static native ByteBuffer processFrameAlignments();
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,30 @@ private void init(CameraManager cameraManager) {
}

private void scanAllCameras(CameraManager cameraManager) {
try {

for (int num = 0; num < 121; num++) {
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(String.valueOf(num));
log("BitAnalyser:" + num + ":" + intToReverseBinary(num));
CameraLensData cameraLensData = createNewCameraLensData(String.valueOf(num), cameraCharacteristics);
if (!getBit(6, num) && !mCameraLensDataMap.containsValue(cameraLensData)) {
mAllCameraIDsSet.add(String.valueOf(num));
mCameraLensDataMap.put(String.valueOf(num), cameraLensData);
try {
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(String.valueOf(num));
log("BitAnalyser:" + num + ":" + intToReverseBinary(num));
CameraLensData cameraLensData = createNewCameraLensData(String.valueOf(num), cameraCharacteristics);
if (!getBit(6, num) && !mCameraLensDataMap.containsValue(cameraLensData)) {
mAllCameraIDsSet.add(String.valueOf(num));
mCameraLensDataMap.put(String.valueOf(num), cameraLensData);
}
} catch (Exception ignored) {
}
}
if(mAllCameraIDsSet.size() == 0) {
for(int i = 0; i<2;i++){
try {
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(String.valueOf(i));
CameraLensData cameraLensData = createNewCameraLensData(String.valueOf(i), cameraCharacteristics);
mAllCameraIDsSet.add(String.valueOf(i));
mCameraLensDataMap.put(String.valueOf(i), cameraLensData);
} catch (Exception ignored) {
}
}
}
} catch (IllegalArgumentException ignored) {
} catch (Exception e) {
e.printStackTrace();
}

findLensZoomFactor(mCameraLensDataMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,29 @@ private void ApplyHdrX() {
interpolateGainMap.Run();
interpolateGainMap.close();
Wrapper.loadInterpolatedGainMap(interpolateGainMap.Output);

float noiseLevel = (processingParameters.noiseModeler.computeModel[0].first.floatValue()+
float NoiseS = processingParameters.noiseModeler.computeModel[0].first.floatValue()+
processingParameters.noiseModeler.computeModel[1].first.floatValue()+
processingParameters.noiseModeler.computeModel[2].first.floatValue();
float NoiseO = processingParameters.noiseModeler.computeModel[0].second.floatValue()+
processingParameters.noiseModeler.computeModel[1].second.floatValue()+
processingParameters.noiseModeler.computeModel[2].second.floatValue();
/*float noiseLevel = (processingParameters.noiseModeler.computeModel[0].first.floatValue()+
processingParameters.noiseModeler.computeModel[1].first.floatValue()+
processingParameters.noiseModeler.computeModel[2].first.floatValue())*0.7f;
noiseLevel += processingParameters.noiseModeler.computeModel[0].second.floatValue()+
processingParameters.noiseModeler.computeModel[1].second.floatValue()+
processingParameters.noiseModeler.computeModel[2].second.floatValue();
noiseLevel*=Math.pow(2.0,19.0+PhotonCamera.getSettings().noiseRstr);
noiseLevel = Math.max(1.f,noiseLevel);
Log.d(TAG, "Denoising level:" + noiseLevel);
//TODO Write into java-created byteBuffer instead of jni
output = Wrapper.processFrame(1.0f*noiseLevel, 6.0f*noiseLevel, 1,0.f, 0.f, 0.f, processingParameters.whiteLevel
Log.d(TAG, "Denoising level:" + noiseLevel);*/
NoiseS/=3.f;
NoiseO/=3.f;
double noisempy = Math.pow(2.0,PhotonCamera.getSettings().noiseRstr+10.7);
NoiseS*=noisempy;
NoiseO*=noisempy*16384;
output = ByteBuffer.allocateDirect(images.get(0).buffer.capacity());
Wrapper.outputBuffer(output);
Wrapper.processFrame(NoiseS, NoiseO, 6.f,1,0.f, 0.f, 0.f, processingParameters.whiteLevel
, processingParameters.whitePoint[0], processingParameters.whitePoint[1], processingParameters.whitePoint[2], processingParameters.cfaPattern);
} else {
rawPipeline.alignAlgorithm = alignAlgorithm;
Expand Down
Binary file modified app/src/main/jniLibs/arm64-v8a/libHdrX.so
Binary file not shown.
4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon Sep 13 00:11:02 MSK 2021
VERSION_BUILD=12360
#Mon Sep 13 02:00:31 MSK 2021
VERSION_BUILD=12378

0 comments on commit 053885c

Please sign in to comment.