Ask Your Question

pixelou's profile - activity

2016-04-09 10:57:58 -0600 asked a question How to generate python bindings for OpenCV based projects

Hello there,

There are many C++ projects out there that use OpenCV. On the other hand, it is very tempting to use the python interface of OpenCV, especially for experimentations. Unfortunately, it is rather difficult to write the bindings for the 3rd party libraries manually.

To simplify this task, I have extracted the header parsing utilities from the OpenCV source tree to make it standalone (available here, but it is not production ready).

Use cases are:

  • Your project uses the python bindings of OpenCV, but you need to use an external library in C++. You can write an parser-frendly wrapper for this library and have the python binding automatically generated.
  • Your project is written in C++ and you want to distribute an python binding.
  • Your project is written in python but you need to use optimzed C++ code. This code will be compiled into a python module which you can load back into your project.
  • [WIP] You wish to compile one module from OpenCV source tree (to test an update from the source tree for example) and generate the python bindings without messing up your OpenCV installation.
  • [WIP, useful?] You write a module that you want to propose for integration in the extra-modules of OpenCV, you want to test the associated python bindings or examples

So my question is: Do you think such a project is useful? How would you prefer to make your bindings?

2016-02-05 01:53:24 -0600 commented answer detectMultiscale fails when weights are requested

Thank you for taking care of this bug.

2016-02-05 01:52:35 -0600 received badge  Supporter (source)
2016-02-05 01:39:08 -0600 received badge  Enthusiast
2016-01-27 13:34:59 -0600 commented answer detectMultiscale fails when weights are requested

Thank you very much for your feedback. I am going to file a bug report then.

2016-01-27 09:10:37 -0600 received badge  Student (source)
2016-01-27 03:45:13 -0600 commented question detectMultiscale fails when weights are requested

Thank you for your feedback. Just for the sake of clarity: by revision I meant earlier commit of the 3.1.0 version, not older version.

2016-01-27 02:01:19 -0600 received badge  Editor (source)
2016-01-27 01:57:05 -0600 received badge  Organizer (source)
2016-01-25 01:49:54 -0600 commented question СascadeСlassifier. Get probability of true detection.

AFAIK, there is no probability of detection computed internaly because this is not how the algorithm works. You can however estimate an arbitrary detection score based on the reject level, the level weight is undocumented and I don't believe it can have a usable meaning across the levels.

Unfortunately, I could not retrieve the weights myself (see my question here).

2016-01-19 20:18:35 -0600 asked a question detectMultiscale fails when weights are requested

Hello,

When weights and rejection levels are requested, detectMultiscale always returns a square at the center of the image, regardless of the image.

Minimal working example: (the image I used is available here)

#include <iostream>
#include <string>
#include <vector>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

const string opencvDir = "/usr/share/opencv/haarcascades/";
const string WindowName = "Oscars";

int main() {
    CascadeClassifier faceCascade;
    if (!faceCascade.load(opencvDir + "/haarcascade_frontalface_alt2.xml")) {
        cerr << "failed to load cascade features" << endl;
        return -1;
    }

    Mat im = imread("oscar.jpg");
    Mat gray(im.cols, im.rows, CV_8U);
    cvtColor(im, gray, cv::COLOR_BGR2GRAY);

    double scaleFactor = 1.2;
    int minNeighbors = 2;
    int flags = 0;
    Size minSize = Size(50, 50);
    Size maxSize = Size(150, 150);
    bool outputRejectLevels = true;
    vector<Rect> objects;
    vector<int> rejectLevels;
    std::vector<double> levelWeights;

    // Broken version
    faceCascade.detectMultiScale(gray, objects, rejectLevels, levelWeights,
        scaleFactor, minNeighbors, flags,
        minSize, maxSize, outputRejectLevels);

    Mat preview = im.clone();
    for (Rect obj : objects)
            rectangle(preview, obj, Scalar(255, 0, 0));

    namedWindow(WindowName, WINDOW_AUTOSIZE);   
    imshow(WindowName, preview);
    waitKey(0);

    objects.clear();
    rejectLevels.clear();
    levelWeights.clear();

    // Working version
    faceCascade.detectMultiScale(gray, objects, scaleFactor, minNeighbors, 
        flags, minSize, maxSize);

    preview = im.clone();
    for (Rect obj : objects)
            rectangle(preview, obj, Scalar(255, 0, 0));
    namedWindow(WindowName, WINDOW_AUTOSIZE);   
    imshow(WindowName, preview);
    waitKey(0);

    return 0;    
}

The version of opencv I use is 3.1.0.r107.g1cd3c6f. It also failed with one of the earlier revisions. Could anyone just run the test above and confirm that there is indeed a bug?


EDIT: bug report opened here