Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();   /// I HAVE TRIED WITH copyTo FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);       ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();   /// // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);      ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Thanks

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();  // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);     ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Please tell me what is the reason of such fault in program and any possible solution Thanks

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();  // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);     ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Please tell me what is the reason of such fault in program and any possible solution My Opencv ver is 2.4.10 so I am actually using the ximgproc's structured edge detector within my project Thanks

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();  // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);     ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Please tell me what is the reason of such fault in program and any possible solution solution. My Opencv ver is 2.4.10 so I am actually using the ximgproc's structured edge detector within my project Thanks

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();  // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);     ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Please tell me what is the reason of such fault in program and any possible solution. My Opencv ver version is 2.4.10 so I am actually using the ximgproc's structured edge detector detector's code within my project project.

Thanks

std::vector of cv::Mat causing memory corruption

I am using opencv_contrib's ximgproc moule's structural edge detector's code in my visual studio project . But it giving _CrtIsValidHeapPointer(pUserData) error expression . With some debugging I realized that Actually the error is caused when a function getFeatures defined in structured_edge_detector.cpp tries to push cv::Mat in a std::vector as shown below

virtual void getFeatures(const Mat &src, Mat &features, const int gnrmRad, const int gsmthRad,
                         const int shrink, const int outNum, const int gradNum) const
{
    cv::Mat luvImg = rgb2luv(src);

    std::vector <cv::Mat> featureArray;

    cv::Size nSize = src.size() / float(shrink);
    split( imresize(luvImg, nSize), featureArray );

    CV_INIT_VECTOR(scales, float, {1.0f, 0.5f});

    for (size_t i = 0; i < scales.size(); ++i)
    {
        int pSize = std::max( 1, int(shrink*scales[i]) );

        cv::Mat magnitude, histogram;
        gradientHist(/**/ imsmooth(imresize(luvImg, scales[i]*src.size()), gsmthRad),
            magnitude, histogram, gradNum, pSize, gnrmRad /**/);
        Mat aaa=imresize( magnitude, nSize ).clone();  // I HAVE TRIED WITH copyTo etc FUNC ALSO ! SAME ERROR
        featureArray.push_back(/**/aaa /**/);     ////// THIS INSERTION IS ALWAYS CAUSING ERROR !
        featureArray.push_back(/**/ imresize( histogram, nSize ).clone() /**/);
    }

    // Mixing
    int resType = CV_MAKETYPE(cv::DataType<float>::type, outNum);
    features.create(nSize, resType);

    std::vector <int> fromTo;
    for (int i = 0; i < 2*outNum; ++i)
        fromTo.push_back(i/2);

    mixChannels(featureArray, features, fromTo);
}

Please tell me what is the reason of such fault in program and any possible solution. My Opencv version is 2.4.10 so I am actually using the ximgproc's structured edge detector's code within my project.

Thanks