如何使用OpenCV查找帧之间的差异?

编程入门 行业动态 更新时间:2024-10-27 15:25:23
本文介绍了如何使用OpenCV查找帧之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在OpenCV上运行视频时,如何找到帧之间的差异?我需要做一个循环,检查逐帧的变化并在另一个窗口中显示结果吗? 我可以在这里附加的循环中执行此操作吗?还是有另一种方法可以做到?

How can I find the differences between frames when I'm running video on OpenCV? I need to do a loop that checks the changes from frame to frame and displays the result in another window? Can I do it in the loop that i attach here? Or is there another way to do it?

while( key != 'x' ) { frame = cvQueryFrame( capture ); cvCvtColor(frame, gray, CV_RGB2GRAY); //gray_frame = cvQueryFrame( capture ); //cvCvtColor(frame, gray_frame, CV_BGR2GRAY); if(key==27) break; cvShowImage( "video",frame ); cvShowImage( "grayvideo",gray ); key = cvWaitKey( 1000 / fps ); } cvDestroyWindow( "video" ); cvDestroyWindow( "grayvideo" ); cvReleaseCapture( &capture ); return 0;

我在命令窗口中收到此错误:编译器未对齐堆栈变量. Libavcodec编译错误 可能会非常慢或崩溃.这不是libavcodec中的错误, 但在编译器中.您可以尝试使用gcc> = 4.2重新编译. 不要向FFmpeg开发人员报告崩溃. OpenCV错误:断言失败(src1.size()== dst.size()&& src1.type()== dst. type())在未知函数中,文件........ \ ocv \ opencv \ src \ cxcore \ cxarithm.cpp ,第1563行

i get this error on the command window:Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers. OpenCV Error: Assertion failed (src1.size() == dst.size() && src1.type() == dst. type()) in unknown function, file ........\ocv\opencv\src\cxcore\cxarithm.cpp , line 1563

深度的大小的玛比错了吗? 我该如何解决?还是maby代码有问题? 非常感谢您的帮助

what is wrong maby the maby the size of depth? how can i fix it? or maby something wrong with the code? thanks a lot for your help

推荐答案

您可以减去两个Mat对象/指针.

You can subtract the two Mat objects/pointers.

Mat prev_frame; cap.read(prev_frame); while (1) { Mat frame; cap.read(frame); Mat dif = frame - prev_frame; imshow("difference", dif); // you can also use absdiff //absdiff(frame, prev_frame, dif); prev_frame = frame.clone(); }

更多推荐

如何使用OpenCV查找帧之间的差异?

本文发布于:2023-10-19 19:08:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1508489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   差异   OpenCV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!