In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to parse RTSP protocol video platform EasyCVR using OpenCV to build Mat data from memory. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
In the EasyCVR picture processing function, OpenCV is used for picture processing. OpenCV is a cross-platform computer vision and machine learning software library released under the BSD license (open source) that can run on Linux, Windows, Android and Mac OS operating systems.
When using OpenCV, you usually directly use the cv::imread (file_path.c_str ()); method to build cv::Mat data for processing. This method is to build cv::Mat after reading data from files on disk, that is, the processing order is as follows:
First, other modules write the picture data to the disk file.
OpenCV loads disk files into memory to build Mat data.
The disadvantages of this method are as follows: first, it consumes performance on disk read and write, secondly, other modules consume memory once, and OpenCV module also consumes memory once.
Because other modules have loaded the corresponding image data in memory, passing this part of the data directly to the OpenCV module can greatly speed up the processing speed. The cv::imdecode (data, CV_LOAD_IMAGE_COLOR) method is mainly used to build Mat data.
The following is the specific code:
String fname = "D:/image.jpg"; /! Read pictures into memory in binary stream FILE* pFile = fopen (fname.c_str (), "rb"); fseek (pFile, 0, SEEK_END); long lSize = ftell (pFile); rewind (pFile); char* pData = new char [lSize]; fread (pData, sizeof (char), lSize, pFile); fclose (pFile); / /! Decode the in-memory data into cv::Mat data cv::Mat img_decode; vector data; for (int I = 0; I < lSize; + + I) {data.push_back (pdata [I]);} img_decode = cv::imdecode (data, CV_LOAD_IMAGE_COLOR); cv::flip (img_decode, img_decode,-1); img_decode.channels (); / /! Encode cv::Mat data into a data stream vector img_encode; cv::imencode (".jpg", img_decode, img_encode); unsigned char * encode_data = new unsigned char [lSize]; for (int I = 0; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.