0
I am a beginner in Java / Android and I am developing an application with image processing. 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 variables thresholdCanny and thresholdCanny2 directly in the running application, that is, adjust the intensity of the filters.
Follow my role already 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;
}
It is possible to capture the current value of thresholdCanny and thresholdCanny2 within the onProgressChanged
and replace the values of these variables according to the Seekbar movement? How can I do this?
Thank you in advance!
Should I use thresholdCanny = seekBar.getProgress(); ? Another doubt, it is possible to make this variable assume a value with some other calculation? example: thresholdCanny - 20 // Thank you
– Alex Colombari
Can do thresholdCanny = Progress;
– Antonio Santos
In this case you can create a method
setThresholdCanny(int thresholdCanny)
and do the calculation in the method. And instead of usingthresholdCanny = progress;
you dosetThresholdCanny(progress)
;. So it becomes more flexible to create calculations etc.– Antonio Santos
Got it, thanks for the help!
– Alex Colombari