当前位置:网站首页>How many images can opencv open?
How many images can opencv open?
2022-06-25 04:07:00 【Program type】
Recently someone asked a question , It has a size 800MB The image file , Find that you can't pass OpenCV Of imread Function load , Just read , The program just crashed . I asked about the size of the image , After calculating the number of pixels, we found that the total number of pixels has exceeded OpenCV Declare the maximum number of pixels limit , So I can't read it !
opencv The maximum number of images can be opened ?
The size of the open image is related to the computer memory , The higher the running memory, the larger the file that can be opened .
Everybody knows OpenCV The function to read the image in is imread, The functions are as follows :
Mat cv::imread(
const String & filename,
int flags = IMREAD_COLOR
)
Parameter interpretation
- filename Represents the file path of the input image
- flags Indicates how the image is loaded
Support includes bmp、jpg、png、webp、pfm、sr、ras、tiff、hdr Image files in the same format
Load super image limit and breakthrough
One of the most common errors encountered when loading large images is
The computer memory is not enough , But most of the time, the computer memory is enough , But still can't load , The reason is simple , Mainly OpenCV The size of the loaded image itself is limited by , The limit is defined in
modules\imgcodecs\src\loadsave.cpp
In this source file , There are three about images imread When the maximum image width 、 high 、 Pixel number size limit , The code defined is :
static const size_t CV_IO_MAX_IMAGE_WIDTH = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_WIDTH", 1 << 20);
static const size_t CV_IO_MAX_IMAGE_HEIGHT = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_HEIGHT", 1 << 20);
static const size_t CV_IO_MAX_IMAGE_PIXELS = utils::getConfigurationParameterSizeT("OPENCV_IO_MAX_IMAGE_PIXELS", 1 << 30);
Explain the following :
- Maximum image width supported 2^20
- Maximum image height supported 2^20
- Maximum number of pixels supported 2^30
function validateInputImageSize Will first verify the size of the image ,
static Size validateInputImageSize(const Size& size)
{
CV_Assert(size.width > 0);
CV_Assert(static_cast<size_t>(size.width) <= CV_IO_MAX_IMAGE_WIDTH);
CV_Assert(size.height > 0);
CV_Assert(static_cast<size_t>(size.height) <= CV_IO_MAX_IMAGE_HEIGHT);
uint64 pixels = (uint64)size.width * (uint64)size.height;
CV_Assert(pixels <= CV_IO_MAX_IMAGE_PIXELS);
return size;
}
Modify restrictions
Want to load image files that exceed these limits , First make sure you have enough memory , Then manually modify OpenCV The source code file , Change the limit to the value you want , Then recompile OpenCV that will do .
Share some of my artificial intelligence learning materials for free , Including some AI Common framework actual combat video 、 Image recognition 、OpenCV、NLQ、 machine learning 、pytorch、 Computer vision 、 Videos such as deep learning and neural network 、 Courseware source code 、 Famous essence resources at home and abroad 、AI Hot papers 、 Industry reports, etc .
For better systematic learning AI, I recommend that you collect one .
Here are some screenshots , Free download method is attached at the end of the article .
One 、 Artificial intelligence courses and projects
Two 、 Famous essence resources at home and abroad
3、 ... and 、 Collection of papers on artificial intelligence
Four 、 AI Industry Report
Learn Artificial Intelligence well , Read more , Do more , practice , If you want to improve your level , We must learn to settle down and learn slowly and systematically , Only in the end can we gain something .
Click on the business card below , Scan the code and download the information for free .
边栏推荐
- Work assessment of Biopharmaceutics of Jilin University in March of the 22nd spring -00031
- Russian Airi Research Institute, etc. | SEMA: prediction of antigen B cell conformation characterization using deep transfer learning
- What is the difference between learning code, rolling code and fixed code? The number of repeated codes, coding capacity and the principle of rolling code
- The art of writing simple code
- Development of trading system (XIII) -- Analysis of quickfix source code
- zabbix的安装避坑指南
- 墨天轮访谈 | IvorySQL王志斌—IvorySQL,一个基于PostgreSQL的兼容Oracle的开源数据库
- Jilin University 22 spring March "career design" assignment assessment-00072
- Maybe it's the wrong reason
- List rendering in wechat applet
猜你喜欢
[team learning] SQL programming language notes - task04
cesium 图形标注圆形、正方形、多边形、椭圆等
Siddhartha: the book of life can be regurgitated frequently
Changsha's "talent seeking": "making efforts" and "making practical moves" go hand in hand, "rapid development" and "slow life" go hand in hand
【Proteus仿真】Arduino UNO按键控制数码管闪烁增/减显示
Maybe it's the wrong reason
居家办公之后才明白的时间管理 | 社区征文
Hello CTP (III) - CTP quotation API
[harmony OS] [ark UI] basic ETS context operations
【组队学习】SQL编程语言笔记——Task04
随机推荐
Work assessment of pharmacotherapeutics of Jilin University in March of the 22nd spring -00064
虽然传统意义上的互联网早已不复存在,但这并不代表互联网早已消失不再
How to quickly deliver high-value software
Configuration source code
Cesium graphic annotation circle, square, polygon, ellipse, etc
Monitoring pancakeswap new token
DAP数据调度功能完善说明
Development of trading system (XIII) -- Analysis of quickfix source code
Color NFT series representing diversity launched on the sandbox market platform
佐喃社区
What is the difference between learning code, rolling code and fixed code? The number of repeated codes, coding capacity and the principle of rolling code
OpenSUSE environment variable settings
js工具函数,自己封装一个节流函数
Jilin University 22 spring March "technical economics" assignment assessment-00073
Work assessment of Biopharmaceutics of Jilin University in March of the 22nd spring -00031
(ultra detailed onenet TCP protocol access) arduino+esp8266-01s accesses the Internet of things platform, uploads real-time collected data /tcp transparent transmission (and how to obtain and write Lu
Mstp+vrrp+ospf implements a three-tier architecture
Solution to the problem that Linux crontab timed operation Oracle does not execute (crontab environment variable problem)
墨天轮访谈 | IvorySQL王志斌—IvorySQL,一个基于PostgreSQL的兼容Oracle的开源数据库
MySQL根据表前缀批量修改、删除表