Manifest.xml 파일에서 반투명을 적용하고 싶은 액티비티를 아래와 같이 수정

1
2
<activity android:name=".marryPopup"
            android:theme="@style/Theme.AppCompat.Translucent"></activity>
cs

.java 파일 수정

1
2
3
4
5
6
7
8
9
10
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
        
   WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
   layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
   layoutParams.dimAmount = 0.6f; // 투명도 0 ~ 1
   getWindow().setAttributes(layoutParams);
 
   setContentView(R.layout.activity_marry_popup);
}
cs


스테레오 매칭

○ 서로 다른 시점의 두 장의 이미지로 부터 거리 정보를 추출.

○ 양쪽 이미지 사이의 대응되는 점이 차이나는 정도를 통해 거리 정보를 얻을 수 있음.


13SCwiths7         13SCwiths6



에피폴라 제약조건 (epipolar constraint)

○ 매칭 시간 감소.

○ 2d 이미지 대상의 검색을 1d 라인상의 검색으로 간소화.



◎ 매칭 (Matching)

○ 이미지 레티피케이션 (Image Rectification)

○ 에피폴라 라인을 따라 매칭


잘 쓰던 피파온라인 정보 앱들이 개발자분들의 개인 사정으로 업데이트가 끊기면서


에라.. 없으면 내가 만들어 써야겠다 다짐하고 잠깐 작업을 했더니 새로운 앱이 나와 처박아버렸다.


혹시 필요하신분은 가져다 쓰시길..



위 캡쳐는 실행 화면.


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
public class MainActivity extends AppCompatActivity {
 
