Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:01:30+00:00 2026-06-12T02:01:30+00:00

I have two images which I want to compare using python and opencv. I

  • 0

I have two images which I want to compare using python and opencv.

I understood how to extract surf features from a single images from this book: Programming Computer Vision with Python.

I extract the features as follows:

import cv2
from numpy import *

# read image
im = cv2.imread('empire.jpg')

# downsample
im_lowres = cv2.pyrDown(im)

# convert to grayscale
gray = cv2.cvtColor(im_lowres,cv2.COLOR_RGB2GRAY)

# detect feature points
s = cv2.SURF()
mask = uint8(ones(gray.shape))

keypoints = s.detect(gray,mask)

# show image and points
vis = cv2.cvtColor(gray,cv2.COLOR_GRAY2BGR)
for k in keypoints[::10]:
    cv2.circle(vis,(int(k.pt[0]),int(k.pt[1])),2,(0,255,0),-1)
    cv2.circle(vis,(int(k.pt[0]),int(k.pt[1])),int(k.size),(0,255,0),2)

cv2.imshow('local descriptors',vis)
cv2.waitKey()

Now how I can I compare keypoints with another sets of keypoints which comes from a reference image using?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:01:32+00:00Added an answer on June 12, 2026 at 2:01 am

    There is a FLANN implementation for Python OpenCV, I have used it myself and it works very well. Initially it wasn’t easy to figure out, but the this question helped me a lot, see Esteban Angee’s answer.

    You can also have a look at my answer to this question, where I quickly explained the code. I repeat the explanation here.

    r_threshold = 0.6
    FLANN_INDEX_KDTREE = 1  # bug: flann enums are missing
    

    Construct your parameters dictionary:

    flann_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 4)
    flann = cv2.flann_Index(desc2, flann_params)
    

    Perform nearest neighbours search:

    idx2, dist = flann.knnSearch(desc1, 2, params = {}) # bug: need to provide empty dict
    mask = dist[:,0] / dist[:,1] < r_threshold
    idx1 = np.arange(len(desc1))
    pairs = np.int32( zip(idx1, idx2[:,0]) )
    

    Returns the descriptors that matched:

    return pairs[mask]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two images which i would like to compare and do different operations
I have two images with which I am using in an anchor tag. I
In my application I have two images which are arranged in circle. I want
I have two images, both taken at the same time from the same detector.
I have a slideshow programed here that i want two images to be on
I have, as an example, the following two images: http://img571.imageshack.us/i/spain.jpg/ http://img97.imageshack.us/i/spainoverlay.png/ I want to
I have a program which plays two sounds. I want the user to know
I am trying to align two images horizontally using CSS. In CSS, I have:
Sheet1 Sheet2 Above i have two images link that i have captured from my
In a nutshell I have two images I want to overlay one over the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.