HI I'm now testing opencv function with dll linked opencv's static lib, compiled with opencv4.5.3, Cmake and VS2015, but however I've found that there's an exception caused by opencv. Here's the error after return:testdll_1.exe has triggered a breakpoint. which being point to :
if (!HeapFree(select_heap(block), 0, block))
{
errno = __acrt_errno_from_os_error(GetLastError());
}
and being found stack overrun in release mode Here's how I tried to build dll:
#pragma once
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/opencv_world453.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/ippicvmt.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libprotobuf.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/ippiw.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libjpeg-turbo.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/ittnotify.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/ade.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/zlib.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libopenjp2.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libpng.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/quirc.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/IlmImf.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libtiff.lib" )
#pragma comment( lib,"D:/opencv/build/x86/vc14/staticlib/libwebp.lib" )
#include "stdafx.h"
#define _DLL_EXPORTS
#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 <string>
using std::string;
using namespace std;
using namespace cv;
using namespace dnn;
class _declspec(dllexport) ocr
private:
cv::dnn::Net net;
int some_params = 0;
string model_path;
public:
ocr(void){
model_path = "./1.onnx";
net = cv::dnn::readNetFromONNX(model_path);
};
~ocr(void);{}
void showimg(string path){Mat a= imread(path);
cv::imshow("a",a);
cv::waitKey(0);
}
After that I've tried to run this dll with:#pragma comment(lib, "makedll.lib") and an hpp file with same interface above.It's being like:
void main(int argc, char** argv)
{
ocr read;
read.showimg("D:/opencv/1.jpg");
return;
}
Though the imshow function works well, but with the Net type inside private, the program still exit with stack overrun error after return. Is it opencv's individual heap error or Net type error? How am I able to discover the right way fixing this error? Or maybe if this isn't important that much, is it possible to ignore the error?