技术标签: opencv3常用代码示例 c/c++
#include <opencv2/opencv.hpp>
#include <opencv2/videostab.hpp>
#include <string>
#include <iostream>
using namespace std;
using namespace cv;
using namespace cv::videostab;
string inputPath = "inputVideo.avi";
string outputPath = "outputVideo.avi";
// 视频稳定输出
void videoOutput(Ptr<IFrameSource> stabFrames, string outputPath)
{
VideoWriter writer;
cv::Mat stabFrame;
int nframes = 0;
// 设置输出帧率
double outputFps = 25;
// 遍历搜索视频帧
while (!(stabFrame = stabFrames->nextFrame()).empty())
{
nframes++;
// 输出视频稳定帧
if (!outputPath.empty())
{
if (!writer.isOpened())
writer.open(outputPath, VideoWriter::fourcc('X', 'V', 'I', 'D'),
outputFps, stabFrame.size());
writer << stabFrame;
}
imshow("stabFrame", stabFrame);
// esc键退出
char key = static_cast<char>(waitKey(100));
if (key == 27)
{
cout << endl;
break;
}
}
std::cout << "nFrames: " << nframes << endl;
std::cout << "finished " << endl;
}
void cacStabVideo(Ptr<IFrameSource> stabFrames, string srcVideoFile)
{
try
{
Ptr<VideoFileSource> srcVideo = makePtr<VideoFileSource>(inputPath);
cout << "frame count: " << srcVideo->count() << endl;
// 运动估计
double estPara = 0.1;
Ptr<MotionEstimatorRansacL2> est =
makePtr<MotionEstimatorRansacL2>(MM_AFFINE);
// Ransac参数设置
RansacParams ransac = est->ransacParams();
ransac.size = 3;
ransac.thresh = 5;
ransac.eps = 0.5;
// Ransac计算
est->setRansacParams(ransac);
est->setMinInlierRatio(estPara);
// Fast特征检测
Ptr<FastFeatureDetector> feature_detector =
FastFeatureDetector::create();
// 运动估计关键点匹配
Ptr<KeypointBasedMotionEstimator> motionEstBuilder =
makePtr<KeypointBasedMotionEstimator>(est);
// 设置特征检测器
motionEstBuilder->setDetector(feature_detector);
Ptr<IOutlierRejector> outlierRejector = makePtr<NullOutlierRejector>();
motionEstBuilder->setOutlierRejector(outlierRejector);
// 3-Prepare the stabilizer
StabilizerBase *stabilizer = 0;
// first, prepare the one or two pass stabilizer
bool isTwoPass = 1;
int radius_pass = 15;
if (isTwoPass)
{
// with a two pass stabilizer
bool est_trim = true;
TwoPassStabilizer *twoPassStabilizer = new TwoPassStabilizer();
twoPassStabilizer->setEstimateTrimRatio(est_trim);
twoPassStabilizer->setMotionStabilizer(
makePtr<GaussianMotionFilter>(radius_pass));
stabilizer = twoPassStabilizer;
}
else
{
// with an one pass stabilizer
OnePassStabilizer *onePassStabilizer = new OnePassStabilizer();
onePassStabilizer->setMotionFilter(
makePtr<GaussianMotionFilter>(radius_pass));
stabilizer = onePassStabilizer;
}
// second, set up the parameters
int radius = 15;
double trim_ratio = 0.1;
bool incl_constr = false;
stabilizer->setFrameSource(srcVideo);
stabilizer->setMotionEstimator(motionEstBuilder);
stabilizer->setRadius(radius);
stabilizer->setTrimRatio(trim_ratio);
stabilizer->setCorrectionForInclusion(incl_constr);
stabilizer->setBorderMode(BORDER_REPLICATE);
// cast stabilizer to simple frame source interface to read stabilized frames
stabFrames.reset(dynamic_cast<IFrameSource*>(stabilizer));
// 4-videoOutput the stabilized frames. The results are showed and saved.
videoOutput(stabFrames, outputPath);
}
catch (const exception &e)
{
cout << "error: " << e.what() << endl;
stabFrames.release();
}
}
int main(int argc, char* argv[])
{
Ptr<IFrameSource> stabFrames;
// 输入输出视频准备
cacStabVideo(stabFrames, inputPath);
stabFrames.release();
return 0;
}
文章浏览阅读601次。今天有空再度学习Struts1.3.9的源码,感觉对org.apache.commons.digester.Digester的认识还很少,上网看了一篇文章讲的比较好,特此转载! 文章出处:http://www.onjava.com/pub/a/onjava/2002/10/23/digester.html?page=1 文章中的案例解释: //生成一个digester。主要
文章浏览阅读370次。自己封装的文件服务苹果手机无法播放视频
文章浏览阅读987次。1. shenyue2题目分析这是一道RSA相关的密码学题目,给出了RSA相关的公钥(n,e)(n,e)(n,e),并且给出了额外的两个参数:一个已知素数rrr以及kkk,并且有如下关系: k=(p−r)dk=(p−r)dk=(p-r)d 其实这是一道2018 CodeGate CTF 的原题,直接按照CTF-WIKI中介绍的解法就可以求出来。而我写这篇文章的目的是向大家介绍另外一种方法,..._ctf shenyue2
文章浏览阅读1k次,点赞20次,收藏20次。先根据node版本先锁定node-sass版本 然后再来回切换sass-loader版本 这玩应你就试吧 一试一个一个不吱声_node-sass 升级
文章浏览阅读6.7k次。这种问题是因为sheet名称有问题,一般是名字两边有空格?解决:新建一个sheet,然后查看代码,输进去这些,一运行就出来了Sub listSheetName()i = 1For Each sSheet In Application.SheetsCells(i, 1).Value = sSheet.Namei = i + 1NextsSheetEndSub获取到所有..._valueerror: value does not match pattern ^[$]?([a-za-z]{1,3})[$]?(\d+)(:[$]?
文章浏览阅读1k次,点赞2次,收藏2次。pthread库不是Linux系统默认的库,连接时需要使用库libpthread.a,在编译中要加-lpthreadgcc xxx.c.pp -lpthread 针对直接编译的target_link_libraries(thread libpthread.so) 针对cmake的这里thread是我的二进制文件..._linux 中pthread_create()未定义
文章浏览阅读1.6k次,点赞2次,收藏8次。用Qt实现TCP服务器与客户端的信息收发_qt tcpserver
文章浏览阅读1.1k次。一、前言最近需要统计一张hbase表的条数,网上的很多案例都是使用MR的方式来进行统计,所以我们也采用这个方式。但是在实施过程中,遇到一些问题。使用MR去统计时,如果不指定队列,那么就会使用默认的YARN队列,而我们的默认队列是完全没有资源的。网上关于指定YARN队列的文章也比较少,这里整理并记录一下。二、准备这里我们使用 hbase.RowCounter包执行MR的任务。[hbase@bi-hadoop02 ~]$ hbase org.apache.hadoop.hbase.mapreduce_org.apache.hadoop.hbase.mapreduce.rowcounter 增加参数
文章浏览阅读1.8k次。FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:org.apache.hadoop.hbase.client.RetriesExhaustedException: Can't get the locations at org.apache.hadoop.hbase.client.RpcRetryingCallerWithReadReplicas_failed: execution error, return code 1 from org.apache.hadoop.hive.ql.exec.d
文章浏览阅读518次,点赞6次,收藏10次。在数据库管理工具的选择上,使用了Navicat 11,这是一个用户友好且功能强大的数据库管理软件,它支持多种数据库系统,包括MySQL,并提供了图形化界面,使得数据库的管理和维护工作更加便捷。开发环境方面,我们选择了PyCharm作为主要的集成开发环境(IDE),它提供了丰富的Python开发工具和插件,支持Django框架,有助于提高开发效率和代码质量。此外,系统还可以记录操作人员的操作记录,便于追踪和审计。提高物资利用率:通过对医用物资的有效管理,可以避免物资的浪费和积压,提高物资利用率。
文章浏览阅读1.8w次,点赞3次,收藏7次。WIN10 LSTC 2019 安装新版Mircosoft Edge浏览器,解决无法安装问题自己的笔记本一直使用WIN10 2019 LSTC(MSDN下载的)这一版本,因为这一版本真的太轻快简洁了,最近换电脑也是安装的Win10 LSTC 2019,但是安装完毕后在安装新版edge浏览器的时候提示系统版本低安装不了,自己的旧电脑就是LSTC却安装上,不知道什么原因,后来回想了一下旧电脑的使用过程并对新旧电脑的系统做了详细对比,发现是旧电脑上的系统补丁包版本高,而新电脑是刚安装的系统,补丁包还没有过升级_ltsc安装不了edge
文章浏览阅读784次,点赞11次,收藏10次。ADI前些年推出的ADALM-PLUTO SDR设备由于其轻便灵活的特点,外加价格相比于专业无线电相当实惠,受到了很多开源社区的欢迎,也诞生了许多的应用,如跟踪GPS、伪造GPS实现硬件级虚拟定位、电子钥匙重发攻击等(这些实际上HackRF做的更多)。同时对于学习通信的师生和对无线电感兴趣的业余玩家,也是个很不错的选择。国内购买纯原版Pluto SDR有些困难,但好在国内也有很多企业或团队基于某些成熟的SDR平台衍生出的性能更强,适用固件更多的软件无线电平台,价格也并非难以承受。_gnuradio 3.8.2 如何支持adalm pluto-sdr windows