In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article is about how OpenCV can read and write images. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Image operation
Image processing.
CvtColor (matobj1,printmatobj,CV_BGR2GRAY) / / Image 1 grayscale processing, save to image 2Canny (edges,edges,0,30,0); / / extract edges, save to image 2
Image display
NamedWindow ("printmatobj", 1); / / create a window imshow ("printmatobj", printmatobj); / / display to the window to read and write images
Use two functions to read and write files
Read image file
Imread function:
Enter the file path, and the number of channels that return the image, and the image is converted to a matrix
Empty method:
Check whether the read is successful
Write image file
Use the imwrite function to enter the file path, file format, file format details, matrix conversion to the image to save to the specified path
Read and write video
Use two classes to read and write files
VideoCapture
Classes that read videos
Open method / / Open camera or video isOpened method / / check whether the read method is opened successfully / / read an image VideoCaptureobj > > Matobj// read an image
VideoWriter
Classes that output video
Codec:
In CV_Fourcc format, if the coding is not successful, use another codec instead.
Size s (320240); / / define video width and height
VideoWirter writer=VideoWirter (filename,decoder,rate,size) / / set file name, codec, frame rate, width, height parameters
IsOpened method / / check whether the VideoWriterobj has been created successfully
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.