当前位置: 首页 > news >正文

怎样建设一个公司网站贵州seo推广

怎样建设一个公司网站,贵州seo推广,网络公关事件,网站推广的心得文章目录 opencv视频文件的读取,处理与保存一、视频文件的读取:1、cv::VideoCapture是OpenCV库中用于处理视频输入的类,它提供了一种简单的方法来从摄像头,视频文件、或图像序列中读取帧;(1)打开…

文章目录

      • opencv视频文件的读取,处理与保存
        • 一、视频文件的读取:
          • 1、cv::VideoCapture是OpenCV库中用于处理视频输入的类,它提供了一种简单的方法来从摄像头,视频文件、或图像序列中读取帧;
            • (1)打开摄像头:
            • (2)打开视频文件:
            • (3)打开网络摄像头:
            • (4)打开图像序列:
          • 2、cv::VideoCapture类的常用方法:
            • (1)capture.get():用于获取视频的属性,比如帧数、帧率等:
            • (2)capture.set(int propId, double value):用于设置视频的属性,比如设置视频的帧率、帧大小等属性;
            • (3)capture.read(cv::Mat& frame):用于读取视频的一帧,将其存储在 `cv::Mat` 对象中;
            • (4)capture.release():用于释放 `VideoCapture` 对象所占用的资源,一般在你已经完成了对视频流的操作后调用它;
        • 二、对视频帧进行处理:
        • 三、保存处理后的视频:
          • 1、cv::VideoWriter 是opencv中用于将图像帧序列保存为视频文件的类,它可以将处理过的帧写入一个视频文件,也可以将视频流输出到摄像头或网络;
            • (1)创建一个 cv::VideoWriter 对象:
          • 2、cv::VideoWriter类的常用方法:
            • (1)cv::VideoWriter::open():用于打开一个视频文件或设备以便写入视频帧;
            • (2)cv::VideoWriter::write():用于将一帧图像写入视频文件;
            • (3)cv::VideoWriter::isOpened():用于检查VideoWriter对象是否成功打开,如果成功打开了视频文件或者设备,该方法将返回true,否则返回false;
            • (4)cv::VideoWriter::release():用于释放VideoWriter对象所占用的资源,一般在你已经完成了对视频的写入操作后调用它;

opencv视频文件的读取,处理与保存

一、视频文件的读取:
1、cv::VideoCapture是OpenCV库中用于处理视频输入的类,它提供了一种简单的方法来从摄像头,视频文件、或图像序列中读取帧;
(1)打开摄像头:
cv::VideoCapture capture(int index)参数解释:
index:打开指定编号的摄像头,编号0表示默认摄像头,如果你的计算机连接了多个摄像头,你可以使用不同的编号来选择不同的摄像头;
(2)打开视频文件:
cv::VideoCapture capture(const std::string& filename)参数解释:
filename:打开指定的视频文件,你需要提供视频文件的路径和名称作为参数;
(3)打开网络摄像头:
cv::VideoCapture capture(const std::string& apiKey, const std::string& deviceId)参数解释:
用于打开网络摄像头,需要提供相应的API密钥和设备ID;
(4)打开图像序列:
cv::VideoCapture capture(const std::string& pattern, int api)参数解释:
用于打开图像序列,需要提供文件名模式(通配符)和相应的API;
2、cv::VideoCapture类的常用方法:
(1)capture.get():用于获取视频的属性,比如帧数、帧率等:
capture.get(int propId)参数解释:
propId:是一个整数参数,用于指定你想获取的属性类型(cv::CAP_PROP_FRAME_COUNT:获取视频的帧数;cv::CAP_PROP_FPS:获取视频的帧率(每秒帧数);cv::CAP_PROP_FRAME_WIDTH:视频帧的宽度;cv::CAP_PROP_FRAME_HEIGHT:视频帧的高度;
)

示例:

#include <opencv2\opencv.hpp>
#include <iostream>
#include <demo.h>using namespace cv;
using namespace std;int main() {// 初始化一个cv::VideoCapture对象,打开视频文件VideoCapture capture("C:\\cpp\\image\\cayenne.mp4");if (!capture.isOpened()) {std::cerr << "Error: 无法打开视频文件." << std::endl;return -1;}// 调用cv::VideoCapture类的get()方法,获取视频宽度,高度,帧数,帧率int frameWidth = capture.get(cv::CAP_PROP_FRAME_WIDTH);int frameHeight = capture.get(cv::CAP_PROP_FRAME_HEIGHT);int frameCount = capture.get(cv::CAP_PROP_FRAME_COUNT);double fps = capture.get(cv::CAP_PROP_FPS);std::cout << "frame width:" << frameWidth << std::endl;std::cout << "frame height:" << frameHeight << std::endl;std::cout << "Number of Frames:" << frameCount << std::endl;std::cout << "FPS:" << fps << std::endl;capture.release(); // 释放VideoCapture对象
}
(2)capture.set(int propId, double value):用于设置视频的属性,比如设置视频的帧率、帧大小等属性;
capture.set(int propId, double value)参数解释:
propId:指定了你想设置的属性类型;
value:要设置的值;

