This call can reallocate `labels` and `dst` Mats and caller will not get neither result nor error message.
The simplest way to forbid such reallocation is to declare these Mats as `const`:

    const cv::Mat dst = cv::cvarrToMat(dstarr);
    const cv::Mat labels = cv::cvarrToMat(labelsarr);

It will work because const Mats are getting `FIXED_TYPE+FIXED_SIZE` flag when converted to `OutputArray`