diff --git a/app/src/main/java/org/lezizi/microsphere/PMDActivity.java b/app/src/main/java/org/lezizi/microsphere/PMDActivity.java index edb3e2d..5f555ef 100644 --- a/app/src/main/java/org/lezizi/microsphere/PMDActivity.java +++ b/app/src/main/java/org/lezizi/microsphere/PMDActivity.java @@ -3,9 +3,14 @@ import android.content.Intent; import android.graphics.Bitmap; import android.os.Environment; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.view.View; import android.widget.ImageView; +import android.widget.SeekBar; +import android.widget.TextView; import org.opencv.android.Utils; import org.opencv.core.CvType; @@ -17,50 +22,134 @@ import org.opencv.imgcodecs.Imgcodecs; import org.opencv.imgproc.Imgproc; +import java.security.Key; +import java.util.ArrayList; +import java.util.List; + public class PMDActivity extends AppCompatActivity { + protected MatOfKeyPoint keypoints; + protected Mat cimg; + protected Mat resized; + protected void update_preview(){ + SeekBar bar1 = findViewById(R.id.seekBar1); + SeekBar bar2 = findViewById(R.id.seekBar2); + SeekBar bar3 = findViewById(R.id.seekBar3); + float barValue1 = bar1.getProgress()/(float)100.0; + float barValue2 = bar2.getProgress()/(float)100.0; + float barValue3 = bar3.getProgress()/(float)100.0; + TextView result= findViewById(R.id.textView2); + + Mat out=new Mat(cimg.rows()/4, cimg.cols()/4, CvType.CV_64FC3); + + ArrayList samll_list=new ArrayList<>(); + ArrayList middle_list=new ArrayList<>(); + ArrayList big_list=new ArrayList<>(); + for (KeyPoint vkp : keypoints.toList()) + { + if (vkp.sizemax_size) max_size=vkp.size; } + SeekBar bar1 = findViewById(R.id.seekBar1); + SeekBar bar2 = findViewById(R.id.seekBar2); + SeekBar bar3 = findViewById(R.id.seekBar3); + bar1.setMax((int)(max_size*100.0)); + bar2.setMax((int)(max_size*100.0)); + bar3.setMax((int)(max_size*100.0)); - Mat out=new Mat(cimg.rows()/4, cimg.cols()/4, CvType.CV_64FC3); - Mat m=new Mat(cimg.rows(), cimg.cols(), CvType.CV_64FC3); - Features2d.drawKeypoints(resized,keypoints,out,new org.opencv.core.Scalar(0,255,0), Features2d.DRAW_RICH_KEYPOINTS ); - Imgproc.resize(out, m, m.size(),0,0,Imgproc.INTER_AREA); + SeekBar.OnSeekBarChangeListener listener=new SeekBar.OnSeekBarChangeListener(){ + @Override + public void onProgressChanged(SeekBar seekBar, int i, boolean b) { + if (b){ + update_preview(); + } + } - // convert to bitmap: - Bitmap bm = Bitmap.createBitmap(m.cols(), m.rows(),Bitmap.Config.ARGB_8888); - Utils.matToBitmap(m, bm); + @Override + public void onStartTrackingTouch(SeekBar seekBar) { - // find the imageview and draw it! - ImageView iv = findViewById(R.id.imageView1); - iv.setImageBitmap(bm); + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }; + + bar1.setOnSeekBarChangeListener(listener); + bar2.setOnSeekBarChangeListener(listener); + bar3.setOnSeekBarChangeListener(listener); + + update_preview(); } } diff --git a/app/src/main/res/layout/activity_maaresult.xml b/app/src/main/res/layout/activity_maaresult.xml index a3bf45b..1bf01d5 100644 --- a/app/src/main/res/layout/activity_maaresult.xml +++ b/app/src/main/res/layout/activity_maaresult.xml @@ -16,22 +16,4 @@ android:layout_height="0dp" android:layout_width="0dp" /> - diff --git a/app/src/main/res/layout/activity_pmd.xml b/app/src/main/res/layout/activity_pmd.xml index 6b8168d..9a96de4 100644 --- a/app/src/main/res/layout/activity_pmd.xml +++ b/app/src/main/res/layout/activity_pmd.xml @@ -1,15 +1,99 @@ - - + + + + + + + + + + + + + + + + + + + - + android:layout_gravity="bottom|end" + android:layout_margin="@dimen/fab_margin" + app:srcCompat="@android:drawable/ic_menu_view" /> + + +