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";
}