增加场景的设置,移除HDR和NIGHT两个特定场景

serial
Matthew 1 year ago
parent 4a412647ea
commit b69a639b6d

@ -119,9 +119,7 @@ NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARA
aeLockAvailable = false;
awbLockAvailable = false;
hdrSupported = false;
nightModeSupported = false;
nightPortraitModeSupported = false;
sceneModeSupported = false;
camera_manager_cb.context = this;
camera_manager_cb.onCameraAvailable = ::onAvailabilityCallback;
@ -212,7 +210,7 @@ int NdkCamera::open(const std::string& cameraId) {
int32_t format = e.data.i32[i + 0];
if (input) continue;
if (format == AIMAGE_FORMAT_YUV_420_888 || format == AIMAGE_FORMAT_JPEG)
// if (format == AIMAGE_FORMAT_YUV_420_888 || format == AIMAGE_FORMAT_JPEG)
{
DisplayDimension res(e.data.i32[i + 1], e.data.i32[i + 2]);
if (!disp.IsSameRatio(res))
@ -224,7 +222,7 @@ int NdkCamera::open(const std::string& cameraId) {
continue;
}
if (format == AIMAGE_FORMAT_YUV_420_888 && res > disp)
if (/*format == AIMAGE_FORMAT_YUV_420_888 && */res > disp)
{
foundIt = true;
foundRes = res;
@ -362,19 +360,11 @@ int NdkCamera::open(const std::string& cameraId) {
{
for (int i = 0; i < e.count; i++)
{
if (ACAMERA_CONTROL_SCENE_MODE_HDR == e.data.u8[i])
if (m_params.sceneMode == e.data.u8[i])
{
hdrSupported = true;
sceneModeSupported = true;
break;
}
else if (ACAMERA_CONTROL_SCENE_MODE_NIGHT == e.data.u8[i])
{
nightModeSupported = true;
}
else if (ACAMERA_CONTROL_SCENE_MODE_NIGHT_PORTRAIT == e.data.u8[i])
{
nightPortraitModeSupported = true;
}
}
}
}
@ -479,20 +469,9 @@ int NdkCamera::open(const std::string& cameraId) {
uint8_t awbMode = ACAMERA_CONTROL_AWB_MODE_AUTO;
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AWB_MODE, 1, &awbMode);
if (hdrSupported && m_params.hdrMode) {
uint8_t hdrMode = ACAMERA_CONTROL_SCENE_MODE_HDR;
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_SCENE_MODE, 1,&hdrMode);
}
if (m_params.nightMode) {
if (nightModeSupported) {
uint8_t sceneMode = ACAMERA_CONTROL_SCENE_MODE_NIGHT;
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_SCENE_MODE, 1, &sceneMode);
}
if (nightPortraitModeSupported) {
uint8_t modeEnabled = 1; // ACAMERA_CONTROL_SCENE_MODE_HDR
// res = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_SCENE_MODE_NIGHT_PORTRAIT, 1, &modeEnabled);
}
if (m_params.sceneMode != 0) {
uint8_t sceneMode = m_params.sceneMode;
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_SCENE_MODE, 1, &sceneMode);
}
status = ACameraOutputTarget_create(image_reader_surface, &image_reader_target);
@ -1004,7 +983,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
val = {0};
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_SCENE_MODE, &val);
mResult.hdrMode = (*(val.data.u8) == ACAMERA_CONTROL_SCENE_MODE_HDR) ? 1 : 0;
mResult.sceneMode = status == ACAMERA_OK ? *(val.data.u8) : 0;
val = {0};
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_MODE, &val);

@ -69,13 +69,12 @@ class NdkCamera
public:
struct CAMERA_PARAMS {
unsigned int hdrMode : 1;
unsigned int nightMode : 1;
unsigned int sceneMode : 5;
unsigned int autoFocus : 1;
unsigned int autoExposure : 1;
unsigned int orientation:3;
unsigned int focusTimeout : 14; // milli-seconds 65535 / 4
unsigned int reserved : 11;
unsigned int reserved : 8;
unsigned int exposureTime; // ms
unsigned int sensibility;
};
@ -90,7 +89,7 @@ public:
int64_t exposureTime;
float FocusDistance;
int32_t sensitibity;
uint8_t hdrMode;
uint8_t sceneMode;
};
@ -132,9 +131,7 @@ protected:
int32_t mHeight;
std::string mCameraId;
bool hdrSupported;
bool nightModeSupported;
bool nightPortraitModeSupported;
bool sceneModeSupported;
bool afSupported;
bool awbSupported;
bool aeLockAvailable;

