sinat_34628809 2016-05-11 04:02 采纳率: 0%
浏览 1024
已结题

SURF+视频帧判断 总是崩溃

想用SURF特征点来检测视频两帧间的差别,进而判断出场景转变的位置,可是每次到转场帧的时候就崩溃

附上代码 谢谢各位了!

//---------------------------------【头文件、命名空间包含部分】----------------------------
// 描述:包含程序所使用的头文件和命名空间
//------------------------------------------------------------------------------------------------
#include
#include
#include
#include
#include
using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
int framecount=1 ;
//【1】载入源图片
Mat img_1 ,img_2 ;
VideoCapture capture ("F:\VS项目库\网上下载的镜头分割程序\TEST\TEST\333.avi") ;

capture>>img_1 ;

    //【2】利用SURF检测器检测的关键点
int minHessian = 700;
SurfFeatureDetector detector( minHessian );
SurfFeatureDetector(SURF);
vector<KeyPoint> keypoints_1, keypoints_2;
detector.detect( img_1, keypoints_1 );

    //【3】计算描述符(特征向量)
SurfDescriptorExtractor extractor ;
Mat descriptors_1, descriptors_2;
extractor.compute( img_1, keypoints_1, descriptors_1 );



while(1)
{


capture>>img_2 ;
imshow("原图",img_2) ;
waitKey(30) ;

detector.detect( img_2, keypoints_2 );
extractor.compute( img_2, keypoints_2, descriptors_2 );

//实例化一个匹配器
BruteForceMatcher< L2<float> >matcher ;
vector<DMatch>matches ;
matcher.match(descriptors_1 ,descriptors_2 ,matches)  ;

int num = matches.size();
if(num<10)
    cout <<framecount <<endl ;
if(num>0)
descriptors_1=descriptors_2 ;


//img_1 = img_2 ;
framecount++ ;


}
waitKey(0);
return 0;

}

币不多 新手望见谅 谢谢!!

  • 写回答

1条回答 默认 最新

  • 普通网友 2016-10-07 17:23
    关注

    征点来检测视频两帧间的差别,进而判断出场景转变的位置,可是每次到转场帧的时候就崩溃
    附上代码 谢谢各位了!
    //---------------------------------【头文件、命名空间包含部分】----------------------------
    // 描述:包含程序所使用的头文件和命名空间
    //------------------------------------------------------------------------------------------------
    #include
    #include
    #include
    #include
    #include
    using namespace cv;
    using namespace std;
    int main( int argc, char** argv )
    {
    int framecount=1 ;
    //【1】载入源图片
    Mat img_1 ,img_2 ;
    VideoCapture capture ("F:\VS项目库\网上下载的镜头分割程序\TEST\TEST\333.avi") ;
    capture>>img_1 ;

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建