这个问题让我感到不安,直到一周。我想像托管一样拍照,但在Sony Camera API不支持。所以我编码就像连续拍摄5张不同值(0,+ 2,-2,-4,+ 4)的图片一样。 (使用按钮,按下按钮时应拍照5次)你可以看到下面的代码:
此代码用于设置相机上的快门速度
private void setShutterSpeed(final int valofShutterSpeed) {
new Thread() {
@Override
public void run() {
try {
JSONObject replyJson = mRemoteApi.setShutterSpeed(valofShutterSpeed);
JSONArray resultsObj = replyJson.getJSONArray("result");
int resultCode = resultsObj.getInt(0);
if (resultCode == 0) {
takePicture();
Log.e(TAG, "SetSHutterSpeed: Mode success.");
} else {
Log.e(TAG, "SetSHutterSpeed mode: error: " + resultCode);
DisplayHelper.toast(getApplicationContext(), //
R.string.msg_error_api_calling);
}
} catch (IOException e) {
Log.e(TAG, "SetSHutterSpeed: setShutterSpeed: IOException: " + e.getMessage());
return;
} catch (JSONException e) {
Log.e(TAG, "SetSHutterSpeed: setShutterSpeed: JSON format error.");
}
}
}.start();
}
此拍照代码:
private void takePicture() {
if (mLiveviewSurface == null || !mLiveviewSurface.isStarted()) {
DisplayHelper.toast(getApplicationContext(), R.string.msg_error_take_picture);
return;
}
new Thread() {
@Override
public void run() {
try {
JSONObject replyJson = mRemoteApi.actTakePicture();
JSONArray resultsObj = replyJson.getJSONArray("result");
JSONArray imageUrlsObj = resultsObj.getJSONArray(0);
String postImageUrl = null;
if (1 <= imageUrlsObj.length()) {
postImageUrl = imageUrlsObj.getString(0); continousShottingWithDifferentShutterValue();
}
if (postImageUrl == null) {
Log.w(TAG, "takePicture: post image URL is null.");
DisplayHelper.toast(getApplicationContext(), //
R.string.msg_error_take_picture);
return;
}
// Show progress indicator
DisplayHelper.setProgressIndicator(SonyCameraActivity.this, false);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
这是for循环:
int val, posVal = 0;
int currentShutterSpeed = 0;
private void continousShottingWithDifferentShutterValue() {
if (val == 0) {
currentShutterSpeed = -5;
setShutterSpeed(currentShutterSpeed);
val++;
} else if (val == 1) {
currentShutterSpeed = 5;
setShutterSpeed(currentShutterSpeed);
val++;
} else if (val == 2) {
currentShutterSpeed = -10;
setShutterSpeed(currentShutterSpeed);
val++;
} else if (val == 3) {
currentShutterSpeed = 10;
setShutterSpeed(currentShutterSpeed);
val++;
} else if (val == 4) {
setShutterSpeedVal0(0);
posVal++;
}
if (posVal == 3) {
posVal = 0;
val = 0;
}
}
但是当我拍照时,有时快门速度或拍摄照片会出现错误并且循环停止。
错误类型有:setShutterSpeed IOExeption错误:500;或未设置setShutterSpeed。有人使用Sonycamera远程API,并知道如何修复它或拍摄5次不同的值。会感激任何想法。谢谢
答案 0 :(得分:0)
我解决了这个问题。这是一个快门速度值错误。正如你在Sony Camera Api中所知,没有快门速度的值,我在相机设置中写了它。和JSON请求和响应不匹配所以它显示错误500.如果有人想使用快门速度值:这里是:
String shutterValue[] = {"30\"", "25\"", "20\"", "15\"", "13\"", "10\"", "8\"", "6\"",
"5\"", "4\"", "3.2\"", "2.5\"", "2\"", "1.6\"", "1.3\"", "1\"", "0.8\"", "0.6\"", "0.5\"",
"0.4\"", "1/3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13", "1/15", "1/20", "1/25", "1/30",
"1/40", "1/50", "1/60", "1/80", "1/100", "1/125", "1/160", "1/200", "1/250", "1/320", "1/400",
"1/500", "1/640", "1/800", "1/1000", "1/1250", "1/1600", "1/2000", "1/2500", "1/3200", "1/4000"};