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 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题