# Is there a way to extract the 4 corners points from all the points found with detectMinEigenFeatures?

4 ビュー (過去 30 日間)
Arseni Ivanov 2021 年 5 月 6 日

I am trying to make an Augmented Reality video feature using automatic detection after designating an area using 4 points with drawpolygon. I am getting a lot of matches, and I want to make a generic solution that can find the 4 corner points for the homography as marked in red below:
I have tried using max- and min-points, but this does not work for all camera angles as different directions might render the upper right corner as the minX instead of the upper left corner and so on.
edit; In particular, this breaks when seeing the checkerboard "straight on" as for example both minX goes to the same value as maxY and can occupy neighbouring detections.

サインインしてコメントする。

### 採用された回答

Matt J 2021 年 5 月 6 日
If you have a binary map of the chequerboard, you can use imerode to separate the black squares and then pgonCorners
to identify the corners of each.
##### 3 件のコメント表示非表示 2 件の古いコメント
Arseni Ivanov 2021 年 5 月 7 日
You are right it works, I just assumed that the first column of the output was x and not y, so by flipping my output it now works properly. I will edit the message as it was my fault. If anyone is interested in the code from the image above to the result posted by Matt J:
se = strel('disk',45);
T = imerode(imcomplement(imerode(imbinarize(rgb2gray(I),0.19),se)),se);
T = bwareafilt(T,1);
points = pgonCorners(T,4);
points = flip(xA,2);
Note that this is very slow due to probably unnecessary operations but it works. Also it's very adapted to my scene so anyone stumbling upon this might have to change the threshold, single structuring element and order of operations on the image.

サインインしてコメントする。

### その他の回答 (1 件)

Gatech AE 2021 年 5 月 6 日
I think an interesting way might be using the convex hull of your points. Running on the assumption that you have an Nx2 array of points,
x = Pts(:,1);
y = Pts(:,2);
k = convhull(x,y);
The variable k returns the indices of the points that form the perimeter sorted in counter-clockwise order. So for the corners,
corners = Pts(k,:);
##### 1 件のコメント表示非表示 なし
Arseni Ivanov 2021 年 5 月 6 日

Thank you for the suggestion, I think that this can be a very good solution if you have a better pattern. In my case, I get k ranging from size of 4 to 14 indexes depending on the frame as a lot of the points lie exactly on the edge due to the checkered pattern. Perhaps I can play around with these points and treat nearby points as a mean of the group.and see if this gives an alright approximation.
edit; I might be wrong though, and perhaps the extra points are a result of the image being uneven, creating a bigger hull

サインインしてコメントする。

### カテゴリ

Find more on Display Point Clouds in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by