    private String htmlPageUrl = "http://fifaonline3.nexon.com/datacenter/player/list.aspx?strpynm=";
    private String search;
    private TextView textviewHtmlDocument;
    private String htmlContentInStringFormat;
    private String searchResult01 = "", searchResult02 = "", searchResult03 = "", searchResult04 = "", searchResult05 = "", searchResult06 = "", searchResult07 = "", searchResult08 = "", searchResult09 = "", searchResult10 = "", searchResult11 = "";
    final ArrayList<String> items = new ArrayList<String>() ;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, items);
        final ListView listview = (ListView) findViewById(R.id.listView) ;
        listview.setAdapter(adapter) ;
 
        textviewHtmlDocument = (TextView)findViewById(R.id.textView);
        textviewHtmlDocument.setMovementMethod(new ScrollingMovementMethod());
 
        Button htmlTitleButton = (Button)findViewById(R.id.button);
        final EditText editText=(EditText)findViewById(R.id.editText);
        htmlTitleButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String playername = editText.getText().toString();
                search = htmlPageUrl + playername;
                JsoupAsyncTask jsoupAsyncTask = new JsoupAsyncTask();
                jsoupAsyncTask.execute();
                try {Thread.sleep(3000);} catch (InterruptedException e) { }
                adapter.notifyDataSetChanged();
            }
        });
    }
 
    private class JsoupAsyncTask extends AsyncTask<Void, Void, Void> {
 
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }
 
        @Override
        protected Void doInBackground(Void... params) {
            try {
                Document doc = Jsoup.connect(search).get();
                Elements links = doc.select(".name");
 
                for (Element link : links) {
                    htmlContentInStringFormat += (link.attr("abs:href"+ "("+link.text().trim() + ")\n");
 
                    Elements linkelements = link.getElementsByTag("td");
                    int elesize = linkelements.size();
 
                }
 
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
 
        @Override
        protected void onPostExecute(Void result) {
            textviewHtmlDocument.setText("검색결과");
            items.clear();
            textviewHtmlDocument.setText(htmlContentInStringFormat);
        }
    }
 
}
cs


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
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.vrlab.fifa3simulation.MainActivity">
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search"
        android:id="@+id/button"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true" />
 
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:text=""
        android:ems="10"
        android:layout_alignBottom="@+id/button"
        android:layout_alignParentStart="true"
        android:id="@+id/editText"
        android:layout_toStartOf="@+id/button" />
 
    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText"
        android:layout_centerHorizontal="true"
        android:id="@+id/textView" />
 
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/listView"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/textView" />
 
</RelativeLayout>
 
cs


개발환경

○ JSP, CSS, mysql

○ 소스코드 : https://github.com/IkHyunJo/tennis



구현결과

01234567891011

01234567891011121314

01234



'Computer > Coding' 카테고리의 다른 글

[Android] 반투명 액티비티  (0) 2017.05.13
[Android] 피파온라인 선수 검색 예제  (0) 2017.04.12
[Processing] particle/interaction project  (0) 2017.03.30
[opencv] Simple lane detection  (0) 2017.03.30
[opencv] Line matching  (0) 2017.03.30

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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import processing.video.*;
 
int stat;
int btn = 0;
int btn2 = 0;
int btn3 = 0;
float nbsum = 0;
float pbsum = 0;
float nbsum2 = 0;
float pbsum2 = 0;
float nbsum3 = 0;
float pbsum3 = 0;
 
ParticleSystem ps;
Capture video;
PImage img, dback;
double sum4;
 
void setup() {
  size(600480);
  video = new Capture(this, 64048030);
  video.start();
 
  img = createImage(640480, RGB);
  dback = createImage(640480, GRAY);
  background(0);
  
  ps = new ParticleSystem(new PVector(width/2-1500));
}
 
 
void draw() {
  if(video.available()){
    video.read();
  }
 
  video.loadPixels();
  img.loadPixels();
  for(int x = 50; x < 630; x++){
    for(int y = 0; y < 480; y++){
      img.pixels[y*img.width +(640-x)] = video.pixels[y*img.width + x];
    }
  }
  img.filter(GRAY);
  checkInterection2();
  dithering();
  checkInterection();
  if(btn == 1){
    ps.addParticle();
    ps.run();
  }
  
  image(img, 0480);
  //rect(300, 0, 20, 20);
}
 
void checkInterection(){
  img.loadPixels();
  nbsum = 0;
  for(int dx = 0; dx < 20; dx++){
    for(int dy = 0; dy < 20; dy++){
      nbsum = nbsum + brightness(img.pixels[(dy)*img.width + (500+dx)]);
    }
  }
 
  if(abs(nbsum - pbsum) > 6000){
    if(btn == 0){btn = 1;}
    else if(btn == 1){btn = 0;}
  }
  //text("brightness difference : " + abs(nbsum - pbsum), 10, 480);
  
  pbsum = nbsum;
}
 
void checkInterection2(){
  img.loadPixels();
  nbsum2 = 0;
  for(int dx = 0; dx < 20; dx++){
    for(int dy = 0; dy < 20; dy++){
      nbsum2 = nbsum2 + brightness(img.pixels[(dy)*img.width + (100+dx)]);
    }
  }
  
  if(abs(nbsum2 - pbsum2) > 10000){
    if(btn2 == 0){if(btn3==1){btn2 = 2;}else{btn2 = 1;}}
    else if(btn2 == 1){btn2 = 2;}
    else if(btn2 == 2){btn2 = 3;}
    else if(btn2 == 3){btn2 = 4;}
    else if(btn2 == 4){btn2 = 0;}
  }
  //text("brightness difference : " + abs(nbsum2 - pbsum2), 10, 480);
  
  pbsum2 = nbsum2;
}
 
void backbtn(){
  img.loadPixels();
  nbsum3 = 0;
  for(int dx = 0; dx < 20; dx++){
    for(int dy = 0; dy < 20; dy++){
      nbsum3 = nbsum3 + brightness(img.pixels[(dy)*img.width + (500+dx)]);
    }
  }
  
  if(abs(nbsum3 - pbsum3) > 10000){
    if(btn3 == 0){btn3 = 1;}
    else if(btn3 == 1){btn3 = 2;}
    else if(btn3 == 2){btn3 = 3;}
    else if(btn3 == 3){btn3 = 4;}
    else if(btn3 == 4){btn3 = 0;}
  }
  text("brightness difference : " + abs(nbsum3 - pbsum3), 10480);
  
  pbsum3 = nbsum3;
}
 
 
void dithering(){
  stat = 1;
  
  img.loadPixels();
  if(btn2 == 0){background(0);}
  else if(btn2 == 1){background(#25DBD6);}
  else if(btn2 == 2){background(#0130F7);}
  else if(btn2 == 3){background(#C03A1A);}
  else if(btn2 == 4){background(#8A3C86);}
  for(int x = 5; x < 635; x+=10){
    for(int y = 5; y < 475; y+=10){
      sum4 = 0;
      for(int a = -5; a<5; a++){
        for(int b = -5; b<5; b++){
          sum4 = sum4 + brightness(img.pixels[(y+b)*img.width + (x+a)]);
        }
      }     
 
      if (sum4 > 25000){
        ellipse(x, y, 1010);
        noStroke();
      }else if ((20000<sum4)&&(sum4<25000)){
        ellipse(x, y, 88);
        noStroke();
      }else if ((15000<sum4)&&(sum4<20000)){
        ellipse(x, y, 66);
        noStroke();
      }else if ((10000<sum4)&&(sum4<15000)){
        ellipse(x, y, 44);
        noStroke();
      }else if ((5000<sum4)&&(sum4<10000)){
        ellipse(x, y, 22);
        noStroke();
      }
      if(btn2 == 0){
        int crand = int(random(1,4));
        if (crand == 1){fill(#DA2429);}
        else if (crand == 2){fill(#FECF08);}
        else if (crand == 3){fill(#3FC5E5);}
        else if (crand == 4){fill(#75C379);}
      }
      else if(btn2 == 1){fill(#DA2429);}
      else if(btn2 == 2){fill(#FECF08);}
      else if(btn2 == 3){fill(#3FC5E5);}
      else if(btn2 == 4){fill(#75C379);}
    }
  }
}
 
 
class ParticleSystem {
  ArrayList<Particle> particles;
  PVector origin;
 
  ParticleSystem(PVector position) {
    origin = position.copy();
    particles = new ArrayList<Particle>();
  }
 
  void addParticle() {
    particles.add(new Particle(origin));
  }
 
  void run() {
    for (int i = particles.size()-1; i >= 0; i--) {
      Particle p = particles.get(i);
      p.run();
      if (p.isDead()) {
        particles.remove(i);
      }
    }
  }
}
 
class Particle {
  PVector position;
  PVector velocity;
  PVector acceleration;
  float lifespan;
 
  Particle(PVector l) {
    acceleration = new PVector(00.05);
    velocity = new PVector(random(-11), random(-20));
    position = l.copy();
    lifespan = 255.0;
  }
 
  void run() {
    update();
    display();
  }
 
  void update() {
    velocity.add(acceleration);
    position.add(velocity);
    lifespan -= 0.4;
  }
 
  void display() {
    //stroke(255, lifespan);
    noStroke();
    int crand = int(random(1,4));
    if (crand == 1){fill(#DA2429, lifespan);}
    else if (crand == 2){fill(#FECF08, lifespan);}
    else if (crand == 3){fill(#3FC5E5, lifespan);}
    else if (crand == 4){fill(#75C379, lifespan);}
    //fill(#854845, lifespan); //change color
    int rands = int(random(8,20));
    ellipse(position.x, position.y, rands, rands);
  }
 
  boolean isDead() {
    if (lifespan < 0.0) {
      return true;
    } else {
      return false;
    }
  }
}
cs



<실행 영상>

'Computer > Coding' 카테고리의 다른 글

[Android] 반투명 액티비티  (0) 2017.05.13
[Android] 피파온라인 선수 검색 예제  (0) 2017.04.12
[JSP] 테니스 토너먼트 웹  (0) 2017.03.30
[opencv] Simple lane detection  (0) 2017.03.30
[opencv] Line matching  (0) 2017.03.30
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
153
154
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
 
using namespace cv;
using namespace std;
 
Mat grad, src;
Mat edges(600800, CV_8UC1);
char name[100];
 
void main()
 
{
    int gg = 0;
    while (1){
        sprintf(name, "Testvideo/testvideo1/Left_%d.bmp", gg);
        Mat src = imread(name, 1);
        if (!src.data) break// src 이미지 데이터가없으면 종료
 
        edges = Scalar(0);
        
        //소벨 필터
        Mat src_gray;
        Mat abs_grad_x, abs_grad_y;
        int scale = 1;
        int delta = 0;
        int ddepth = CV_16S;
 
        //이미지 로딩
        GaussianBlur(src, src, Size(33), 00, BORDER_DEFAULT);
        cvtColor(src, src_gray, CV_RGB2GRAY);
 
        Mat grad_x, grad_y;
 
        /// Gradient X
        Sobel(src_gray, grad_x, ddepth, 103, scale, delta, BORDER_DEFAULT);
        convertScaleAbs(grad_x, abs_grad_x);
 
        /// Gradient Y
        Sobel(src_gray, grad_y, ddepth, 013, scale, delta, BORDER_DEFAULT);
        convertScaleAbs(grad_y, abs_grad_y);
 
        addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.50, grad);
        
        //오른쪽 엣지 찾기
        vector<Point2i> rPoints;
        for (int y = 430; y < grad.rows; y = y + 5)
        {
            bool i = false;
            uchar* data = grad.ptr<uchar>(y);
            for (int x = 300; x < grad.cols; x++) {
                if (data[x] > 100 && i == false)
                {
                    rectangle(edges, Point(x, y), Point(x - 2, y - 2), Scalar(25500), 2);
                    rPoints.push_back(Point(x, y));
                    i = true;
                }
            }
        }
        //왼쪽 엣지 찾기
        vector<Point2i> lPoints;
        for (int y = 380; y < grad.rows; y = y + 5)
        {
            bool i = false;
            uchar* data = grad.ptr<uchar>(y);
            for (int x = 300; x > 0; x--) {
                if (data[x] > 100 && i == false)
                {
                    rectangle(edges, Point(x, y), Point(x - 2, y - 2), Scalar(25500), 2);
                    lPoints.push_back(Point(x, y));
                    i = true;
                }
            }
        }
 
        
        // 라인 찾기
        vector<Vec2f> lines;
        HoughLines(edges, lines, 1, CV_PI / 18015000);
        int r, l;
        l = 0, r = 0;
        // 라인 그리기
        for (size_t i = 0; i < lines.size(); i++)
        {
            float rho = lines[i][0], theta = lines[i][1];
            Point pt1, pt2;
            double a = cos(theta), b = sin(theta);
 
            if ((a / b) < 0)
            {
                r = i;
            }
            else
            {
                l = i;
                cout << l << endl;
            }
        }
        
        
        float rho = lines[r][0], theta = lines[r][1];
        Point pt1, pt2;
        double a = cos(theta), b = sin(theta);
        double x0 = a*rho, y0 = b*rho;
        pt1.x = cvRound(x0 + 1000 * (-b));
        pt1.y = cvRound(y0 + 1000 * (a));
        pt2.x = cvRound(x0 - 1000 * (-b));
        pt2.y = cvRound(y0 - 1000 * (a));
        
        float rho2 = lines[l][0], theta2 = lines[l][1];
        Point pt3, pt4;
        double a2 = cos(theta2), b2 = sin(theta2);
        double x02 = a2*rho2, y02 = b2*rho2;
        pt3.x = cvRound(x02 + 1000 * (-b2));
        pt3.y = cvRound(y02 + 1000 * (a2));
        pt4.x = cvRound(x02 - 1000 * (-b2));
        pt4.y = cvRound(y02 - 1000 * (a2));
        
        double t;
        double s;
 
        double under = (pt4.y - pt3.y)*(pt2.x - pt1.x) - (pt4.x - pt3.x)*(pt2.y - pt1.y);
 
        double _t = (pt4.x - pt3.x)*(pt1.y - pt3.y) - (pt4.y - pt3.y)*(pt1.x - pt3.x);
        double _s = (pt2.x - pt1.x)*(pt1.y - pt3.y) - (pt4.y - pt1.y)*(pt1.x - pt3.x);
 
 
 
        t = _t / under;
        s = _s / under;
 
 
        double cx = pt1.x + t * (double)(pt2.x - pt1.x);
        double cy = pt1.y + t * (double)(pt2.y - pt1.y);
        Point cp;
        cp.x = cx, cp.y = cy;
 
        line(src, pt2, cp, Scalar(00255), 3, CV_AA);
        line(src, pt3, cp, Scalar(00255), 3, CV_AA);
        rectangle(src, Point(cx, cy), Point(cx - 4, cy - 4), Scalar(25500), 4);
        
 
 
        cv::namedWindow("Detected Lines with Hough");
        cv::imshow("Detected Lines with Hough", src);
 
        gg++;
        waitKey(1);
    }
    
}
cs



<구현 결과 영상>


<구현 과정>

'Computer > Coding' 카테고리의 다른 글

[Android] 반투명 액티비티  (0) 2017.05.13
[Android] 피파온라인 선수 검색 예제  (0) 2017.04.12
[JSP] 테니스 토너먼트 웹  (0) 2017.03.30
[Processing] particle/interaction project  (0) 2017.03.30
[opencv] Line matching  (0) 2017.03.30


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
#include <opencv2/line_descriptor.hpp>
 
#include "opencv2/core/utility.hpp"
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
 
#include <iostream>
 
using namespace cv;
 
static const char* keys =
"{@image_path1 | | Image path 1 }"
        "{@image_path2 | | Image path 2 }" };
 
static void help()
{
  std::cout << "\nThis example shows the functionalities of lines extraction " << "and descriptors computation furnished by BinaryDescriptor class\n"
                << "Please, run this sample using a command in the form\n" << "./example_line_descriptor_compute_descriptors <path_to_input_image 1>"
                << "<path_to_input_image 2>" << std::endl;
 
}
 
int main( int argc, char** argv )
{
  /* get parameters from comand line */
  CommandLineParser parser( argc, argv, keys );
  String image_path1 = parser.get<String>0 );
  String image_path2 = parser.get<String>1 );
 
  if( image_path1.empty() || image_path2.empty() )
  {
        help();
        return -1;
  }
 
  /* load image */
  cv::Mat imageMat1 = imread( image_path1, 1 );
  cv::Mat imageMat2 = imread( image_path2, 1 );
 
  waitKey();
  if( imageMat1.data == NULL || imageMat2.data == NULL )
  {
        std::cout << "Error, images could not be loaded. Please, check their path" << std::endl;
  }
 
  /* create binary masks */
  cv::Mat mask1 = Mat::ones( imageMat1.size(), CV_8UC1 );
  cv::Mat mask2 = Mat::ones( imageMat2.size(), CV_8UC1 );
 
  /* create a pointer to a BinaryDescriptor object with default parameters */
  Ptr<BinaryDescriptor> bd = BinaryDescriptor::createBinaryDescriptor();
 
  /* compute lines */
  std::vector<KeyLine> keylines1, keylines2;
  bd->detect( imageMat1, keylines1, mask1 );
  bd->detect( imageMat2, keylines2, mask2 );
 
  /* compute descriptors */
  cv::Mat descr1, descr2;
  bd->compute( imageMat1, keylines1, descr1 );
  bd->compute( imageMat2, keylines2, descr2 );
 
  /* create a BinaryDescriptorMatcher object */
  Ptr<BinaryDescriptorMatcher> bdm = BinaryDescriptorMatcher::createBinaryDescriptorMatcher();
 
  /* require match */
  std::vector<DMatch> matches;
  bdm->match( descr1, descr2, matches );
 
  /* plot matches */
  cv::Mat outImg;
  std::vector<char> mask( matches.size(), 1 );
  drawLineMatches( imageMat1, keylines1, imageMat2, keylines2, matches, outImg, Scalar::all( -1 ), Scalar::all( -1 ), mask,
                       DrawLinesMatchesFlags::DEFAULT );
 
  imshow( "Matches", outImg );
  waitKey();
}
cs

<출처 : http://docs.opencv.org/3.0-beta/modules/line_descriptor/doc/tutorial.html>


이미지1에서 세그먼트된 각각의 라인들에 대한 best match를 이미지2에서 한개씩 찾는다.


opencv에서는 LBD descriptor을 binary descriptor로 바꾸어 매칭을 실시한다.



이 외에 radius match나 knn match를 이용하려면 아래와 같이 수정하면 된다.

1
2
3
4
5
6
7
8
9
10
11
/* prepare a structure to host matches */
std::vector<std::vector<DMatch> > matches;
 
/* require knn match */
bdm->knnMatch( descr1, descr2, matches, 6 );
 
/* prepare a structure to host matches */
std::vector<std::vector<DMatch> > matches;
 
/* compute matches */
bdm->radiusMatch( queries, matches, 30 );
cs
<출처 : http://docs.opencv.org/3.0-beta/modules/line_descriptor/doc/tutorial.html>

하지만 'matches' 벡터가 2d 벡터로 바뀌므로 image plot 부분의 코드 또한 수정이 필요하다.


1
2
3
4
5
std::vector<char> mask( vsize, 1 );
  for(int i = 0; i < matches.size(); i++){
    drawLineMatches( imageMat1, keylines1, imageMat2, keylines2, matches[i], outImg, 
    Scalar::all( -1 ), Scalar::all( -1 ), mask, DrawLinesMatchesFlags::DEFAULT );
  }
cs

위의 코드와 같이 match의 사이즈만큼 반복시켜주면 끝!


인 매칭이 필요한 이유

○ 기존의 매칭 방법의 대부분은 local points 혹은 region feature 기반.


○ 이러한 매칭 방법들은 텍스쳐가 낮은 장면에서 성능이 떨어지는 경향이 있음.

○ 하지만 이러한 장면들도 충분한 Line feature들을 포함 할 수 있음.



라인 매칭을 위한 3가지 방법

○ 각각의 Line에 대한 개별적인 매칭.

○ Line segment들의 그룹에 대한 매칭.

- 해당 방법의 경우는 대부분 작은 베이스라인을 가지는 스테레오 이미지 쌍을 위한 경우.

- 더 넓은 범위의 조건에서의 성능은 충분히 검증되지 않음.

○ Point correspondences를 이용한 라인 매칭.

- 텍스쳐가 낮은, 충분한 point feature가 없는 씬에서의 매칭을 위한 연구를 진행하므로 해당사항 없음.



Line detection for LBD

○ Scale space에서 라인을 검출.

○ 원본 이미지는 옥타브 이미지 세트를 생성하기 위해 다운샘플링.

○ 원본이미지의 동일한 영역에서 모든 옥타브에서 검출된 라인들만 LineVec로 이용.



Line Support Region 설정

○ Descriptor은 line support region (LSR)을 기반으로 계산됨.

○ LSR은 여러개의 band로 구성되며 band의 두께는 균일, 길이는 라인 세그먼트와 동일하며 평행함.



LBD의 구조

○ LBD는 단순한 BD(band descriptor)의 나열로 구성.


View the MathML source


○ BD(band descriptor)의 구조.

View the MathML sourceView the MathML source


○ BDBj로 부터 구한 평균 벡터 Mj와 표준 편차 벡터 Sj를 이용하여 LBD 구성.


View the MathML source





Reference

- An efficient and robust line segment matching approach based on LBD descriptor and pairwise geometric consistency.