在opencv中解构Mat_ <int64>失败</int64>

时间:2014-03-12 01:31:00

标签: c++ visual-studio-2010 opencv mat

我的程序在我的32位Windows上崩溃了。当函数返回时,VS2010给出了一个错误:

  

Windows已在mat_test.exe中触发断点。这可能是由于堆损坏,这表示mat_test.exe或其加载的任何DLL中存在错误。这也可能是由于用户按下了F12而mat_test.exe具有焦点。输出窗口可能包含更多诊断信息。

如果我将INT64更改为signed int,它运行良好。这与opencv有关吗? opencv&#39; s Mat_是否支持INT64数据类型?

#include <opencv.hpp>
#include <stdio.h>

using namespace cv;
using namespace std;

typedef signed __int64 INT64;
typedef unsigned char byte;


Mat imgcpy(Mat &ori_image);
Mat imgcpy(Mat &ori_image){
    Mat img;
    Mat_<float> img_;

    Mat img_copy;
    img_copy.create(8,8,CV_8U);
    for(int i=0;i<8;i++)
        for(int j=0;j<8;j++)
            img_copy.at<byte>(i,j)=1;
    cout<<img_copy<<endl;



    const Size sz(9,9);
    Mat_<float> scores(sz,0);
    Mat_<INT64> Tig1 = Mat_<INT64>::zeros(sz), Tig2 = Mat_<INT64>::zeros(sz);
    Mat_<INT64> Tig4 = Mat_<INT64>::zeros(sz), Tig8 = Mat_<INT64>::zeros(sz);
    Mat_<byte> Row1 = Mat_<byte>::zeros(sz),Row2 = Mat_<byte>::zeros(sz);
    Mat_<byte> Row4 = Mat_<byte>::zeros(sz),Row8 = Mat_<byte>::zeros(sz);
    //cout << Tig1 << endl << endl;
    for (int y=1;y<=8;y++)
    {
        //byte* G = img_copy.ptr<byte>(y-1);
        INT64* T1 = Tig1.ptr<INT64>(y); // Binary TIG of current row
        INT64* T2 = Tig2.ptr<INT64>(y);
        INT64* T4 = Tig4.ptr<INT64>(y);
        INT64* T8 = Tig8.ptr<INT64>(y);
        INT64* Tu1 = Tig1.ptr<INT64>(y-1); // Binary TIG of upper row
        INT64* Tu2 = Tig2.ptr<INT64>(y-1);
        INT64* Tu4 = Tig4.ptr<INT64>(y-1);
        INT64* Tu8 = Tig8.ptr<INT64>(y-1);
        byte* R1 = Row1.ptr<byte>(y);
        byte* R2 = Row2.ptr<byte>(y);
        byte* R4 = Row4.ptr<byte>(y);
        byte* R8 = Row8.ptr<byte>(y);
        float *s = scores.ptr<float>(y);
        for (int x=1;x<=8;x++)
        {
            //cout<<G[x-1];
            //byte g = 1;//G[x-1];
            //R1[x] = (R1[x-1] << 1) | ((g >> 4) & 1);
            //R2[x] = (R2[x-1] << 1) | ((g >> 5) & 1);
            //R4[x] = (R4[x-1] << 1) | ((g >> 6) & 1);
            //R8[x] = (R8[x-1] << 1) | ((g >> 7) & 1);
            T1[x] = (Tu1[x] << 8) | R1[x];
            T2[x] = (Tu2[x] << 8) | R2[x];
            T4[x] = (Tu4[x] << 8) | R4[x];
            T8[x] = (Tu8[x] << 8) | R8[x];
            //cout<<Tig1<<endl<<"\n";
            //cout<<Tig2<<endl<<"\n";
            //cout<<Tig4<<endl<<"\n";
            //cout<<Tig8<<endl<<"\n";
            //cout<<Row1<<endl<<"\n";
            //cout<<Row2<<endl<<"\n";
            //cout<<Row4<<endl<<"\n";
            //cout<<Row8<<endl<<"\n";
            //s[x] = dot(T1[x], T2[x], T4[x], T8[x]);
            //T1[x]=1;
            //T2[x]=1;
            //T4[x]=1;
            //T8[x]=1;
            s[x]=y;

        }
    }
    cout<<scores<<endl<<endl;

    //cout<< scores(Rect(8,8,2,2)) <<endl<<endl;
    scores(Rect(7,7,2,2)).copyTo(img);
    cout<<img<<endl<<endl;
    return img;
}
int main(){

    Mat img;
    Mat ori_img;

    img = imgcpy(ori_img);
    return 0;

}

1 个答案:

答案 0 :(得分:0)

当调用vector析构函数时,我遇到了类似的问题,除了它在另一台计算机上工作。问题是图书馆。我从另一台计算机复制了编译的库文件。他们的视觉stduio版本是不同的。这可能会导致您的问题,使用您的编译器构建opencv。

当visual studio版本更改c运行时库版本更改时。因此,您的代码可能会在运行时崩溃。当我用我的视觉工作室编译OpenCV时,我的问题已经解决了,你的希望就是我的希望。