合成hdr bug

mem
liuguijing 6 months ago
parent 14afaa3aaf
commit 5321d29cb3

@ -140,7 +140,6 @@ public class Camera2RawFragment extends Fragment {
private Long exposetime;
private Integer sensitivity;
public boolean isHandTakePic = true;
private double pic1 = 0;
@ -482,7 +481,7 @@ public class Camera2RawFragment extends Fragment {
finishedCaptureLocked();
}
showToast(sb.toString());
// showToast(sb.toString());
}
@Override
@ -493,7 +492,7 @@ public class Camera2RawFragment extends Fragment {
mRawResultQueue.remove(requestId);
finishedCaptureLocked();
}
showToast("Capture failed!");
// showToast("Capture failed!");
}
};
@ -537,7 +536,6 @@ public class Camera2RawFragment extends Fragment {
takepic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isHandTakePic = true;
takePicture();
}
});
@ -862,7 +860,7 @@ public class Camera2RawFragment extends Fragment {
@Override
public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
showToast("Failed to configure camera.");
// showToast("Failed to configure camera.");
}
}, mBackgroundHandler);
} catch (CameraAccessException e) {
@ -1106,7 +1104,6 @@ public class Camera2RawFragment extends Fragment {
// captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, new Integer(4));
// 设置曝光时间例如设置为1000微秒
// long exposureTime = 1000 000000L; // 1000微秒
if (isHandTakePic) {
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
if (exposureTime > 0) {
v = exposureTime;
@ -1116,13 +1113,11 @@ public class Camera2RawFragment extends Fragment {
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, sensitivity);
}
}
}
if (idx == 1) {
// captureBuilder.set(CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, new Integer(4));
// 设置曝光时间例如设置为1000微秒
// long exposureTime = 1000 000000L; // 1000微秒
if (isHandTakePic) {
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
if (exposureTime > 0) {
if (pic1 <= 0) {
@ -1137,9 +1132,9 @@ public class Camera2RawFragment extends Fragment {
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 100);
}
}
}
CaptureRequest request = captureBuilder.build();
// ImageSaverBuilder jpegBuilder = new ImageSaverBuilder(activity).setCharacteristics(mCharacteristics);
ImageSaverBuilder rawBuilder = new ImageSaverBuilder(activity).setCharacteristics(mCharacteristics);//保存拍照参数
rawBuilder.setExposetime((long) v);//保存曝光时间
@ -1185,6 +1180,7 @@ public class Camera2RawFragment extends Fragment {
private void dequeueAndSaveImage(TreeMap<Integer, ImageSaverBuilder> pendingQueue, RefCountedAutoCloseable<ImageReader> reader) {
synchronized (mCameraStateLock) {
reader.get();
Map.Entry<Integer, ImageSaverBuilder> entry = null;
if (pendingQueue != null) {
for (Map.Entry<Integer, ImageSaverBuilder> item : pendingQueue.entrySet()) {
@ -1334,27 +1330,6 @@ public class Camera2RawFragment extends Fragment {
}
}
/**
* Generate a string containing a formatted timestamp with the current date and time.
*
* @return a {@link String} representing a time.
*/
/**
* Cleanup the given {@link OutputStream}.
*
* @param outputStream the stream to close.
*/
/**
* Return true if the given array contains the given integer.
*
* @param modes array to check.
* @param mode integer to get for.
* @return true if the array contains the given integer, otherwise false.
*/
private static boolean contains(int[] modes, int mode) {
if (modes == null) {
return false;
@ -1367,13 +1342,6 @@ public class Camera2RawFragment extends Fragment {
return false;
}
/**
* Return true if the two given {@link Size}s have the same aspect ratio.
*
* @param a first {@link Size} to compare.
* @param b second {@link Size} to compare.
* @return true if the sizes have the same aspect ratio, otherwise false.
*/
private static boolean checkAspectsEqual(Size a, Size b) {
double aAspect = a.getWidth() / (double) a.getHeight();
double bAspect = b.getWidth() / (double) b.getHeight();

@ -11,6 +11,7 @@ import android.hardware.camera2.DngCreator;
import android.media.Image;
import android.media.ImageReader;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
import com.xypower.mppreview.bean.Contants;
@ -90,11 +91,11 @@ public class ImageSaver implements Runnable {
}
mReader.close();
if (success) {
File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
String directoryPath = directory.getPath();
File file = new File(directory, "create_" + mExpostime + "_" + generateTimestamp() + ".png");
String path = file.getPath();
Log.e("测试测试", "开始转化:" + System.currentTimeMillis());
try {
RawToJpgConverter.convertRawToJpg(mFile.getPath(), path);
} catch (IOException e) {
@ -104,10 +105,17 @@ public class ImageSaver implements Runnable {
bean.setEtime(mExpostime);
bean.setPath(path);
mlist.add(bean);
Log.e("测试测试", "转化结束:" + System.currentTimeMillis());
if (mlist.size() == 2) {
Log.e("测试测试", "开始合成:" + System.currentTimeMillis());
PngPhotoBean bean1 = mlist.get(0);
PngPhotoBean bean2 = mlist.get(1);
makeHdr(bean1.getEtime(), bean1.getPath(), bean2.getEtime(), bean2.getPath(), directoryPath + "/" + "hdr_" + generateTimestamp() + ".png");
String path1 = bean1.getPath();
String path2 = bean2.getPath();
String outputPath = directoryPath + "/" + "hdr_" + generateTimestamp() + ".png";
Log.e("测试测试", "照片路径:" + path1 + " 照片路径:" + path2 + " 生成路径:" + outputPath);
boolean b = makeHdr(bean1.getEtime(), path1, bean2.getEtime(), path2, outputPath);
Log.e("测试测试", "合成结束:" + System.currentTimeMillis());
}
}
}

@ -73,7 +73,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private void takePicture() {
Camera2RawFragment fragment = (Camera2RawFragment) getSupportFragmentManager().findFragmentById(R.id.container);
fragment.isHandTakePic = false;
fragment.takePicture();
}

Loading…
Cancel
Save