1 | initial version |
There's an example on how to create swing GUI with Java OpenCV. The full source is available here: https://github.com/JavaOpenCVBook/code/tree/master/chapter2/opencv-gui You can compile and run it in a couple minutes using maven and the information here: https://github.com/JavaOpenCVBook/code
You would basically have to put a JSlider to your JFrame, and the code there would be something like this:
private void setupSlider(JFrame frame) {
JLabel sliderLabel = new JLabel("Blur level", JLabel.CENTER);
sliderLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
int minimum = 0;
int maximum = 10;
int initial =0;
JSlider levelSlider = new JSlider(JSlider.HORIZONTAL,
minimum, maximum, initial);
levelSlider.setMajorTickSpacing(2);
levelSlider.setMinorTickSpacing(1);
levelSlider.setPaintTicks(true);
levelSlider.setPaintLabels(true);
levelSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
int level = (int)source.getValue();
Mat output = imageProcessor.blur(image, level);
updateView(output);
}
});
frame.add(sliderLabel);
frame.add(levelSlider);
}