|
|
|
@ -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,15 +1104,13 @@ 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;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
}
|
|
|
|
|
if (sensitivity > 0) {
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, sensitivity);
|
|
|
|
|
}
|
|
|
|
|
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
|
|
|
|
|
if (exposureTime > 0) {
|
|
|
|
|
v = exposureTime;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
}
|
|
|
|
|
if (sensitivity > 0) {
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, sensitivity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1122,24 +1118,23 @@ 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) {
|
|
|
|
|
if (pic1 <= 0) {
|
|
|
|
|
v = exposureTime * 7;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
} else {
|
|
|
|
|
v = exposureTime * pic1;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sensitivity > 0) {
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, 100);
|
|
|
|
|
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
|
|
|
|
|
if (exposureTime > 0) {
|
|
|
|
|
if (pic1 <= 0) {
|
|
|
|
|
v = exposureTime * 7;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
} else {
|
|
|
|
|
v = exposureTime * pic1;
|
|
|
|
|
captureBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, (long) v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sensitivity > 0) {
|
|
|
|
|
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();
|
|
|
|
|