ResistorScanner
ResistorScanner copied to clipboard
Enable macro mode
Hello
on the S3 jellybean detection does not work because camera can not focus close enough.
Here I added a checkbox in the main view after Seekbar
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Macro"
android:id="@+id/btnMacro"
android:layout_above="@+id/CameraZoomControls"
android:layout_centerHorizontal="true" />
Then I added code in CameraView to handle the checkbox
public void setMacroControl(CheckBox macroControl)
{
_macroControl = macroControl;
_macroControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Camera.Parameters params = mCamera.getParameters();
List<String> FocusModes = params.getSupportedFocusModes();
if (isChecked) {
if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_MACRO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
}
} else {
if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
} else if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
}
mCamera.setParameters(params);
}
});
}
it is enabled in main activity with:
_resistorCameraView.setMacroControl((CheckBox) findViewById(R.id.btnMacro));
It will be very useful.
Nice! If you make a pull request, I can merge these changes in.
you can also use some old fashioned copy-paste! I dont want to fork and all for 10 code lines :)
This code just has to be added, there is nothing to remove.
Heh, touché