![](/img/trans.png)
[英]Visual C++ Library for converting set of images to a video without using Opencv
[英]Saving video as series of images opencv
這個問題是針對運動檢測的opencv代碼錯誤的繼續。 編輯后的代碼可以正常工作,但是不會創建輸出視頻,它的字節數為零!這是怎么回事?此外,為運動檢測而創建的邊界框永遠不會真正捕獲運動,即不會執行任何操作我原本聲稱是這樣做的,我對代碼目標有誤解嗎?
這是可用於將視頻框為一組圖像的代碼。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "cv.h"
#include <highgui.h>
#include "cxcore.h"
int main( int argc, char** argv )
{
CvCapture *capture = cvCaptureFromAVI("E:\\Myvideo.avi");
if(!capture)
{
printf("!!! cvCaptureFromAVI failed (file not found?)\n");
return -1;
}
int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
printf("* FPS: %d\n", fps);
IplImage* frame = NULL;
int frame_number = 0;
char key = 0;
while (key != 'q')
{
// get frame
frame = cvQueryFrame(capture);
if (!frame)
{
printf("!!! cvQueryFrame failed: no frame\n");
break;
}
// quit when user press 'q'
key = cvWaitKey(1000 / fps);
}
// free resources
cvReleaseCapture(&capture);
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.