New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matching two Meshes #103
Comments
I'm not sure what In any case these examples might be useful for you:
You can use |
Yes Sir, So I have two meshes I should show them in front each other, like in the image attached before, as well as I mentioned in the mean question, Hopefully, my ideas get clearer! In fact, the links you gave me regarding aligning, it doesn't benefit me, and regarding measuring distances I also believe no need for it, I'm trying to obtain Euclidean distance in order to obtain the match giving example would be like this:
Where here we have first one is the coordinates(or we can get it as index) from mesh |
Try: from vtkplotter import *
import numpy as np
a = load(datadir+'man.vtk')
a_ip = list(range(0, 20)) # pick some point indices
a_pts = a.points()[a_ip] # 3d coords of those points
b = a.clone().pos(1,0.2,0).c('violet')
b_ip = list(range(1000,1020))
b_pts = b.points()[b_ip]
lns = Lines(a_pts, b_pts, lw=2)
scal = mag(b_pts - a_pts) # length of line as color
lns.cellColors(scal, cmap='jet')
lns.addScalarBar(title='distance')
show(a,b, lns, axes=1) |
Dear Sir,
method two:(Favorable)
can I get guidance for visualizing meshes with there key points and the matching depending on this,
in addition to this, later on, there might be choosing different colors if this is a correct match or not. |
Hi, I'm afraid i'm not familiar with neither cv2 nor flann. If you already have the matching points as coordinates or indices between meshes |
Hello Again,
so it didn't show separately!! like your visualizing? as well how to ensure that rpts1 showed on mesh2, not on mesh1? Here is my case, I have 2 matching points! and if I try the same object it gives full matching, but in visualization, nothing is shown (lines), what I'm doing wrong, please? |
You are shifting the second mesh inside the from vtkplotter import *
mesh1 = load(datadir+'apple.ply').alpha(0.2)
mesh2 = load(datadir+'apple.ply').x(3).c('v').alpha(0.2)
pts1, pts2 = mesh1.points(), mesh2.points()
matches1 = [ 0,100,200]
matches2 = [300,400,500]
lns = Lines(pts1[matches1], pts2[matches2], lw=4)
scal = mag(pts1[matches1] - pts2[matches2])
lns.cellColors(scal, cmap='viridis').addScalarBar(title='distance')
rpts1 = Points(pts1[matches1], r=10, c='white')
rpts2 = Points(pts2[matches2], r=10, c='blue')
show(mesh1, mesh2, lns, rpts1, rpts2, axes=1)
screenshot('a.png')
|
Dear Sir,
What about if I have for the two meshes two sets good, and bad
|
from vedo import *
import numpy as np
mesh1 = load(datadir+'apple.ply').alpha(0.2)
mesh2 = mesh1.clone().x(3).c('v')
pts1, pts2 = mesh1.points(), mesh2.points()
good_matches = [ 0,100,200]
bad_matches = [300,400,500]
good_lns = Lines(pts1[good_matches], pts2[good_matches], lw=3, c='g')
bad_lns = Lines(pts1[bad_matches], pts2[bad_matches], lw=4, c='r')
show(mesh1, mesh2, good_lns, bad_lns, axes=1)#.screenshot('a.png')
########################## find index from coordinate
#print(pts1[good_matches])
pp = [[ 1.03942804e-01, 1.83283873e-02, -9.15606380e-01],
[ 0, -3.48307818e-01, -9.15e-01],
[-6.23666346e-01, -1.09974377e-01, -9.41993356e-01]]
def find_index(array, p):
array = np.asarray(array)
if not utils.isSequence(p): p = [p]
idxs = [np.sum((array-q)**2, axis=1).argmin() for q in p]
return idxs
print(find_index(pts1, pp)) |
Sorry, I'm re-opening this issue, My code is as follows:
|
I cannot detect any mistake in the above code, I suggest you double check the indices you use to select array slices. |
So I tried on simpler models, the previous lines were taken dependable on files, now I only tried on two models, as in the picture, it is shown on the tails there are no matches! the code for this result is directly like this:
|
I have no way to reproduce your plot - and it's not clear what you are expecting to see "on the tails". Make sure you have the latest version of the code: then check what indices/points correspond to in arrays |
So I did what you said, What I'm expecting on tails is finding lines between the points there! I mean assuming I have 30 key points which are visualized on each dolphin! there's 22 good, and 8 bad Did you get my point? And regarding the indices I didn't find any problem with them, I even replace NumPy and use this:
|
No, I don't get your point, that's very confused. You should find a reproducible example otherwise I don't know how to help. |
Please could you clarify what you mean by reproducible example?
All the problem is:
The keypoints that I extracted and show them on the model should be linked with lines from the first model to the second, while this is not appearing! Like in the tail of the dolphin, there are keypoint that appears but don’t have links with that on the other dolphin?
…Sent from my iPhone
On 15/10/2020, at 10:28 PM, Marco Musy ***@***.***> wrote:
No, I don't get your point, that's very confused.
You should find a reproducible example otherwise I don't know how to help.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
well it's very hard to see anything about the links between the two dolphins. reproducible example means something I can run which exhibits and unexpected or undesired behavior. |
Sorry for reaching again, although I wasn't able to configure how I may make a reproducible example, but the idea despite dolphin or any model I'm trying to match. That's my point! Thank you |
You need to learn how to debug your code! |
Hello,
Where I would like to visualize each vertex of the first column different than the others, Thank you for your support. |
you can extract the coordinates with import numpy as np
mylist=[[ 0, 1, 165, 178, 191, 239, 238, 254, 255, 240],
[ 10, 9, 11, 168, 180, 193, 243, 242, 256, 127]]
mylist = np.array(mylist)
mycenters = np.array(mylist)[:,0]
myneigh = np.delete(np.array(mylist), 0, 1).ravel()
print(mycenters)
print(myneigh)
# coords:
print(mymesh.points()[mycenters])
print(mymesh.points()[myneigh]) (please understand that I only have time resources for helping with |
Previously and upon you assist me in this: #83 (comment)
now what I have to ask, if I have two meshes, and I need to make matching between them, we already have interest points, and from these points, and after applying few strategies, I got matching between meshes,
So now, instead of having:
a = [1,4,7,2,9,10,50,33,25]
I got a new array having for example:
b = [1,50,33,25]
and this the common points between the two meshesMy question would it be possible to show the two meshes, showing the main interest points, as well make lines that refer to matching depending on b
like the image obtained by someone, and the color of the line will be later, depending on whether this match is correct or not.
Would it be possible to do this using this library, please?
The text was updated successfully, but these errors were encountered: