0
我想自動對焦礦石有一個更好的質量凸輪有人可以幫我嗎?我想讓我的qr掃描儀自動對焦,並且我想將凸輪切換到正面和背面。 這是我的代碼...android studio自動對焦qr掃描儀
public class MainActivity extends AppCompatActivity {
SurfaceView cameraPreview;
TextView txtResult;
BarcodeDetector barcodeDetector;
CameraSource cameraSource;
ImageButton cameraSwitch;
final int RequestCameraPermissionID = 1001;
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case RequestCameraPermissionID: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
return;
}
try
{
cameraSource.start(cameraPreview.getHolder());
cameraPreview.findFocus();
} catch (IOException e) {
e.printStackTrace();
}
}
}
break;
}
}
//QR-code scanner
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cameraPreview = (SurfaceView) findViewById(R.id.cameraPreview);
cameraSwitch = (ImageButton) findViewById(R.id.cameraSwitch);
txtResult = (TextView) findViewById(R.id.txtResult);
barcodeDetector = new BarcodeDetector.Builder(this)
.setBarcodeFormats(Barcode.QR_CODE)
.build();
cameraSource = new CameraSource
.Builder(this, barcodeDetector)
.setRequestedPreviewSize(500, 500)
.build();
cameraSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
}
});
任何幫助將是不錯的。