示例:

cv::VideoCapture capture(0); // 打开默认摄像头if (!capture.isOpened()) {std::cerr << "Error: 无法打开摄像头." << std::endl;return -1;
}capture.set(cv::CAP_PROP_FRAME_WIDTH, 1280);
capture.set(cv::CAP_PROP_FRAME_HEIGHT, 720);
capture.set(cv::CAP_PROP_FPS, 30);capture.release(); // 释放VideoCapture对象
(3)capture.read(cv::Mat& frame):用于读取视频的一帧,将其存储在 cv::Mat 对象中;

示例:

cv::VideoCapture capture("video_file.mp4");if (!capture.isOpened()) {std::cerr << "Error: 无法打开视频文件." << std::endl;return -1;
}cv::Mat frame;
capture.read(frame);// 在这里可以对 frame 进行处理capture.release(); // 释放VideoCapture对象
(4)capture.release():用于释放 VideoCapture 对象所占用的资源,一般在你已经完成了对视频流的操作后调用它;
二、对视频帧进行处理:

循环遍历视频的每一帧,可以在循环内部对每一帧进行处理在这里,我注释掉了处理部分,你可以根据需要添加各种图像处理操作,比如滤波、边缘检测等;

代码示例:

#include <opencv2\opencv.hpp>
#include <iostream>
#include <demo.h>using namespace cv;
using namespace std;int main() {// 打开视频文件VideoCapture capture("C:\\cpp\\image\\cayenne.mp4");// 检查视频是否成功打开if (!capture.isOpened()) {std::cerr << "Error: 无法打开视频文件." << std::endl;return -1;}// 获取视频的帧数和帧率int frameCount = capture.get(cv::CAP_PROP_FRAME_COUNT);double fps = capture.get(cv::CAP_PROP_FPS);// 创建一个VideoWriter对象来保存处理后的视频cv::VideoWriter outVideo("outVideo.mp4", capture.get(CAP_PROP_FOURCC), fps, cv::Size(capture.get(cv::CAP_PROP_FRAME_WIDTH), capture.get(cv::CAP_PROP_FRAME_HEIGHT)));// 循环处理视频的每一帧for (int i = 0; i < frameCount; ++i) {cv::Mat frame;capture >> frame; // 读取一帧if (frame.empty()) {break;}// 在这里可以对frame进行处理,比如进行滤波、边缘检测等// 例如:cv::cvtColor(frame, frame, cv::COLOR_BGR2GRAY);// 将处理后的帧写入输出视频文件outVideo << frame;}// 释放VideoCapture和VideoWriter对象capture.release();outVideo.release();std::cout << "视频处理完成." << std::endl;
}
三、保存处理后的视频:
1、cv::VideoWriter 是opencv中用于将图像帧序列保存为视频文件的类,它可以将处理过的帧写入一个视频文件,也可以将视频流输出到摄像头或网络;
(1)创建一个 cv::VideoWriter 对象:

函数原型:

