Comments (8)
https://github.com/ducha-aiki/affnet/blob/master/examples/hesaffnet/WBS%20demo.ipynb
does the same, except the last part of your code, which you should add yourself:
# Find homography
h, mask = cv2.findHomography(points1, points2, cv2.RANSAC)
# Use homography
height, width, channels = im2.shape
im1Reg = cv2.warpPerspective(im1, h, (width, height))
from affnet.
Thanks for showing the the direction.
But I need some help in converting LAFs into cv2.Keypoints vectors or points to find the homography to map the image.
In the LAF.py I found
def LAF2pts(LAF, n_pts = 50):
a = np.linspace(0, 2*np.pi, n_pts);
x = [0]
x.extend(list(np.sin(a)))
x = np.array(x).reshape(1,-1)
y = [0]
y.extend(list(np.cos(a)))
y = np.array(y).reshape(1,-1)
HLAF = np.concatenate([LAF, np.array([0,0,1]).reshape(1,3)])
H_pts =np.concatenate([x,y,np.ones(x.shape)])
H_pts_out = np.transpose(np.matmul(HLAF, H_pts))
H_pts_out[:,0] = H_pts_out[:,0] / H_pts_out[:, 2]
H_pts_out[:,1] = H_pts_out[:,1] / H_pts_out[:, 2]
return H_pts_out[:,0:2]```
from affnet.
Thanks for showing the direction
but I also need to convert LAFs to cv2.Keypoints format or points to get the homography of the image,
I found LAF.py
def LAF2pts(LAF, n_pts = 50):
a = np.linspace(0, 2*np.pi, n_pts);
x = [0]
x.extend(list(np.sin(a)))
x = np.array(x).reshape(1,-1)
y = [0]
y.extend(list(np.cos(a)))
y = np.array(y).reshape(1,-1)
HLAF = np.concatenate([LAF, np.array([0,0,1]).reshape(1,3)])
H_pts =np.concatenate([x,y,np.ones(x.shape)])
H_pts_out = np.transpose(np.matmul(HLAF, H_pts))
H_pts_out[:,0] = H_pts_out[:,0] / H_pts_out[:, 2]
H_pts_out[:,1] = H_pts_out[:,1] / H_pts_out[:, 2]
return H_pts_out[:,0:2]
from affnet.
I used the following methode of getting the Keypoints from Local Affine Features (LAFs)
keypoints1 = list(map(lambda x:cv2.KeyPoint(x=x[0],y=x[1], _size = 2),LAFs1.numpy()[:,:,2]))
keypoints2 = list(map(lambda x:cv2.KeyPoint(x=x[0],y=x[1], _size = 2),LAFs2.numpy()[:,:,2]))
# Draw top matches
imMatches = cv2.drawMatches(im1,keypoints1, im2,keypoints2 , matches, None)
cv2.imwrite("matches.jpg", imMatches)
#cv2_imshow(imMatches)
# Extract location of good matches
points1 = np.zeros((len(matches), 2), dtype=np.float32)
points2 = np.zeros((len(matches), 2), dtype=np.float32)
for i, match in enumerate(matches):
points1[i, :] = keypoints1[match.queryIdx].pt
points2[i, :] = keypoints2[match.trainIdx].pt
# Find homography
h, mask = cv2.findHomography(points1, points2, cv2.RANSAC)
print(img2.shape)
# Use homography
height, width, channels = im2.shape
im1Reg = cv2.warpPerspective(im2, h, (width, height))
Although the matches are good but it doesn't warps the image as expected.
I am getting better warping using ORB/SIFT from opencv itself.
Is there something wrong in this implementation ?
from affnet.
Considering the fact that the view point difference is lesser than 10 degrees
from affnet.
Well, for viewpoint difference < 10 degrees you don`t need HardNet or AffNet, it would be overkill.
How many matches and detections do you get with opencv SIFT and with this repo? It might be the issue of detector threshold.
Could you also post the warped images from all methods?
from affnet.
After playing around with the thresholds and number of matches, I am getting the following results.
Input Images:
1st image -
2nd image
Results
After warping the output using the affnet model
After warping the output using the SIFT model
After warping the output using the ORB model
from affnet.
I don`t see any huge difference actually. What is your final goal?
from affnet.
Related Issues (20)
- nmsed_resp HOT 6
- Exact_Pacthes HOT 8
- Comparison to vl_covdet() HOT 1
- AffNetFastFullAff architecture missing HOT 2
- Is the experiments of Oxford Dataset retrieval task using BoW available? HOT 3
- Does the hardnet part need to retrain after affnet part finished? HOT 6
- Question about evaluating the model on roxford dataset HOT 11
- why the validation of handcrafted Baumberg Iteration runs without orientation HOT 2
- Some suggestions for the people to visit HOT 3
- About AffNet training(Fig.5) HOT 2
- About train_OriNet_test_on_graffity.py HOT 1
- RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation
- About the version of the python and pytorch HOT 2
- How to get feature's scale and orientation HOT 7
- get keypoints HOT 1
- RuntimeError: [enforce fail at CPUAllocator.cpp:47] HOT 4
- How to get
- How to get the A matrixs which satisfies the Geometric constraints condition EP=-AEP? HOT 7
- About the AFFNET HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from affnet.