OpenCV applications using VS2010

I am struggling to get opencv set up using visual studio 2010. I am trying to follow guides and I feel like I am following them correctly, however the test projects still aren't running and I don't understand the errors due to the fact that I am new to opencv, c++, and vs2010.


Here are the tutorials ive tried:

the "installation using pre-built libaries" and "Set the OpenCV enviroment variable and add it to the systems path" sections -
http://opencv.itseez.com/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable

then in combination with the above
http://opencv.itseez.com/doc/tutorials/introduction/windows_visual_studio_Opencv/windows_visual_studio_Opencv.html#windows-visual-studio-how-to



and basically the same thing but by a different person:
http://www.deveature.com/2011/11/24/opencv-2-3-1-and-visual-studio-2010/




So I've followed those steps and am able to 'build solution correctly with the test code from either of the above examples, however when I try to debug either i get problems with opening or finding pdb files and the application seems to not run or not run properly.

here is the output when i try to debug the code:
'practice.exe': Loaded 'C:\Documents and Settings\Danny\My Documents\Visual Studio 2010\Projects\practice\Debug\practice.exe', Symbols loaded.
'practice.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_core231d.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded.
'practice.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
'practice.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_imgproc231d.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\opencv\build\common\tbb\bin\ia32\vc10\tbb_debug.dll', Symbols loaded.
'practice.exe': Loaded 'C:\opencv\build\x86\vc10\bin\opencv_highgui231d.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\user32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\avifil32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\msvfw32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\avicap32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\version.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\UmxSbxExw.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\UmxSbxw.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\Program Files\CA\CA Internet Security Suite\CA Anti-Spam\QSP-9.0.0.211\QOEHook.dll', Cannot find or open the PDB file
'practice.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0x850) has exited with code -1 (0xffffffff).
The program '[3900] practice.exe: Native' has exited with code -1 (0xffffffff).


If it helps this is what I have added to my environment variables

C:\opencv\build;
C:\opencv\build\x86\vc10\bin;
C:\Opencv\build\common\tbb\bin\ia32\vc10

and I have installed the OpenCV-2.3.1-win-superpack.exe from the following location: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/
placing the root folder (opencv) directly in the C:\ drive



If there is any other information you would like me to provide just inform me and I will do so as soon as possible.
Last edited on
I couldn't fit the code in the post with everything so I've added it here (note: its also on the second of the three links in the tutorials listed)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// Video Image PSNR and SSIM
#include <iostream> // for standard I/O
#include <string>   // for strings
#include <iomanip>  // for controlling float print precision
#include <sstream>  // string to number conversion
#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur
#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>  // OpenCV window I/O

using namespace std;
using namespace cv;

double getPSNR ( const Mat& I1, const Mat& I2);
Scalar getMSSIM( const Mat& I1, const Mat& I2);

void help()
{
    cout
        << "\n--------------------------------------------------------------------------" << endl
        << "This program shows how to read a video file with OpenCV. In addition, it tests the"
        << " similarity of two input videos first with PSNR, and for the frames below a PSNR "  << endl
        << "trigger value, also with MSSIM."<< endl
        << "Usage:"                                                                       << endl
        << "./video-source referenceVideo useCaseTestVideo PSNR_Trigger_Value Wait_Between_Frames " << endl
        << "--------------------------------------------------------------------------"   << endl
        << endl;
}
int main(int argc, char *argv[], char *window_name)
{
    help();
    if (argc != 5)
    {
        cout << "Not enough parameters" << endl;
        return -1;
    }
    stringstream conv;

    const string sourceReference = argv[1],sourceCompareWith = argv[2];
    int psnrTriggerValue, delay;
    conv << argv[3] << argv[4];       // put in the strings
    conv >> psnrTriggerValue >> delay;// take out the numbers

    char c;
    int frameNum = -1;          // Frame counter

    VideoCapture captRefrnc(sourceReference),
                 captUndTst(sourceCompareWith);

    if ( !captRefrnc.isOpened())
    {
        cout  << "Could not open reference " << sourceReference << endl;
        return -1;
    }

    if( !captUndTst.isOpened())
    {
        cout  << "Could not open case test " << sourceCompareWith << endl;
        return -1;
    }

    Size refS = Size((int) captRefrnc.get(CV_CAP_PROP_FRAME_WIDTH),
                     (int) captRefrnc.get(CV_CAP_PROP_FRAME_HEIGHT)),
         uTSi = Size((int) captUndTst.get(CV_CAP_PROP_FRAME_WIDTH),
                     (int) captUndTst.get(CV_CAP_PROP_FRAME_HEIGHT));

    if (refS != uTSi)
    {
        cout << "Inputs have different size!!! Closing." << endl;
        return -1;
    }

    const char* WIN_UT = "Under Test";
    const char* WIN_RF = "Reference";

    // Windows
            namedWindow(WIN_RF, CV_WINDOW_AUTOSIZE );
            namedWindow(WIN_UT, CV_WINDOW_AUTOSIZE );
            cvMoveWindow(WIN_RF, 400       ,            0);      //750,  2 (bernat =0)
            cvMoveWindow(WIN_UT, refS.width,            0);      //1500, 2

    cout << "Frame resolution: Width=" << refS.width << "  Height=" << refS.height
         << " of nr#: " << captRefrnc.get(CV_CAP_PROP_FRAME_COUNT) << endl;

    cout << "PSNR trigger value " <<
          setiosflags(ios::fixed) << setprecision(3) << psnrTriggerValue << endl;

    Mat frameReference, frameUnderTest;
    double psnrV;
    Scalar mssimV;

    while( true) //Show the image captured in the window and repeat
    {
        captRefrnc >> frameReference;
        captUndTst >> frameUnderTest;

        if( frameReference.empty()  || frameUnderTest.empty())
        {
            cout << " < < <  Game over!  > > > ";
            break;
        }

        ++frameNum;
        cout <<"Frame:" << frameNum;

        ///////////////////////////////// PSNR ////////////////////////////////////////////////////
        psnrV = getPSNR(frameReference,frameUnderTest);                 //get PSNR
        cout << setiosflags(ios::fixed) << setprecision(3) << psnrV << "dB";

        //////////////////////////////////// MSSIM /////////////////////////////////////////////////
        if (psnrV < psnrTriggerValue)
        {
            mssimV = getMSSIM(frameReference,frameUnderTest);

            cout << " MSSIM: "
                 << "R" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[2] * 100
                 << "G" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[1] * 100
                 << "B" << setiosflags(ios::fixed) << setprecision(3) << mssimV.val[0] * 100;
        }

       cout << endl;

        ////////////////////////////////// Show Image /////////////////////////////////////////////
        imshow( WIN_RF, frameReference);
        imshow( WIN_UT, frameUnderTest);

        c = cvWaitKey(delay);
        if (c == 27) break;
    }

    return 0;
}

