OpenCV错误:void cv :: setSize中的断言失败(s> = 0)(cv :: Mat&,int,int const *,const size_t *,bool)

时间:2015-04-16 07:07:59

标签: c++ opencv

我是opencv库的新手。我正在尝试使用openCv拼接图像,同时运行它在void cv :: setSize中给出异常“断言失败(s> = 0)”。请帮我。这是我的代码..

JNIEXPORT void JNICALL Java_com_example_imagejoiner_MyJoiner_stitchImages(
        JNIEnv* env, jobject javaThis, jobjectArray jfilePaths,
        jstring jfinalImagePath) {

vector<Mat> imgs;
imgs.clear();

Mat imgMat;

bool try_use_gpu = false;

const int imageCount = env->GetArrayLength(jfilePaths);

for (int i = 0; i < imageCount; i++) {

    jstring filePath = (jstring) env->GetObjectArrayElement(jfilePaths, i);

    const char *rawString = env->GetStringUTFChars(filePath, 0);

    LOGV("RESULT = %s", rawString);

    imgMat = imread(rawString);

    if (!imgMat.empty()) {
        LOGV("Mat added.....");
        LOGV("RESULT = %d", i);
        imgs.push_back(imgMat);
    }

}

imgMat.release();

const char *finalImagePath = env->GetStringUTFChars(jfinalImagePath, 0);

LOGV("RESULT = %s", finalImagePath);

Mat pano;

Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = stitcher.stitch(imgs, pano);

imgs.clear();

LOGV("RESULT = %s", "done mat.....");

imwrite(finalImagePath, pano);

LOGV("RESULT = %s", "done writing.....");

pano.release();
}

0 个答案:

没有答案