惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - 浪端之渡鸟

老鼠跑猫叫主人惊醒c++观察者模式实现 讨论exe获取dll提供的单例,并获取单例所提供的带有vector<class A>& STL容器的返回值的情况-提供1种解决方法 vs2010 mfc dll 调试编译的问题 std::stringstream 模版实现,类型转换,遇到空格不跳出 字节对齐,对opencv的影响 跨平台,c语言创建多级路径代码分享 吐槽VS2010,卡死后,一直不能点,强制关机后代码丢失 IOS App资源路径 fopen的打开方式 解决安装macports,不能更新的问题 坑爹啊,新手一个这问题折腾2天,xcode4.5拖上去控件真机调试就崩 静态页面转化 删除_svn文件夹 开发相关日志 WebClient.cs封装 symbian 输入控件不显示输入法解决: V3 V5宏定义 coco2d-x 重置z轴 htmlcontrol-for-symbian 源码解析
opencv在MFC下使用的问题
浪端之渡鸟 · 2012-12-04 · via 博客园 - 浪端之渡鸟

Posted on 2012-12-04 17:28  浪端之渡鸟  阅读(2357)  评论()    收藏  举报

现在我碰到了左右为难的问题:
1.如果用静态库dll解决这个问题,那么在有vector作为输入参数调用opencv就会出现析构问题,因为已经跨栈了
运行到下面会卡住:
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));

我代码里有做sift检测:
{
vector<KeyPoint> pt;
m_Detector.detect( (*it2)->pImage, pt );
}运行到这里析构pt的时候就会报错

2.如果用共享库ll,就是内存泄露的问题
Detected memory leaks!
Dumping objects ->
{1139} normal block at 0x01891A58, 512 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
{1138} normal block at 0x01891A10, 8 bytes long.
Data: <, > 2C 10 89 01 00 00 00 00 
{1137} normal block at 0x018919C8, 8 bytes long.
Data: < > 00 10 89 01 00 00 00 00 
{1136} normal block at 0x01891980, 8 bytes long.
Data: < > E0 0F 89 01 00 00 00 00 
{1135} normal block at 0x01891938, 8 bytes long.
Data: < > B0 0F 89 01 00 00 00 00 
{1134} normal block at 0x018918F0, 8 bytes long.
Data: < > 90 0F 89 01 00 00 00 00 
{1133} normal block at 0x01891860, 80 bytes long.
Data: <` ` ` > 60 18 89 01 60 18 89 01 60 18 89 01 CD CD CD CD 
{1132} normal block at 0x01891818, 8 bytes long.
Data: <| > 7C 0F 89 01 00 00 00 00 
{1131} normal block at 0x018917D0, 8 bytes long.
Data: <\ > 5C 0F 89 01 00 00 00 00 
{1130} normal block at 0x01891788, 8 bytes long.
Data: <8 > 38 0F 89 01 00 00 00 00 
{1129} normal block at 0x01891740, 8 bytes long.
Data: < > 18 0F 89 01 00 00 00 00 
{1128} normal block at 0x018916F8, 8 bytes long.
Data: < > F0 0E 89 01 00 00 00 00 
{1127} normal block at 0x018916B0, 8 bytes long.
Data: < > D0 0E 89 01 00 00 00 00 
{1123} normal block at 0x01891590, 8 bytes long.
Data: < > 1C 0E 89 01 00 00 00 00 
{1122} normal block at 0x01891548, 8 bytes long.
...
下面还有很多。

十分悲剧,对于这个问题,难道不能两全其美了么 :(

经过在这里发帖自己思考后,解决了,原帖如下:

http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=23564&p=68153#p68153

已解决该问题:

1.使用静态库

配置属性-》C++->代码生成->运行库 多线程调试 (/MTd)

2.这个不是opencv的问题,是调用dll的问题,dll中给vector分配成员空间,无论你是传引用,还是指针,只要vector的初始化容器大小,放不下成员,在dll中就会给vector增加空间,故解决方法如下:

vector<KeyPoint> pt(1000);
m_Detector.detect( (*it2)->pImage, pt );

预先在自己程序中分配好,1000只是个估值,根据实际大小最大值来设置

大部分转载 小部分自写