Ask Your Question

danceToBebop's profile - activity

2016-07-22 08:11:50 -0600 asked a question BFmatcher crashes because of different descriptor shapes

Hey everyone,

I'm using binary images of the same size, extracting ORB Features but when it comes to compare the descriptors I receive an:

The Error

OpenCV/opencv/modules/core/src/stat.cpp:3757: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function batchDistance

However when I check the descriptors with

print img.dtype, np.shape(img), np.shape(descriptors)
print oldimg.dtype, np.shape(oldimg), np.shape(olddescriptors)

I get

uint8 (21, 27) (22, 32)
uint8 (21, 27) (17, 32)

Apparently this seems to be the error. On the other hand there's not much I can do against it. Has anybody an idea? At least is there some kind of tutorial online, of how to manually match the descriptors ?

Btw it is the same if I use SIFT, SURF, etc.

Here's my code:

I'm working with python 2.7 and OpenCV 2.4

    orb = cv2.ORB_create(edgeThreshold=3)
    oldkeypoints, olddescriptors = orb.detectAndCompute(oldimg,None)
    keypoints, descriptors = orb.detectAndCompute(img,None) 

    bf = cv2.BFMatcher(cv2.NORM_HAMMING)
    bf.clear()
    bf.add(olddescriptors)
    bf.train()

    matches = bf.match(descriptors) # crashes here
    matches = sorted(matches, key = lambda x:x.distance)
2016-07-21 11:05:30 -0600 received badge  Self-Learner (source)
2016-07-21 10:15:45 -0600 received badge  Scholar (source)
2016-07-21 10:15:40 -0600 received badge  Editor (source)
2016-07-21 10:05:29 -0600 answered a question How to set up a "side-OpenCV" / set path to another opencv

I was able to figure out a solution that works. An option is working with sys.path, there is apparently another one with $PYTHONPATH but that didn't run on my system - I short guess would be, that here a library is just appended to the path and if one already has a working library of this kind in its path, the first one - in this case the deprecated opencv is chosen.

However working with sys.path lets you put the library at any desired position. To make it short:

import sys
sys.path.insert(0,'<path-to-better-lib>')
import cv2

the number stands for the position in the path-string: 0 means put on very first place so the later cv2.so will just be ignored.

example for <'path-to-better-lib'> : ~/newOpencv/lib/python2.7/dist-packages, that's where the cv2.so resides, which represents opencv

N.B.: of course this will work with other libraries too, just replace import cv2 respectively. That's how to deal with multiple versions of any (not just cv) libs installed on one workstation in python

2016-07-20 12:42:20 -0600 commented question How to set up a "side-OpenCV" / set path to another opencv

I have the answer but I have to wait 1 more day due this community, so this case is closed thanks for your time

2016-07-20 12:27:08 -0600 received badge  Critic (source)
2016-07-19 11:04:34 -0600 commented answer How to set up a "side-OpenCV" / set path to another opencv

The library was build again, but still system-wide the depricated version is used. That comes back to my question, how can I change that path, to look for the recent one ?

2016-07-19 10:33:31 -0600 commented question How to set up a "side-OpenCV" / set path to another opencv

will this e.g. prevent python to use the deprecated and force it to use my version ?

2016-07-19 10:26:53 -0600 asked a question How to set up a "side-OpenCV" / set path to another opencv

Hey everyone,

I'm working on a station without sudo rights. Installed is a OpenCV V. 2.3.x. Now for my needs this isn't sufficient. However I was able to download and compile the latest Version

make aswell as make install

worked out fine, but of the last step. Moving the installed libs to /usr/local/include/opencv2 because of the missing rights.

So since it's now just a matter of setting the path to the library, how can I do this, that system-wide the recently installed version is only used and the other ignored ?

Thanks for your help

Kind Regards