How to detect the specific coordinate points from array of points given by corner detection?
I have an image of a person head from which I detected the corner points. Here are my code and result from it:
import cv2
import numpy as np
Head = cv2.imread('Head.jpg')
#Corner detection
gray = cv2.cvtColor(Head, cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
corners = cv2.goodFeaturesToTrack(gray, 50, 0.01, 10)
corners = np.int0(corners)
for corner in corners:
x,y = corner.ravel()
cv2.circle(Head, (x,y), 3, 255, -1)
z = np.max(y)
cv2.circle(Head, (x,z), 5, (0,0,255), -1)
cv2.imshow('Corner', Head)
cv2.waitKey(0)
cv2.destroyAllWindows()
Head Image:
Corner Detected:
Here, I am trying to point out only two corners in neck area(Lowest ones in above image). For that, I find out the max y from numpy array of corners and plot the point in red point. But, its plotting red point in eye. What I am doing wrong?
How do I find out the coordinate points of neck(lowest 2 corner points only)??
python numpy opencv image-processing
add a comment |
I have an image of a person head from which I detected the corner points. Here are my code and result from it:
import cv2
import numpy as np
Head = cv2.imread('Head.jpg')
#Corner detection
gray = cv2.cvtColor(Head, cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
corners = cv2.goodFeaturesToTrack(gray, 50, 0.01, 10)
corners = np.int0(corners)
for corner in corners:
x,y = corner.ravel()
cv2.circle(Head, (x,y), 3, 255, -1)
z = np.max(y)
cv2.circle(Head, (x,z), 5, (0,0,255), -1)
cv2.imshow('Corner', Head)
cv2.waitKey(0)
cv2.destroyAllWindows()
Head Image:
Corner Detected:
Here, I am trying to point out only two corners in neck area(Lowest ones in above image). For that, I find out the max y from numpy array of corners and plot the point in red point. But, its plotting red point in eye. What I am doing wrong?
How do I find out the coordinate points of neck(lowest 2 corner points only)??
python numpy opencv image-processing
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
I'm referring tocorners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14
add a comment |
I have an image of a person head from which I detected the corner points. Here are my code and result from it:
import cv2
import numpy as np
Head = cv2.imread('Head.jpg')
#Corner detection
gray = cv2.cvtColor(Head, cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
corners = cv2.goodFeaturesToTrack(gray, 50, 0.01, 10)
corners = np.int0(corners)
for corner in corners:
x,y = corner.ravel()
cv2.circle(Head, (x,y), 3, 255, -1)
z = np.max(y)
cv2.circle(Head, (x,z), 5, (0,0,255), -1)
cv2.imshow('Corner', Head)
cv2.waitKey(0)
cv2.destroyAllWindows()
Head Image:
Corner Detected:
Here, I am trying to point out only two corners in neck area(Lowest ones in above image). For that, I find out the max y from numpy array of corners and plot the point in red point. But, its plotting red point in eye. What I am doing wrong?
How do I find out the coordinate points of neck(lowest 2 corner points only)??
python numpy opencv image-processing
I have an image of a person head from which I detected the corner points. Here are my code and result from it:
import cv2
import numpy as np
Head = cv2.imread('Head.jpg')
#Corner detection
gray = cv2.cvtColor(Head, cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
corners = cv2.goodFeaturesToTrack(gray, 50, 0.01, 10)
corners = np.int0(corners)
for corner in corners:
x,y = corner.ravel()
cv2.circle(Head, (x,y), 3, 255, -1)
z = np.max(y)
cv2.circle(Head, (x,z), 5, (0,0,255), -1)
cv2.imshow('Corner', Head)
cv2.waitKey(0)
cv2.destroyAllWindows()
Head Image:
Corner Detected:
Here, I am trying to point out only two corners in neck area(Lowest ones in above image). For that, I find out the max y from numpy array of corners and plot the point in red point. But, its plotting red point in eye. What I am doing wrong?
How do I find out the coordinate points of neck(lowest 2 corner points only)??
python numpy opencv image-processing
python numpy opencv image-processing
asked Jan 3 at 10:17
Gkisi27Gkisi27
677
677
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
I'm referring tocorners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14
add a comment |
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
I'm referring tocorners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
I'm referring to
corners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14
I'm referring to
corners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14
add a comment |
1 Answer
1
active
oldest
votes
The issue is in this line:
z = np.max(y)
Here the value of y will just be the value of the last corner looked at in the previous loop. What you can do is to create a list of all the coordinate of the corners, and then order the list based on the y value:
ordered_coords = [ corner.ravel() for corner in corners ]
ordered_coords.sort(key=lambda x: x[1])
The two corners you're looking for with the highest y value will then be the last two elements in the list.
cv2.circle(Head, ordered_coords[-1], 5, (0,0,255), -1)
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020260%2fhow-to-detect-the-specific-coordinate-points-from-array-of-points-given-by-corne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue is in this line:
z = np.max(y)
Here the value of y will just be the value of the last corner looked at in the previous loop. What you can do is to create a list of all the coordinate of the corners, and then order the list based on the y value:
ordered_coords = [ corner.ravel() for corner in corners ]
ordered_coords.sort(key=lambda x: x[1])
The two corners you're looking for with the highest y value will then be the last two elements in the list.
cv2.circle(Head, ordered_coords[-1], 5, (0,0,255), -1)
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
add a comment |
The issue is in this line:
z = np.max(y)
Here the value of y will just be the value of the last corner looked at in the previous loop. What you can do is to create a list of all the coordinate of the corners, and then order the list based on the y value:
ordered_coords = [ corner.ravel() for corner in corners ]
ordered_coords.sort(key=lambda x: x[1])
The two corners you're looking for with the highest y value will then be the last two elements in the list.
cv2.circle(Head, ordered_coords[-1], 5, (0,0,255), -1)
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
add a comment |
The issue is in this line:
z = np.max(y)
Here the value of y will just be the value of the last corner looked at in the previous loop. What you can do is to create a list of all the coordinate of the corners, and then order the list based on the y value:
ordered_coords = [ corner.ravel() for corner in corners ]
ordered_coords.sort(key=lambda x: x[1])
The two corners you're looking for with the highest y value will then be the last two elements in the list.
cv2.circle(Head, ordered_coords[-1], 5, (0,0,255), -1)
The issue is in this line:
z = np.max(y)
Here the value of y will just be the value of the last corner looked at in the previous loop. What you can do is to create a list of all the coordinate of the corners, and then order the list based on the y value:
ordered_coords = [ corner.ravel() for corner in corners ]
ordered_coords.sort(key=lambda x: x[1])
The two corners you're looking for with the highest y value will then be the last two elements in the list.
cv2.circle(Head, ordered_coords[-1], 5, (0,0,255), -1)
edited Jan 3 at 14:09
answered Jan 3 at 12:32
westgarthwwestgarthw
16115
16115
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
add a comment |
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
You're going to need to keep track of the corresponding x-coordinate
– Mad Physicist
Jan 3 at 12:39
That is 100% true :p
– westgarthw
Jan 3 at 12:41
That is 100% true :p
– westgarthw
Jan 3 at 12:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020260%2fhow-to-detect-the-specific-coordinate-points-from-array-of-points-given-by-corne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What is the shape and dtype of corners?
– Mad Physicist
Jan 3 at 12:40
What do you mean by shape of corners? If your are refering to image.shape, its 522 by 522. Dtype is unit8.
– Gkisi27
Jan 4 at 9:09
I'm referring to
corners = np.int0(corners)
– Mad Physicist
Jan 4 at 9:14