HTC one M8使用双摄像头来实现3D尺寸加效果。这种技术的名称是什么?
这是一个演示: Video
答案 0 :(得分:1)
使用深度图进行图像处理,有关详细信息,请参阅: https://www.htcdev.com/devcenter/opensense-sdk/htc-dual-lens-api
无需逆向工程 - DimensionPlus效果只是2D加效果的实现(如果您需要名称),如下所述:https://en.wikipedia.org/wiki/2D-plus-depth
此效果使用照片中包含的深度贴图来创建标准几何图形,SDK使用该几何图形来使用陀螺仪可视化效果(或者您可以编程触摸导航)。
答案 1 :(得分:1)
3D Dimension Plus效果是使用HTC提供的Dual Lens SDK实现的:
https://www.htcdev.com/devcenter/opensense-sdk/htc-dual-lens-api/htc-dual-lens-sdk-installation/
如果您下载SDK,它将包含显示如何实现所需效果的示例。
以下是SDK示例中的代码示例,由HTC提供:
public class DimenstionPlusActivity extends Activity {
private DimensionPlusView dimensionPlusView;
final String filename = "dimensionPlusSample.jpg"; // copy to root of sdcard
private File root = Environment.getExternalStorageDirectory();
final String filepath = root+"/"+filename;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dimensionPlusView = (DimensionPlusView) findViewById(R.id.dimensionPlusView);
try {
dimensionPlusView.loadDimensionPlusFile(filepath);
} catch (IOException e) {
if(e.getMessage().contains("READFILE_ERROR")){
Toast.makeText(getBaseContext(),filename+" not found", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getBaseContext(),filename+" not supported", Toast.LENGTH_LONG).show();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected void onResume() {
super.onResume();
dimensionPlusView.onResume();
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sensorManager.registerListener(mSenserEventListener, sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
SensorManager.SENSOR_DELAY_FASTEST);
}
@Override
protected void onPause() {
super.onPause();
dimensionPlusView.onPause();
SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sensorManager.unregisterListener(mSenserEventListener);
}
@Override
protected void onDestroy () {
super.onDestroy();
dimensionPlusView.release();
}
private SensorEventListener mSenserEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
// gyro event
float gravity1 = event.values[0];
float gravity2 = event.values[1];
int orientation = ((WindowManager) DimenstionPlusActivity.this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
.getRotation();
switch (orientation) {
case Surface.ROTATION_0:
dimensionPlusView.gyro(-gravity2, gravity1);
break;
case Surface.ROTATION_90:
dimensionPlusView.gyro(-gravity1, -gravity2);
break;
case Surface.ROTATION_180:
dimensionPlusView.gyro(gravity2, -gravity1);
break;
case Surface.ROTATION_270:
dimensionPlusView.gyro(gravity1, gravity2);
break;
default:
dimensionPlusView.gyro(-gravity2, gravity1);
break;
}
return;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};
}