@ -70,6 +70,7 @@ public class ChannelActivity extends AppCompatActivity {
}
});
/*
binding.btnNightMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -87,6 +88,7 @@ public class ChannelActivity extends AppCompatActivity {
}
}
});
*/
}
private View.OnFocusChangeListener onFocusChangeListener = new View.OnFocusChangeListener() {
@ -130,7 +132,7 @@ public class ChannelActivity extends AppCompatActivity {
binding.btnAutoExplosure.setChecked(true);
binding.btnAutoFocus.setChecked(true);
binding.btnHdrMode.setChecked(true);
// binding.btnHdrMode.setChecked(true);
binding.exposuretime.setText("0");
binding.sensitivity.setText("0");
@ -146,8 +148,17 @@ public class ChannelActivity extends AppCompatActivity {
binding.btnUsbCamera.setChecked(jsonObject.optInt("usbCamera", 0) == 1);
binding.btnAutoExplosure.setChecked(jsonObject.optInt("autoExposure", 1) == 1);
binding.btnAutoFocus.setChecked(jsonObject.optInt("autoFocus", 1) == 1);
binding.btnHdrMode.setChecked(jsonObject.optInt("hdrMode", 0) == 1);
binding.btnNightMode.setChecked(jsonObject.optInt("nightMode", 0) == 1);
// binding.btnHdrMode.setChecked(jsonObject.optInt("hdrMode", 0) == 1);
// binding.btnNightMode.setChecked(jsonObject.optInt("nightMode", 0) == 1);
int sceneMode = jsonObject.optInt("sceneMode", 0);
String sceneModeText = Integer.toString(sceneMode) + " ";
for (int idx = 0; idx < binding.sceneModes.getCount(); idx++) {
String text = (String)binding.sceneModes.getItemAtPosition(idx);
if (text.indexOf(sceneModeText) == 0) {
binding.sceneModes.setSelection(idx);
break;
}
}
binding.exposuretime.setText(Integer.toString(jsonObject.optInt("exposureTime", 0)));
binding.sensitivity.setText(Integer.toString(jsonObject.optInt("sensibility", 0)));
binding.orientations.setSelection(jsonObject.optInt("orientation", 0));
@ -223,8 +234,13 @@ public class ChannelActivity extends AppCompatActivity {
jsonObject.put("usbCamera", binding.btnUsbCamera.isChecked() ? 1 : 0);
jsonObject.put("autoExposure", binding.btnAutoExplosure.isChecked() ? 1 : 0);
jsonObject.put("autoFocus", binding.btnAutoFocus.isChecked() ? 1 : 0);
jsonObject.put("hdrMode", binding.btnHdrMode.isChecked() ? 1 : 0);
jsonObject.put("nightMode", binding.btnNightMode.isChecked() ? 1 : 0);
// jsonObject.put("hdrMode", binding.btnHdrMode.isChecked() ? 1 : 0);
// jsonObject.put("nightMode", binding.btnNightMode.isChecked() ? 1 : 0);
int sceneMode = 0;
String sceneModeText = (String)binding.sceneModes.getSelectedItem();
sceneModeText = sceneModeText.substring(0, sceneModeText.indexOf(" -"));
sceneMode = Integer.parseInt(sceneModeText);
jsonObject.put("sceneMode", sceneMode);
jsonObject.put("exposureTime", Integer.parseInt(binding.exposuretime.getText().toString()));
jsonObject.put("sensibility", Integer.parseInt(binding.sensitivity.getText().toString()));
jsonObject.put("orientation", binding.orientations.getSelectedItemPosition());

@ -130,26 +130,17 @@
app:layout_constraintStart_toEndOf="@+id/btnAutoExplosure"
app:layout_constraintTop_toBottomOf="@+id/resolutionCX" />
<Switch
android:id="@+id/btnHdrMode"
<Spinner
android:id="@+id/sceneModes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:entries="@array/sceneModes"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin_small"
android:text="HDR"
android:layout_marginTop="@dimen/activity_vertical_margin"
app:layout_constraintStart_toEndOf="@+id/btnAutoFocus"
app:layout_constraintTop_toBottomOf="@+id/resolutionCX" />
<Switch
android:id="@+id/btnNightMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin_small"
android:text="Night"
app:layout_constraintStart_toEndOf="@+id/btnHdrMode"
app:layout_constraintTop_toBottomOf="@+id/resolutionCX" />
<TextView
android:id="@+id/textViewExplosure"
android:layout_width="wrap_content"

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="sceneModes">
<item>0 - Disabled</item>
<item>5 - Night</item>
<item>5 - Night</item>
<item>9 - Snow</item>
<item>10 - Sunset</item>
<item>12 - Fireworks</item>
<item>18 - HDR</item>
</string-array>
</resources>
Loading…
Cancel
Save