Ask Your Question

kulan's profile - activity

2014-01-30 03:18:43 -0600 received badge  Editor (source)
2014-01-30 03:01:52 -0600 asked a question Can't debug opencv libraries

emphasized text I've a question concerning debugging opencv code under Eclipse CDT plugin with using gnu gdb. I use windows 7 (64) + eclipse 4.3 (kepler) + cdt 8.2.1 + mingw w64 gcc 4.8.2 + gdb 7.6.1 + opencv 2.4.8. I try to debug very simple code:

#include <iostream>
#include <string>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
    Mat frame1, frame2;
    VideoCapture camera1, camera2;

    camera1.open(0);
    if (!camera1.isOpened())
    {
        cout << "Failed to open camera 1" << endl;
        return -1;
    }
    namedWindow("Camera 1", CV_WINDOW_KEEPRATIO);

    camera2.open(1);
    if (!camera2.isOpened())
    {
        cout << "Failed to open camera 2" << endl;
        return -2;
    }
    namedWindow("Camera 2", CV_WINDOW_KEEPRATIO);

    while (true)
    {
        camera1 >> frame1;
        if (frame1.empty())
            break;

        camera2 >> frame2;
        if (frame2.empty())
            break;

        imshow("Camera 1", frame1);
        imshow("Camera 2", frame2);

        char key = (char) waitKey(5);
        switch (key)
        {
            case 'q':
            case 'Q':
            case 27: //escape key
                return 0;
            default:
                break;
        }
    }

    return 0;
}

This code work good but i wish to learn how to debug it. The problem is debugger can't go step in opencv non-inline functions. Previously I've compiled opencv debug version with -g -g3 flags. All work perfect except I can't do step in opencv functions located at cpp files. Thanks in advance for help.