double getPSNR(const Mat& I1, const Mat& I2)
{
    Mat s1;
    absdiff(I1, I2, s1);       // |I1 - I2|
    s1.convertTo(s1, CV_32F);  // cannot make a square on 8 bits
    s1 = s1.mul(s1);           // |I1 - I2|^2

    Scalar s = sum(s1);         // sum elements per channel

    double sse = s.val[0] + s.val[1] + s.val[2]; // sum channels

    if( sse <= 1e-10) // for small values return zero
        return 0;
    else
    {
        double  mse =sse /(double)(I1.channels() * I1.total());
        double psnr = 10.0*log10((255*255)/mse);
        return psnr;
    }
}

Scalar getMSSIM( const Mat& i1, const Mat& i2)
{
    const double C1 = 6.5025, C2 = 58.5225;
    /***************************** INITS **********************************/
    int d     = CV_32F;

    Mat I1, I2;
    i1.convertTo(I1, d);           // cannot calculate on one byte large values
    i2.convertTo(I2, d);

    Mat I2_2   = I2.mul(I2);        // I2^2
    Mat I1_2   = I1.mul(I1);        // I1^2
    Mat I1_I2  = I1.mul(I2);        // I1 * I2

    /*************************** END INITS **********************************/

    Mat mu1, mu2;   // PRELIMINARY COMPUTING
    GaussianBlur(I1, mu1, Size(11, 11), 1.5);
    GaussianBlur(I2, mu2, Size(11, 11), 1.5);

    Mat mu1_2   =   mu1.mul(mu1);
    Mat mu2_2   =   mu2.mul(mu2);
    Mat mu1_mu2 =   mu1.mul(mu2);

    Mat sigma1_2, sigma2_2, sigma12;

    GaussianBlur(I1_2, sigma1_2, Size(11, 11), 1.5);
    sigma1_2 -= mu1_2;

    GaussianBlur(I2_2, sigma2_2, Size(11, 11), 1.5);
    sigma2_2 -= mu2_2;

    GaussianBlur(I1_I2, sigma12, Size(11, 11), 1.5);
    sigma12 -= mu1_mu2;

    ///////////////////////////////// FORMULA ////////////////////////////////
    Mat t1, t2, t3;

    t1 = 2 * mu1_mu2 + C1;
    t2 = 2 * sigma12 + C2;
    t3 = t1.mul(t2);              // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))

    t1 = mu1_2 + mu2_2 + C1;
    t2 = sigma1_2 + sigma2_2 + C2;
    t1 = t1.mul(t2);               // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))

    Mat ssim_map;
    divide(t3, t1, ssim_map);      // ssim_map =  t3./t1;

    Scalar mssim = mean( ssim_map ); // mssim = average of ssim map
    return mssim;
}
Last edited on
here is my guide for you (i made it myself)

OpenCV 2.3.1 for Visual C++ 2010
http://www.mediafire.com/download.php?xgw7jdt24b4trjs

you can find the programs used in the tutorial by searching them (google)
Hi
i had tried your tutorial but it still not work.
here is my error message

"c:\opencv\build\include\opencv\cv.h(63): fatal error C1083: Cannot open include file: 'opencv2/core/core_c.h': No such file or directory"

###########################
opencv version 2.3.1
visual studio 2010 ultimate
win 7 32bits
###########################

any idea?
Last edited on
when are you getting the error (where are you in my tutorial)??
(sorry for the late reply, i will answer your next questions faster)
Last edited on
Topic archived. No new replies allowed.