cv::VideoWriter writer(const String& filename, int fourcc, double fps, Size frameSize, bool isColor = true)参数解释:
filename:要保存的视频文件名或者设备地址;
fourcc:FourCC编码,指定视频编解码器的类型(cv::VideoWriter::fourcc('X','V','I','D'):Xvid编解码器;cv::VideoWriter::fourcc('M','J','P','G'):MJPEG编解码器;cv::VideoWriter::fourcc('M','P','4','V'):MPEG-4编解码器;cv::VideoWriter::fourcc('H','2','6','4'):H.264编解码器;
);
fps:帧率,即每秒显示的帧数;
frameSize:帧的大小,可以通过cv::Size类指定;
isColor:指定保存的视频是否为彩色,默认为true
2、cv::VideoWriter类的常用方法:
(1)cv::VideoWriter::open():用于打开一个视频文件或设备以便写入视频帧;
cv::VideoWriter::open(const String& filename, int fourcc, double fps, Size frameSize, bool isColor = true)参数解释:参数和构造函数类似;
filename:要保存的视频文件名或者设备地址;
fourcc:FourCC编码,指定视频编解码器的类型(cv::VideoWriter::fourcc('X','V','I','D'):Xvid编解码器;cv::VideoWriter::fourcc('M','J','P','G'):MJPEG编解码器;cv::VideoWriter::fourcc('M','P','4','V'):MPEG-4编解码器;cv::VideoWriter::fourcc('H','2','6','4'):H.264编解码器;
);
fps:帧率,即每秒显示的帧数;
frameSize:帧的大小,可以通过cv::Size类指定;
isColor:指定保存的视频是否为彩色,默认为true
(2)cv::VideoWriter::write():用于将一帧图像写入视频文件;
cv::VideoWriter::write(const Mat& image)参数解释:
image:要写入视频的帧,通常是一个cv::Mat对象;
(3)cv::VideoWriter::isOpened():用于检查VideoWriter对象是否成功打开,如果成功打开了视频文件或者设备,该方法将返回true,否则返回false;
(4)cv::VideoWriter::release():用于释放VideoWriter对象所占用的资源,一般在你已经完成了对视频的写入操作后调用它;

示例:

我们首先创建了一个 VideoWriter 对象,指定了视频文件的名称、FourCC编码、帧率和帧大小。接着,我们检查是否成功打开了文件。然后,我们创建了一个红色的帧(640x480 大小的纯红色图像)并将其写入视频文件10次。最后,我们释放了 VideoWriter 对象。

#include <opencv2\opencv.hpp>
#include <iostream>
#include <demo.h>using namespace cv;
using namespace std;int main() {Demo demo;// 初始化一个cv::VideoCapture对象,打开视频文件VideoCapture capture("C:\\cpp\\image\\cayenne.mp4");// 调用cv::VideoCapture类的get()方法,获取视频宽度,高度,帧数,帧率int frame_width = capture.get(CAP_PROP_FRAME_WIDTH);int frame_height = capture.get(CAP_PROP_FRAME_HEIGHT);int count = capture.get(CAP_PROP_FRAME_COUNT);double fps = capture.get(CAP_PROP_FPS);std::cout << "frame width:" << frame_width << std::endl;std::cout << "frame height:" << frame_height << std::endl;std::cout << "FPS:" << fps << std::endl;std::cout << "Number of Frames:" << count << std::endl;// 初始化一个cv::VideoWriter 对象,保存处理后的视频文件// capture.get(CAP_PROP_FOURCC):获取原视频的编解码器// Size(frame_width, frame_height):原视频的宽高VideoWriter writer("C:\\cpp\\image\\test.mp4", capture.get(CAP_PROP_FOURCC), fps, Size(frame_width, frame_height), true);Mat frame;while (true) {// 读取视频的一帧,将其存储在frame对象中capture.read(frame);// TODO: do something...// 对读取到的这帧图像,做flip()翻转处理flip(frame, frame, 1);if (frame.empty()) {break;}// 显示这帧图像imshow("frame", frame);// 对这帧图像,做色彩空间转换demo.colorSpace(frame);// 将这帧图像写入视频文件writer.write(frame);int c = waitKey(1);if (c == 27) { // 退出break;}}// releasecapture.release();writer.release();
}

做色彩空间转换 demo.colorSpace()函数如下:

