Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调试断言失败_CrtIsValidHeapPointer(pUserData)C++&;Opencv 我是学C++的新手。我在运行代码时遇到了这个“调试断言失败”错误。我不知道我错在哪里,也不知道如何解决这个问题。我已经调试了这个程序_C++_Opencv - Fatal编程技术网

调试断言失败_CrtIsValidHeapPointer(pUserData)C++&;Opencv 我是学C++的新手。我在运行代码时遇到了这个“调试断言失败”错误。我不知道我错在哪里,也不知道如何解决这个问题。我已经调试了这个程序

调试断言失败_CrtIsValidHeapPointer(pUserData)C++&;Opencv 我是学C++的新手。我在运行代码时遇到了这个“调试断言失败”错误。我不知道我错在哪里,也不知道如何解决这个问题。我已经调试了这个程序,c++,opencv,C++,Opencv,调试断言失败_CrtIsValidHeapPointer(pUserData)C++&;Opencv 我是学C++的新手。我在运行代码时遇到了这个“调试断言失败”错误。我不知道我错在哪里,也不知道如何解决这个问题。我已经调试了这个程序,但是在程序结束之前它没有任何错误 int main() { Mat image; Mat output; Mat gray_prev; Mat gray; string imageName, outp

调试断言失败_CrtIsValidHeapPointer(pUserData)C++&;Opencv 我是学C++的新手。我在运行代码时遇到了这个“调试断言失败”错误。我不知道我错在哪里,也不知道如何解决这个问题。我已经调试了这个程序,但是在程序结束之前它没有任何错误

int main()
{
    Mat image;
    Mat output;
    Mat gray_prev;
    Mat gray;

    string imageName, outputName, rectName;
    cout << "please input the name of file:";
    getline(cin, imageName);
    cout << "please input the name of output:";
    getline(cin, outputName);
    cout << "please input the name of rectfile:";
    getline(cin, rectName);

    image = imread(imageName, CV_LOAD_IMAGE_COLOR);
    output = imread(outputName, CV_LOAD_IMAGE_COLOR);
    if(!image.empty() && !output.empty())
    {
        cvtColor(image, gray_prev, CV_BGR2GRAY);
        cvtColor(output, gray, CV_BGR2GRAY);
    }

    Rect rect1;
    Rect rect2;
    char cstring1[1000];
    char cstring2[1000];
    int x, y, w, h;

    fstream f;
    f.open(rectName, fstream::in);
    f.getline(cstring1, sizeof(cstring1));
    sscanf(cstring1, "%i,%i,%i,%i", &x, &y, &w, &h);
    rect1 = Rect(x, y, w, h);
    f.getline(cstring2, sizeof(cstring2));
    sscanf(cstring2, "%i,%i,%i,%i", &x, &y, &w, &h);
    rect2 = Rect(x, y, w, h);

    vector<vector<Point2f>> points1(2); //存储前后两帧特征点
    vector<vector<Point2f>> points2(2);
    vector<uchar> status;
    vector<float> err;

    //points[0].resize(rect1.width*rect1.height);
    //points[1].resize(rect2.width*rect2.height - rect1.width*rect1.height);
    for(int j=rect2.y; j<(rect2.y+rect2.height); j++){
        for(int i=rect2.x; i<(rect2.x+rect2.width); i++){   
            if( i>=rect1.x && i<=(rect1.x+rect1.width)
                && j>=rect1.y && j<=(rect1.y+rect1.height))
            {
                points1[0].push_back(Point2f(i, j));
            }
            else
            {
                points2[0].push_back(Point2f(i, j));
            }
        }
    }



    calcOpticalFlowPyrLK(
        gray_prev,
        gray,
        points1[0], 
        points1[1],
        status,
        err);

    calcOpticalFlowPyrLK(
        gray_prev, 
        gray,
        points2[0],
        points2[1],
        status,
        err);

    for(int i=0; i<points1[1].size(); i++)
    {
        circle(output, points1[1][i], 1, Scalar::all(0), (-1));
    }

    for(int i=0; i<points2[1].size(); i++)
    {
        circle(output, points2[1][i], 1, Scalar(255,0,0), (-1));
    }

    imshow("optimalflow", output);
    waitKey(0);

    f.close();

}
intmain()
{
Mat图像;
垫输出;
Mat gray_prev;
席灰色;
字符串imageName、outputName、rectName;

我无法调试此程序,但直到程序结束它才出现任何错误。--这是因为直到程序退出后才进行堆损坏检测。请删除对
calc..的最后两个调用。
并查看问题是否消失。如果消失,则是这两个调用之一导致问题。错误的库!请检查t您没有在版本中使用OpenCV调试库,或者使用viceversa。请确保OpenCV库是使用与您的项目相同的编译器、相同的体系结构(例如x86和x64)编译的