I am a beginner in Java / Android and am developing an application with image processing. At the moment I already have the application working with the necessary filters.
In case I have:
Canny(edges, edges, thresholdCanny, thresholdCanny2);
I would like to apply a SeekBar to change the values of the thresholdCanny and thresholdCanny2 variables directly in the running application, ie adjusting the intensity of the filters.
My function is already implemented with SeekBar implemented:
public Mat onCameraFrame(final CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
// Image Processing
Mat rgba = inputFrame.rgba();
Mat edges = new Mat(rgba.size(), CV_8UC1);
final int thresholdCanny = 80, thresholdCanny2 = 100;
// SeekBar change value
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
try {
Imgproc.cvtColor(rgba, edges, Imgproc.COLOR_RGB2GRAY, 4);
Imgproc.GaussianBlur(edges, edges, new Size(5,5), 30, 50);
Canny(edges, edges, thresholdCanny, thresholdCanny2);
} catch (Exception e) {
Log.i(TAG, e.toString());
e.printStackTrace();
}
return edges;
}
Can you capture the current value of thresholdCanny and ThresholdCanny2 within the onProgressChanged
and replace the values of these variables according to SeekBar's movement? How can I do this?
Thank you in advance!