Video streaming with opencv 2.4.7 on visual studio 2010
Hi all :) I tried to load tree.avi file present in sample code of opencv 2.4.7 on visual studio 2010 express edition. I used following code :
#include<opencv\highgui.h>
#include<stdio.h>
#include<opencv\cv.h>
#include<conio.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main()
{
CvCapture* capture = cvCreateFileCapture("C:\opencv247\samples\c\tree.avi");
IplImage* frame = NULL;
if(!capture)
{
printf("Video Not Opened\n");
return -1;
}
int width = (int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH);
int height = (int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT);
double fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
int frame_count = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT);
printf("Video Size = %d x %d\n",width,height);
printf("FPS = %f\nTotal Frames = %d\n",fps,frame_count);
while(1)
{
frame = cvQueryFrame(capture);
if(!frame)
{
printf("Capture Finished\n");
break;
}
cvShowImage("video",frame);
cvWaitKey(10);
}
cvReleaseCapture(&capture);
return 0;
}
I am getting following result after I debug the above code and thus video is not opening :
'OPEN_CV_TEST.exe': Loaded 'C:\Users\Shivam\Documents\Visual Studio 2010\Projects\OPEN_CV_TEST\Debug\OPEN_CV_TEST.exe', Symbols loaded.
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\opencv247\build\x86\vc10\bin\opencv_highgui247d.dll', Cannot find or open the PDB file
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\user32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\gdi32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\lpk.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\usp10.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\ole32.dll', Symbols loaded.
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\advapi32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\sechost.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\opencv247\build\x86\vc10\bin\opencv_core247d.dll', Cannot find or open the PDB file
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\comctl32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\avifil32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\winmm.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\msacm32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\msvfw32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\shell32.dll', Symbols loaded (source information stripped).
'OPEN_CV_TEST.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Symbols loaded ...
.... and the problem is ... ?
"C:\opencv247\samples\c\tree.avi" should be :
"C:/opencv247/samples/c/tree.avi" or "C:\\opencv247\\samples\\c\\tree.avi"
(use forward slashes or 2 backslashes in filenames. )
Some remarks: 1) please use proper formatting, there are code formatting options available (did for you now) 2) please quit the c samples and move to the cpp samples, the interface is much easier to understand for new users 3) as @berak said, use forward slashes or double backslashes. A single backslash is an escape character, which will result into a unexisting filename.
@berak and @StevenPuttemans still after using 2 backslashes it is showing same output as I mentioned above and thus as a result, video I am trying to load is not opening.
Please use the CPP interface and see if it works there :)
Ok. Will surely look at it. Thanks for the help :) @StevenPuttemans