Ask Your Question

Bob Woodley's profile - activity

2017-04-06 04:36:35 -0600 received badge  Student (source)
2016-01-18 22:28:18 -0600 asked a question Is Feature Detection Feasible on Android?

I'm getting poor results using a variety of Feature Detection Algos on Android. I cannot use SURF, SIFT, or BRISK because they are too slow (I'm using a Samsung Galaxy S5). So I've worked with ORB Detector/Orb Extractor, as well as with Orb Detector/FREAK extractor, both of which perform in real-time. However they aren't very good at finding my original training object in any scene with even small amounts of clutter.

I filter by Hamming distance. I apply cross-check and ratio test. I apply KNN. I use various combinations of these. I can't get a clear signal out of the noise. This photo below probably indicates the highest quality feature matching I can get, and there are many points that are not correct. The high number of errors would prevent an algo from confidentally identifying the object.

image description

Is it possible to get a higher quality result?

Possibly my code is wrong, so here are the key lines of code, extracted from a larger class. In this example I'm using ORB Feature Detector and Descriptor Extractor with BF HAMMINGLUT matcher, and a simple distance filter.

DescriptorExtractor descriptorExtractor;
DescriptorMatcher _matcher;
FeatureDetector _detector;

Mat _descriptors;
MatOfKeyPoint _keypoints;

Mat _descriptors2;
MatOfKeyPoint _keypoints2;

private Mat trainFeatureDetector(CvCameraViewFrame inputFrame) {
    Mat gray1 = inputFrame.gray();

    _descriptors = new Mat();
    _keypoints = new MatOfKeyPoint();

    _detector = FeatureDetector.create(FeatureDetector.ORB);
    _matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMINGLUT);
    _detector.detect(gray1, _keypoints, _descriptors);

    descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
    descriptorExtractor.compute(gray1, _keypoints, _descriptors);
}
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
    Mat gray2 = inputFrame.gray();
    _descriptors2 = new Mat();
    _keypoints2 = new MatOfKeyPoint();

    _detector.detect(gray2, _keypoints2);
    descriptorExtractor.compute(gray2, _keypoints2, _descriptors2);

    MatOfDMatch matches12 = new MatOfDMatch();
    _matcher.match(_descriptors, _descriptors2, matches12);
    List<DMatch> matches12_list = matches12.toList();

    // .... filter based on distance... 
    //-- Quick calculation of min distances between keypoints
    double min_dist = 0;
    for (int i = 0; i < matches12_list.size(); i++) {
        double dist = matches12_list.get(i).distance;
        if (dist < min_dist) min_dist = dist;
    }

    //-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
    List<DMatch> good_matches_list = new ArrayList<>();
    for (int i = 0; i < matches12_list.size(); i++) {
        if (matches12_list.get(i).distance < 3 * min_dist) {
            good_matches_list.add(matches12_list.get(i));
        }
    }

    drawMatches(gray2, _keypoints2, good_matches_list, (double) gray2.height(), (double) gray2.width());
}
2015-11-27 10:51:36 -0600 commented answer Android Memory leak on camera rotation

Thanks for the explanation and the solution.

2015-11-27 00:57:57 -0600 asked a question Android Memory leak on camera rotation

I have an app that needs to run in portrait mode and I want to have a small camera preview displayed on the screen. Opencv defaults to landscape for preview. The following code rotates it back to portrait:

 public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    mRgba = inputFrame.rgba();

    Mat tempMat = mRgba.t();
    Core.flip(tempMat, mRgbaT, 1);
    Imgproc.resize(mRgbaT, dst, mRgba.size());
    return dst;
}

The problem is that this code leaks memory and crashes after 10 or 15 seconds. I have tried various permutations of using release and using temporary matrices. It always seems to crash on the resize() function so I suppose that is where the leak is.

For the above example these are the declarations:

private Mat mRgba;
private Mat mRgbaT;
private Mat dst;

initialized in onCameraViewStarted():

public void onCameraViewStarted(int width, int height) {
    mRgbaT = new Mat();
    dst = new Mat();
}

I need help managing the memory correctly. I'd also like to understand what the problem is. Since Java is garbage collected it feels mighty strange to be required to call release().

2014-12-26 14:34:52 -0600 received badge  Popular Question (source)
2012-08-01 08:33:26 -0600 received badge  Scholar (source)
2012-07-30 22:54:47 -0600 asked a question Unhandled exception: facerecognizer vs2010 windows 7 x64.

I have built a debug x64 VS2010 project containing the facerec_demo.cpp class from the samples directory. I am use the ATT database with the supplied csv file from the samples directory.

I am using OpenCV2.4.2. Downloaded 4 days ago.

I get: Unhandled exception at 0x000007fef18e26bb in FaceRecon.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff

at this line:

int predictedLabel = model->predict(testSample);

Any ideas? Has this been tested on 64 bit debug mode?

Thanks!