opencv imencode() 缓冲区异常 [英] opencv imencode() buffer exception

查看:144
本文介绍了opencv imencode() 缓冲区异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这些代码将 Mat 图像编码为 .jpg 格式.它正在处理小图像,但是当我放置大图像时,项目会出现异常

I am using these codes for encode Mat image to .jpg format. It is working with small images, but when I put a large image, project give exception

0x76377fb2 (ucrtbase.dll) 中的未处理异常ImageRecognition.exe:0xC0000409:0xc0000409.

Unhandled exception at 0x76377fb2 (ucrtbase.dll) in ImageRecognition.exe: 0xC0000409: 0xc0000409.

我在 Visual Studio 2015 中使用 opencv2.4.12,我的操作系统是 Windows 10,这是我的代码块.

I am using opencv2.4.12 in Visual Studio 2015 and my OS is Windows 10 here is my code block.

cv::threshold(image, image, 100, 255, cv::THRESH_BINARY + cv::THRESH_OTSU);
std::vector<uchar> buf;
imencode(".jpg", image, buf);

推荐答案

解决这个问题的一些机会:

Some opportunities to solve this problem :

尝试在调用 std::vector buf(50000) 之前分配缓冲区;我使用了这个解决方案,它对我有用.我会尽快升级我的opencv版本到3.2

try to allocate buffer before call std::vector buf(50000); I used this solution it is worked for me. I will upgrade my opencv version to 3.2 as soon as possible

好主意更新到 opencv 3.2

good idea update to opencv 3.2

这篇关于opencv imencode() 缓冲区异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