Skip to content

dnn / python: cv2.dnn.NMSBoxes throws SystemError #12299

@berak

Description

@berak
  • OpenCV => 3.4.2
  • Operating System / Platform => Windows 64 Bit
  • Compiler => mingw

related: #12270

trying with code like:

#boxes = [(1,2,3,4),(2,1,3,4),(4,3,2,1)] # a list of tuples ?
boxes = np.array([[[1,2,3,4],[2,1,3,4],[4,3,2,1]]],np.int32) # a (2d) numpy array ?
conf = np.array([.6, .5, .2], np.float32)
indices = cv2.dnn.NMSBoxes(boxes, conf, .1, .1)
# expected: [0,2], but we get:

SystemError: <built-in function NMSBoxes> returned NULL without setting an error

generated code looks like this:

static PyObject* pyopencv_cv_dnn_NMSBoxes(PyObject* , PyObject* args, PyObject* kw)
{
    using namespace cv::dnn;

    PyObject* pyobj_bboxes = NULL;
    vector_Rect bboxes;
    PyObject* pyobj_scores = NULL;
    vector_float scores;
    float score_threshold=0.f;
    float nms_threshold=0.f;
    vector_int indices;
    float eta=1.f;
    int top_k=0;

    const char* keywords[] = { "bboxes", "scores", "score_threshold", "nms_threshold", "eta", "top_k", NULL };
    if( PyArg_ParseTupleAndKeywords(args, kw, "OOff|fi:NMSBoxes", (char**)keywords, &pyobj_bboxes, &pyobj_scores, &score_threshold, &nms_threshold, &eta, &top_k) &&
        pyopencv_to(pyobj_bboxes, bboxes, ArgInfo("bboxes", 0)) &&
        pyopencv_to(pyobj_scores, scores, ArgInfo("scores", 0)) )
    {
        ERRWRAP2(cv::dnn::NMSBoxes(bboxes, scores, score_threshold, nms_threshold, indices, eta, top_k));
        return pyopencv_from(indices);
    }

    return NULL;
}

so, either PyArg_ParseTupleAndKeywords or pyopencv_to must have failed here, and it fell through, returning NULL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions