当前位置:网站首页>Opencv learn read images videos and webcams
Opencv learn read images videos and webcams
2022-07-26 07:07:00 【Heihei_ study】
Catalog
One 、 Import image

#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
// Import image
int main()
{
string path="C:\\Users\\Rong\\Desktop\\Resources\\test.png";
Mat img = imread(path);
imshow("Image", img);
waitKey(0);
}notes : The image path should be double backslash !
Two 、 Import video
A video is a picture frame by frame , Use while Loop through each frame
// Import video
int main() {
string path = "C:\\Users\\Rong\\Desktop\\Resources\\test_video.mp4";
VideoCapture cap(path);
Mat img;
while (true) {
cap.read(img);
imshow("Video", img);
waitKey(20);
}
}3、 ... and 、 camera
Change the path of that video into 0 Because there is only one camera on my computer ( If write 1 Will report a mistake !)
// camera
int main() {
VideoCapture cap(0);
Mat img;
while (true) {
cap.read(img);
imshow("Webcom", img);
waitKey(20);
}
}边栏推荐
- 10 papers of ant security laboratory were included by ccf-a top meeting to explore the realization of AI credibility from the perspective of algorithm
- LeetCode刷题1:题目分类
- MySQL table read lock
- 火焰图分析Flink反压
- The results of the soft test can be checked, and the entry to query the results of the soft test has been opened in the first half of 2022
- < II> ObjectARX development: create and edit basic graphic objects
- 【数据库】CTE(Common Table Expression(公共表表达式))
- MySQL table write lock
- 解决 Chrome 浏览器被毒霸篡改问题
- Contents mismatch at: 08000000H (Flash=FFH Required=00H) ! Too many errors to display !
猜你喜欢

An album has been released, from introductory practical demonstration to advanced live Q & A, playing with container service so easy~

火焰图分析Flink反压

String and memory functions

Question: can't download sh shellcheck Please install it manually and some commands of shell script

“蔚来杯“2022牛客暑期多校训练营1补题记录(ACDGIJ)
![[749. Isolate virus]](/img/12/b8c3cdb664f4415d20c2fc5c697a41.png)
[749. Isolate virus]

The results of the soft test can be checked, and the entry to query the results of the soft test has been opened in the first half of 2022

C # use log4net plug-in to output logs to files

Realize the full link grayscale based on Apache APIs IX through MSE

Precious metal knowledge: lethal short-term secret script
随机推荐
IDEA——使用@Slf4j打印日志
二叉树知识总结
Idea -- use @slf4j to print logs
< II> ObjectARX development: create and edit basic graphic objects
LeetCode刷题1:题目分类
Summarize and learn STM32 to create project template
buuReserve(4)
buuReserve(4)
[Star Project] small hat aircraft War (IV)
[arm learning (8) AXF tool analysis]
Curve curvature display
Opengauss simple version installation error
LTS(Light-Task-Scheduler)
XSS-labs(1-10)闯关详解
Queue assistant | product update log in June 2022
7. Reverse integer integer
Intention lock
【Star项目】小帽飞机大战(四)
[untitled] reprint
Image annotation software reference