qq_41747698 2021-10-08 14:33 采纳率: 75%
浏览 53
已结题

opencv stack overrun 栈溢出

Unhandled exception at 0x00E61A6C in testdll_1.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.

虽然可以正常运行,但在程序结束时 } 会引起程序报错,即使是imshow一张图像也会导致内存越界,请问原因是初始化的问题吗?

头文件如下


class _declspec(dllexport) ocr
{
private:
    //string _model_path;
    int crop_mode = 1;
    int thresh_mode = 1;
    int bitwise_mode2 = 0;
    double blur1 = 3;
    double blur2 = 11;

    int morph_xx, morph_yy;
    int morph_x = 1;
    int morph_y = 1;
    int morph_x2 = 1;
    int morph_y2 = 3;
    int iteration = 1;
    int canny_max = 300;
    int min_width = 8;
    int flag;
    int flag2;
    string model_path = "./1.onnx";
    dnn::Net net;
    int rect_thresh = 0;
    int blocksize = 31;
    int C = 10;
    int a = 3;
    int c = 5;
    int b = -5;
    int d = 10;
    int softmax_thresh = 0.9;
    int _h = 1;
    int _w = 1;
    int _channel = 1;
    int RGB_mode = 0;//0为默认bgr
                     //unsigned char * img
    int showimg = 1;

public:
    void * net0;
    /*
    void * net0;
    ocr() {
    this->net0 = new Net();
    }

    ~ocr() {
    delete this->net0;
    }
    */
    ocr(void);
    ~ocr(void);
    void set_print();//打印参数
    void set_showimg(int x);

    void set_morph2(int x, int y);//canny用,默认即可,竖向断裂

    void set_morph(int x, int y);//同正负,正数变粗,负数变细
    void set_morph_easy(int x);//x=1: 3,1--字体横向变细,x=2:-3,-1--字体横向变粗, x=3:1,1--不变

    void set_blocksize(int _C, int _blocksize = 31);//阈值 blocksize自适应区块大小,影响背景过滤程度,默认31,C需人工调整,白色字体C为负数,深色字体正数,影响噪点
    void set_blocksize_easy(int x);//0:字体无粘连,背景无线条,自动阈值, x=1:31,15--字体深色   2:31,-15--字体浅色,背景深色   3:31,4--字体深色但较细

    void set_net(const string model_path);//const string 路径
                                          //void set_net_easy();


cpp如下




#include "stdafx.h"
#include "recognize.h"
#include <stdlib.h>  
#include <iostream>
#include <fstream>

#include "opencv2\opencv.hpp"
#include "opencv2\dnn.hpp"
#include "opencv2\dnn\all_layers.hpp"

#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include<cmath>
#include<windows.h>
//#include "omp.h"  

using namespace std;
using namespace cv;
using namespace dnn;

ocr::ocr(void)
{
    //this->net0 = new Net();
    net = cv::dnn::readNetFromONNX(model_path);
}

ocr::~ocr(void)
{
    ;
    //delete this->net0;
    //~Net();
}

void ocr::set_print()
{
    //cout<<blur <<" blur2" << "\n";
    cout << "blur is" << this->blur2;
    cout << "morph_x, morph_y :" << this->morph_x << this->morph_y << "\n";
    cout << "morph_x2 , morph_y2 :" << this->morph_x2 << this->morph_y2 << "\n";
    //cout << "model_path :" << this->model_path << "\n";
    cout << "rect_thresh :" << this->rect_thresh << "\n";
    cout << "blocksize, C :" << this->blocksize << C << "\n";
    cout << "softmax_thresh :" << this->softmax_thresh << "\n";
}

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月20日
  • 已采纳回答 10月13日
  • 修改了问题 10月8日
  • 创建了问题 10月8日

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器