-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
152 lines (115 loc) · 4.8 KB
/
MainActivity.java
File metadata and controls
152 lines (115 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package com.example.democv;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import org.opencv.android.OpenCVLoader;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
ImageView imageView;
Button button_open, button_gray, button_circle;
Bitmap bitmap;
static {
if(!OpenCVLoader.initDebug()){
Log.e("OpenCV", "init unsuccesfull");
}
else
Log.e("OpenCV", "success");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
button_open = findViewById(R.id.button_open);
button_gray = findViewById(R.id.button_gray);
button_circle = findViewById(R.id.button_circle);
button_open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, 0);
}
});
button_gray.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//harris h = new harris();
//BitmapDrawable drawable = (BitmapDrawable) iv.getDrawable();
//Bitmap rgb = drawable.getBitmap();
Bitmap rgb = Bitmap.createBitmap(bitmap);
//rgb = Bitmap.createScaledBitmap(rgb,200, 200, true);
if(rgb == null)
{
Toast.makeText(getApplicationContext(), "LOAD AN IMAGE!!!", Toast.LENGTH_LONG).show();
return;
}
kinks k = new kinks(rgb);
k.run_spline();
Bitmap green = k.getSp(); //k.getCorner();
//imageView.setImageDrawable(null);
/*ColorMatrix m = new ColorMatrix();
m.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(m);
imageView.setColorFilter(filter);*/
imageView.setImageBitmap(null);
imageView.setImageBitmap(green);
Toast.makeText(getApplicationContext(), "Done!!!", Toast.LENGTH_LONG).show();
//bitmap = green;
}
});
button_circle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//harris h = new harris();
//BitmapDrawable drawable = (BitmapDrawable) iv.getDrawable();
//Bitmap rgb = drawable.getBitmap();
Bitmap rgb = Bitmap.createBitmap(bitmap);
//rgb = Bitmap.createScaledBitmap(rgb,200, 200, true);
if(rgb == null)
{
Toast.makeText(getApplicationContext(), "LOAD AN IMAGE!!!", Toast.LENGTH_LONG).show();
return;
}
kinks k = new kinks(rgb);
k.run_circle();
Bitmap green = k.getSp(); //k.getCorner();
imageView.setImageBitmap(null);
imageView.setImageBitmap(green);
Toast.makeText(getApplicationContext(), "Done!!!", Toast.LENGTH_LONG).show();
//bitmap = green;
}
});
}
@Override
protected void onActivityResult(int reqCode, int resCode, Intent data)
{
super.onActivityResult(reqCode, resCode, data);
switch (reqCode) {
case 0:
if (resCode == RESULT_OK) {
Uri imageUri = data.getData();
Bitmap bmp = null;
try {
bmp = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
bmp = Bitmap.createScaledBitmap(bmp,400, 400, true);
imageView.setImageBitmap(bmp);
bitmap = Bitmap.createBitmap(bmp);
}
}
}
}