Ask Your Question

JDS's profile - activity

2017-05-29 02:22:24 -0500 received badge  Notable Question (source)
2016-09-15 02:30:41 -0500 received badge  Popular Question (source)
2016-06-09 16:09:45 -0500 commented question Object recognition performance with ORB

What would be the rationale there, are there specific features of that algorithm that you think might perform better than ORB?

2016-06-09 10:28:04 -0500 commented question Object recognition performance with ORB

Even up close the performance isn't great, the bounding box generated by the homography rarely captures the object in the scene. But yes perhaps I'll need higher resolution for objects further away (currently only 320x240)

2016-06-08 11:11:23 -0500 received badge  Editor (source)
2016-06-08 10:42:07 -0500 asked a question Object recognition performance with ORB

I have a sample project where I am trying to recognize, and draw a box around, a circuit board. Ideally I want the result to be something close to this: https://www.youtube.com/watch?v=-ZNYo... I'm hoping that some people with more experience and intution can suggest changes to my algorithm and code to improve results.

I am using OpenCV with Python, and have been playing around with the ORB detector, which I understand is a free license vs. SIFT or SURF. Also it seems fairly efficient. However my code isn't working too well for matching. It runs fast in real-time, but below are some sample match attempts:

enter image description here

On the left is my (static) template, on the right is the real-time scene. I've taken a few screenshots that are indicative of my results: not that many matches, some mismatches, and it's never able to draw a nice bounding box around the object as my code would (hopefully) have it do. I've also tried taking more vertical/birds-eye pictures of the template, but with similarly poor results. Resolution for template and image are both 320x240.

enter image description here

Below I will paste my code. It uses the ORB recognizer as I mentioned. I am open to switching approaches/algorithms but I'd also like to understand why I could expect better performance if doing so. Thank you in advance for any help or advice, hopefully others will benefit as well.

def ORB_recognizer(detector, kp1, des1, img2):

    ms1=0;ms2=0;ms3=0;ms4=0;ms5=0;ms6=0;ms7=0;ms8=0 # I was profiling performance

    ms1 = time.time()*1000.0

    kp2, des2 = detector.detectAndCompute(img2,None)

    ms2 = time.time()*1000.0

    # create BFMatcher object
    bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
    # Second param is boolean variable, crossCheck which is false by default. If it is true, Matcher returns only those matches with value (i,j) such that i-th descriptor in set A has j-th descriptor in set B as the best match and vice-versa.
    # Match descriptors.

    ms3 = time.time()*1000.0

    matches = bf.match(des1,des2)

    ms4 = time.time()*1000.0

    # Sort them in the order of their distance.
    matches = sorted(matches, key = lambda x:x.distance)

    MIN_MATCH_COUNT = 10
    good = matches[:MIN_MATCH_COUNT]    

    #if len(good)>MIN_MATCH_COUNT:

    ms5 = time.time()*1000.0

    src_pts = np.float32([ kp1[m.queryIdx].pt for m in good ]).reshape(-1,1,2)
    dst_pts = np.float32([ kp2[m.trainIdx].pt for m in good ]).reshape(-1,1,2)

    M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
    matchesMask = mask.ravel().tolist()

    ms6 = time.time()*1000.0

    h,w,d = img1.shape
    pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
    dst = cv2.perspectiveTransform(pts,M)

    img2 = cv2.polylines(img2,[np.int32(dst)],True,255,3, cv2.LINE_AA)

    ms7 = time.time()*1000.0
    #else:
        #print "Not enough matches are found - %d/%d" % (len(good),MIN_MATCH_COUNT)
        #matchesMask = None




    draw_params = dict(matchColor = (0,255,0), # draw matches in green ...
(more)
2013-07-19 22:16:54 -0500 asked a question Windows 7 installation fail: 'Can not open file OpenCV...exe as archive'

Having a really tough time installing OpenCV on my Windows 7 64-bit machine. Yes I tried running as administrator; I also tried 7zip and WinRAR to extract. No dice.

I have downloaded OpenCV-2.4.4.exe, OpenCV-2.4.5.exe, OpenCV-2.4.6.0.exe, and now I'm trying OpenCV-2.3.0.exe =(

Help!!

2013-06-24 20:30:26 -0500 received badge  Supporter (source)
2013-06-24 20:29:51 -0500 commented answer Setting up a camera system to use with OpenCV

Thank you. Two quick q's: will VideoCapture cap(0); grab the camera stream of a generic webcam plugged in via USB - and cap(1) the second one then? And in your code, what is the purpose of sleeping for 10 milliseconds?

2013-06-24 14:54:57 -0500 asked a question Setting up a camera system to use with OpenCV

Hello,

Probably a dumb/basic question, apologies in advance.

I want to buy a standard webcam, say something like this: http://www.bestbuy.com/site/Logitech+-+HD+Webcam+C615/2588445.p;jsessionid=3665222F1C297C76927E29F770068174.bbolsp-app02-163?id=1218337862339&skuId=2588445

Then I want to connect it to my laptop and use OpenCV to analyze its video feed to run CV algorithms with. What do I need to do to get started with this task? Just the set-up so in my C++ code I have the video stream available to analyze. Is there some basic template code I could get started with?

Thanks!