void Demo::colorSpace(Mat &image) {Mat gray, hsv;// 转hsvcvtColor(image, hsv, COLOR_BGR2HSV);// 转灰度cvtColor(image, gray, COLOR_BGR2GRAY);// 显示这两张图imshow("HSV",hsv);imshow("GARY", gray);// 保存这两张图imwrite("C:\\cpp\\vs\\opencv\\hsv.png", hsv);imwrite("C:\\cpp\\vs\\opencv\\gray.png", gray);}

文章转载自:
http://bestial.c7507.cn
http://badman.c7507.cn
http://invalidation.c7507.cn
http://erythorbate.c7507.cn
http://acquittance.c7507.cn
http://immunocyte.c7507.cn
http://galvanotactic.c7507.cn
http://asphyxiant.c7507.cn
http://shingly.c7507.cn
http://senhora.c7507.cn
http://ethisterone.c7507.cn
http://prejudgment.c7507.cn
http://bunion.c7507.cn
http://amaryllidaceous.c7507.cn
http://feat.c7507.cn
http://centennial.c7507.cn
http://demobitis.c7507.cn
http://cohabit.c7507.cn
http://pronate.c7507.cn
http://decartelization.c7507.cn
http://orc.c7507.cn
http://moorhen.c7507.cn
http://lister.c7507.cn
http://egyptianization.c7507.cn
http://grievous.c7507.cn
http://rebind.c7507.cn
http://biconvex.c7507.cn
http://scutiform.c7507.cn
http://benempted.c7507.cn
http://wafd.c7507.cn
http://voraciously.c7507.cn
http://hangfire.c7507.cn
http://absently.c7507.cn
http://diploic.c7507.cn
http://ephesians.c7507.cn
http://teu.c7507.cn
http://triquetrous.c7507.cn
http://squama.c7507.cn
http://msls.c7507.cn
http://generant.c7507.cn
http://myoclonia.c7507.cn
http://illegible.c7507.cn
http://superload.c7507.cn
http://dicrotisc.c7507.cn
http://democratization.c7507.cn
http://disregardful.c7507.cn
http://cruising.c7507.cn
http://torture.c7507.cn
http://autostrada.c7507.cn
http://microcontinent.c7507.cn
http://supplementary.c7507.cn
http://commemorable.c7507.cn
http://crackpot.c7507.cn
http://runround.c7507.cn
http://unanswered.c7507.cn
http://gigmanity.c7507.cn
http://spoiler.c7507.cn
http://aheap.c7507.cn
http://arcograph.c7507.cn
http://millenarianism.c7507.cn
http://sunos.c7507.cn
http://brainwork.c7507.cn
http://irascibly.c7507.cn
http://huguenot.c7507.cn
http://aioli.c7507.cn
http://salvatore.c7507.cn
http://museful.c7507.cn
http://chaucerism.c7507.cn
http://gurge.c7507.cn
http://amorce.c7507.cn
http://primeval.c7507.cn
http://mars.c7507.cn
http://surveyorship.c7507.cn
http://pilum.c7507.cn
http://nobleman.c7507.cn
http://bazoom.c7507.cn
http://newsprint.c7507.cn
http://midgarth.c7507.cn
http://sordamente.c7507.cn
http://countertide.c7507.cn
http://populate.c7507.cn
http://charleston.c7507.cn
http://cold.c7507.cn
http://goldwater.c7507.cn
http://sinai.c7507.cn
http://alforja.c7507.cn
http://callao.c7507.cn
http://stepney.c7507.cn
http://dickeybird.c7507.cn
http://couplet.c7507.cn
http://puy.c7507.cn
http://presumably.c7507.cn
http://opportune.c7507.cn
http://southwestward.c7507.cn
http://halfpenny.c7507.cn
http://snacketeria.c7507.cn
http://mooltan.c7507.cn
http://ayuntamiento.c7507.cn
http://ugliness.c7507.cn
http://brethren.c7507.cn
http://www.zhongyajixie.com/news/76167.html

相关文章:

  • 滁州市南谯区建设局网站舆情信息范文
  • 温岭做网站公司久久seo综合查询
  • 福田的网站建设公司有哪些网站可以免费发布广告
  • wordpress管理界面站长工具之家seo查询
  • 广西企业网站有哪些合肥做网站公司哪家好
  • 东莞专业网站推广需要多少钱网站建站哪家公司好
  • 提高网站打开速度的7大秘籍毕节地seo
  • 常州外贸集团 网站建设seo推广软件代理
  • 购物网站制作公司宁波谷歌seo推广
  • 微信引流推广精准粉对搜索引擎优化的认识
  • 杭州网站搭建公司百度商家怎么入驻
  • 深圳 企业 网站建设南京关键词网站排名
  • 哪里有个人做网站的seo新手教程
  • 网站做中文和英文切换桔子seo
  • 网页微信版本在哪里下载重庆电子商务seo
  • 济南手机端建站模板百度公司好进吗
  • 网页设计作品模板seo词库排行
  • 雅虎网站提交优化关键词排名的工具
  • 临猗做网站seo服务顾问
  • 网站资源做外链社会化媒体营销
  • 安装wordpress后加固爱站seo工具包官网
  • 做电子书网站 赚钱手机免费发布信息平台
  • 如何百度到自己的网站重庆森林影评
  • 制作大型网站开发企业seo推广外包
  • 微信里有人发做任务网站站长网
  • 如何做免费的网站佛山做网站建设
  • 企业官网的作用seo是搜索引擎优化吗
  • 济南网站建设用途郑州seo优化服务
  • 上海先进网站设计网页设计制作网站模板
  • 做甜品的网站磁力多多