Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

SIGSEGV in flann getNeighbors function

ok since this is a runtime error I am going to upload the entire qt project, which isn't that large yet, just too large to copy paste. I will also paste the partial backtrace. It is happening with one file so far, but it is the largest file. I will post a link to the file as well.

video: https://www.dropbox.com/s/e8hzpir7udph9lx/Geoengineering%201%20hour%20vid.m4v?dl=0 project: https://www.dropbox.com/s/uyz0p4zck3ploy0/VideoTwin.zip?dl=0

and here is the backtrace. I just have no idea what could be causing this, as it works for other videos

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x1e37 of process 1491]
0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
(gdb) backtrace
#0  0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#1  0x00000001013bdc49 in cvflann::LshIndex<cvflann::HammingLUT>::knnSearch(cvflann::Matrix<unsigned char> const&, cvflann::Matrix<int>&, cvflann::Matrix<int>&, int, cvflann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#2  0x00000001013e0d1a in void cv::flann::runKnnSearch_<cvflann::HammingLUT, cvflann::Index<cvflann::HammingLUT> >(void*, cv::Mat const&, cv::Mat&, cv::Mat&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#3  0x00000001013b4b1a in cv::flann::Index::knnSearch(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#4  0x0000000100016334 in MainWindow::findDupes (this=0x7fff5fbff788, frame=...)
    at ../VideoTwin/mainwindow.cpp:318
#5  0x000000010001aff7 in MainWindow::on_scanwatcher_finished()::AddWrapper::operator()(MainWindow::frm&) (this=0x10641e678, data=...) at ../VideoTwin/mainwindow.cpp:298
#6  0x000000010001ae46 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIteration(QList<MainWindow::frm>::iterator, int, void*) (
    this=0x10641e640, it=...)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:63
#7  0x000000010001aed9 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIterations(QList<MainWindow::frm>::iterator, int, int, void*) (this=0x10641e640, sequenceBeginIterator=..., beginIndex=6, endIndex=7)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:72
#8  0x000000010002545a in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::forThreadFunction() ()
#9  0x0000000100024f97 in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
#10 0x0000000100025072 in virtual thunk to QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
---Type <return> to continue, or q <return> to quit---kill
#11 0x00000001045b94ac in QtConcurrent::ThreadEngineBase::run() ()
   from /usr/local/opt/qt5/lib/QtConcurrent.framework/Versions/5/QtConcurrent
#12 0x0000000103faa737 in QThreadPoolThread::run() ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#13 0x0000000103fadc02 in QThreadPrivate::start(void*) ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#14 0x00007fffa037cc13 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#15 0x0000000000014c13 in ?? ()
#16 0x00007000003a6000 in ?? ()
#17 0x00007000003a5f50 in ?? ()
#18 0x00007fffa037cb90 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#19 0x0000000000000000 in ?? ()

SIGSEGV in flann getNeighbors function

ok since this is a runtime error I am going to upload the entire qt project, which isn't that large yet, just too large to copy paste. I will also paste the partial backtrace. It is happening with one file so far, but it is the largest file. I will post a link to the file as well.

video: https://www.dropbox.com/s/e8hzpir7udph9lx/Geoengineering%201%20hour%20vid.m4v?dl=0 project: https://www.dropbox.com/s/uyz0p4zck3ploy0/VideoTwin.zip?dl=0

and here is the backtrace. I just have no idea what could be causing this, as it works for other videos

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x1e37 of process 1491]
0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
(gdb) backtrace
#0  0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#1  0x00000001013bdc49 in cvflann::LshIndex<cvflann::HammingLUT>::knnSearch(cvflann::Matrix<unsigned char> const&, cvflann::Matrix<int>&, cvflann::Matrix<int>&, int, cvflann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#2  0x00000001013e0d1a in void cv::flann::runKnnSearch_<cvflann::HammingLUT, cvflann::Index<cvflann::HammingLUT> >(void*, cv::Mat const&, cv::Mat&, cv::Mat&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#3  0x00000001013b4b1a in cv::flann::Index::knnSearch(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#4  0x0000000100016334 in MainWindow::findDupes (this=0x7fff5fbff788, frame=...)
    at ../VideoTwin/mainwindow.cpp:318
#5  0x000000010001aff7 in MainWindow::on_scanwatcher_finished()::AddWrapper::operator()(MainWindow::frm&) (this=0x10641e678, data=...) at ../VideoTwin/mainwindow.cpp:298
#6  0x000000010001ae46 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIteration(QList<MainWindow::frm>::iterator, int, void*) (
    this=0x10641e640, it=...)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:63
#7  0x000000010001aed9 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIterations(QList<MainWindow::frm>::iterator, int, int, void*) (this=0x10641e640, sequenceBeginIterator=..., beginIndex=6, endIndex=7)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:72
#8  0x000000010002545a in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::forThreadFunction() ()
#9  0x0000000100024f97 in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
#10 0x0000000100025072 in virtual thunk to QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
---Type <return> to continue, or q <return> to quit---kill
#11 0x00000001045b94ac in QtConcurrent::ThreadEngineBase::run() ()
   from /usr/local/opt/qt5/lib/QtConcurrent.framework/Versions/5/QtConcurrent
#12 0x0000000103faa737 in QThreadPoolThread::run() ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#13 0x0000000103fadc02 in QThreadPrivate::start(void*) ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#14 0x00007fffa037cc13 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#15 0x0000000000014c13 in ?? ()
#16 0x00007000003a6000 in ?? ()
#17 0x00007000003a5f50 in ?? ()
#18 0x00007fffa037cb90 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#19 0x0000000000000000 in ?? ()

EDIT: here is how I build the index

    stage = 1;
    clock_t start, stop;
    float elapsed;
    Mat indexTemp;
    string buffer;
    statuslabel.setText("Loading computed frames");
    indexBuilder = QSqlQuery(db);
    if ( !indexBuilder.exec("SELECT * FROM frames"))
        qDebug() << "couldn't read frames table" << indexBuilder.lastError();
    start = clock();
    indexBuilder.last();
    int row_count = indexBuilder.at() + 1;
    indexBuilder.first();
    progress->setMaximum(row_count);
    int iterations = 1;
    while (true)
    {
        buffer = indexBuilder.value("descriptors").toString().toStdString();
        Mat mat;
        Mat matonerow;
        FileStorage fs(buffer,FileStorage::READ | FileStorage::MEMORY | FileStorage::FORMAT_YAML);
        fs["descriptors"] >> mat;
        fs.release();
        frm tmp;
        try
        {
            mat.copyTo(tmp.descriptors);
        }
        catch (Exception e)
        {
            qWarning() << "problem copyting mat to frm" << e.err.c_str() << e.msg.c_str();
        }

        tmp.file = indexBuilder.value("file").toString();
        tmp.position = indexBuilder.value("position").toInt();
        frames.append(tmp);
        try
        {
            if (mat.rows < 500)
                mat.push_back(Mat::zeros((500 - mat.rows),32,CV_8U));
            matonerow = mat.reshape(1,1);
        }
        catch (Exception e)
        {
            qDebug() << "problem creating zeros Mat";
        }
//        qDebug() << "matonerow cols" << matonerow.cols << "rows" << matonerow.rows;
//        indexTemp.push_back(matonerow);
        try
        {
            indexTemp.push_back(matonerow);
        }
        catch (Exception e)
        {
            qCritical() << "failed to copy row of Mat at loop" << iterations << e.err.c_str() << e.msg.c_str();
        }

        progress->setValue(iterations);
        iterations++;
        if (!indexBuilder.next())
            break;
    }
    stop = clock();
    elapsed = stop - start;
    qDebug() << "finished. Time elapsed: " << QString::number(elapsed / CLOCKS_PER_SEC) << "seconds";
    qDebug() << "loaded" << iterations << "frames into array";
    start = clock();
    statuslabel.setText("Building index of frames");
    progress->setMaximum(0);
    try
    {
        index.build(indexTemp,cv::flann::LshIndexParams(20,10,2), cvflann::FLANN_DIST_HAMMING);
    }
    catch (Exception e)
    {
        qWarning() << "problem building index";
    }

    stop = clock();
    elapsed = stop - start;
    qDebug() << "built index in" << elapsed / CLOCKS_PER_SEC << "seconds";
    struct AddWrapper {
      MainWindow *instance;
      AddWrapper(MainWindow *w): instance(w) {}
      void operator()(frm & data) {
        instance->findDupes(data);
      }
    };
    AddWrapper fdupes(this);
    statuslabel.setText("Scanning for duplicate videos");
    dupescan = QtConcurrent::map(frames, fdupes );
    dupewatcher.setFuture(dupescan);

here is how I search the index

QString file = frame.file;
Mat mat = frame.descriptors;
Mat indices;
Mat dists;
QTime timestamp(0,0,0,0);
timestamp = timestamp.addMSecs(frame.position);
try
{
    mat = mat.reshape(1,1);
    index.knnSearch(mat,indices,dists,3);
}
catch (Exception e)
{
    qWarning() << "index search failure" << e.err.c_str() << e.msg.c_str();
}
catch (exception& e)
{
    qWarning() << "index search failure" << e.what();
}

for (int i = 0; i < indices.rows; i++ )
{
    QTime matchtime(0,0,0,0);
    int matchms = frames.at( indices.at<int>(i,0)).position;
    matchtime = matchtime.addMSecs(matchms);
    int temp = dists.at<int>(i,1) - dists.at<int>(i,0);
    qDebug() << "frame"<<  timestamp.toString("hh:mm:ss") << "match at" << matchtime.toString("hh:mm:ss") << indices.at<int>(i,1) << indices.at<int>(i,2) << "distance" << temp;
}

SIGSEGV in flann getNeighbors function

UPDATE: got it working great now, I had to make the index data global and pad the query descriptors to match the index cols. Thanks all for the help

ok since this is a runtime error I am going to upload the entire qt project, which isn't that large yet, just too large to copy paste. I will also paste the partial backtrace. It is happening with one file so far, but it is the largest file. I will post a link to the file as well.

video: https://www.dropbox.com/s/e8hzpir7udph9lx/Geoengineering%201%20hour%20vid.m4v?dl=0 project: https://www.dropbox.com/s/uyz0p4zck3ploy0/VideoTwin.zip?dl=0

and here is the backtrace. I just have no idea what could be causing this, as it works for other videos

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x1e37 of process 1491]
0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
(gdb) backtrace
#0  0x00000001013c02df in cvflann::LshIndex<cvflann::HammingLUT>::getNeighbors(unsigned char const*, cvflann::ResultSet<int>&) () from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#1  0x00000001013bdc49 in cvflann::LshIndex<cvflann::HammingLUT>::knnSearch(cvflann::Matrix<unsigned char> const&, cvflann::Matrix<int>&, cvflann::Matrix<int>&, int, cvflann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#2  0x00000001013e0d1a in void cv::flann::runKnnSearch_<cvflann::HammingLUT, cvflann::Index<cvflann::HammingLUT> >(void*, cv::Mat const&, cv::Mat&, cv::Mat&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#3  0x00000001013b4b1a in cv::flann::Index::knnSearch(cv::_InputArray const&, cv::_OutputArray const&, cv::_OutputArray const&, int, cv::flann::SearchParams const&) ()
   from /usr/local/opt/opencv3/lib/libopencv_flann.3.1.dylib
#4  0x0000000100016334 in MainWindow::findDupes (this=0x7fff5fbff788, frame=...)
    at ../VideoTwin/mainwindow.cpp:318
#5  0x000000010001aff7 in MainWindow::on_scanwatcher_finished()::AddWrapper::operator()(MainWindow::frm&) (this=0x10641e678, data=...) at ../VideoTwin/mainwindow.cpp:298
#6  0x000000010001ae46 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIteration(QList<MainWindow::frm>::iterator, int, void*) (
    this=0x10641e640, it=...)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:63
#7  0x000000010001aed9 in QtConcurrent::MapKernel<QList<MainWindow::frm>::iterator, MainWindow::on_scanwatcher_finished()::AddWrapper>::runIterations(QList<MainWindow::frm>::iterator, int, int, void*) (this=0x10641e640, sequenceBeginIterator=..., beginIndex=6, endIndex=7)
    at /usr/local/Cellar/qt5/5.5.1_2/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:72
#8  0x000000010002545a in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::forThreadFunction() ()
#9  0x0000000100024f97 in QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
#10 0x0000000100025072 in virtual thunk to QtConcurrent::IterateKernel<QList<MainWindow::frm>::iterator, void>::threadFunction() ()
---Type <return> to continue, or q <return> to quit---kill
#11 0x00000001045b94ac in QtConcurrent::ThreadEngineBase::run() ()
   from /usr/local/opt/qt5/lib/QtConcurrent.framework/Versions/5/QtConcurrent
#12 0x0000000103faa737 in QThreadPoolThread::run() ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#13 0x0000000103fadc02 in QThreadPrivate::start(void*) ()
   from /usr/local/opt/qt5/lib/QtCore.framework/Versions/5/QtCore
#14 0x00007fffa037cc13 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#15 0x0000000000014c13 in ?? ()
#16 0x00007000003a6000 in ?? ()
#17 0x00007000003a5f50 in ?? ()
#18 0x00007fffa037cb90 in __FunctionTableTransposed_AVX10 ()
   from /usr/lib/system/libsystem_pthread.dylib
#19 0x0000000000000000 in ?? ()

EDIT: here is how I build the index

    stage = 1;
    clock_t start, stop;
    float elapsed;
    Mat indexTemp;
    string buffer;
    statuslabel.setText("Loading computed frames");
    indexBuilder = QSqlQuery(db);
    if ( !indexBuilder.exec("SELECT * FROM frames"))
        qDebug() << "couldn't read frames table" << indexBuilder.lastError();
    start = clock();
    indexBuilder.last();
    int row_count = indexBuilder.at() + 1;
    indexBuilder.first();
    progress->setMaximum(row_count);
    int iterations = 1;
    while (true)
    {
        buffer = indexBuilder.value("descriptors").toString().toStdString();
        Mat mat;
        Mat matonerow;
        FileStorage fs(buffer,FileStorage::READ | FileStorage::MEMORY | FileStorage::FORMAT_YAML);
        fs["descriptors"] >> mat;
        fs.release();
        frm tmp;
        try
        {
            mat.copyTo(tmp.descriptors);
        }
        catch (Exception e)
        {
            qWarning() << "problem copyting mat to frm" << e.err.c_str() << e.msg.c_str();
        }

        tmp.file = indexBuilder.value("file").toString();
        tmp.position = indexBuilder.value("position").toInt();
        frames.append(tmp);
        try
        {
            if (mat.rows < 500)
                mat.push_back(Mat::zeros((500 - mat.rows),32,CV_8U));
            matonerow = mat.reshape(1,1);
        }
        catch (Exception e)
        {
            qDebug() << "problem creating zeros Mat";
        }
//        qDebug() << "matonerow cols" << matonerow.cols << "rows" << matonerow.rows;
//        indexTemp.push_back(matonerow);
        try
        {
            indexTemp.push_back(matonerow);
        }
        catch (Exception e)
        {
            qCritical() << "failed to copy row of Mat at loop" << iterations << e.err.c_str() << e.msg.c_str();
        }

        progress->setValue(iterations);
        iterations++;
        if (!indexBuilder.next())
            break;
    }
    stop = clock();
    elapsed = stop - start;
    qDebug() << "finished. Time elapsed: " << QString::number(elapsed / CLOCKS_PER_SEC) << "seconds";
    qDebug() << "loaded" << iterations << "frames into array";
    start = clock();
    statuslabel.setText("Building index of frames");
    progress->setMaximum(0);
    try
    {
        index.build(indexTemp,cv::flann::LshIndexParams(20,10,2), cvflann::FLANN_DIST_HAMMING);
    }
    catch (Exception e)
    {
        qWarning() << "problem building index";
    }

    stop = clock();
    elapsed = stop - start;
    qDebug() << "built index in" << elapsed / CLOCKS_PER_SEC << "seconds";
    struct AddWrapper {
      MainWindow *instance;
      AddWrapper(MainWindow *w): instance(w) {}
      void operator()(frm & data) {
        instance->findDupes(data);
      }
    };
    AddWrapper fdupes(this);
    statuslabel.setText("Scanning for duplicate videos");
    dupescan = QtConcurrent::map(frames, fdupes );
    dupewatcher.setFuture(dupescan);

here is how I search the index

QString file = frame.file;
Mat mat = frame.descriptors;
Mat indices;
Mat dists;
QTime timestamp(0,0,0,0);
timestamp = timestamp.addMSecs(frame.position);
try
{
    mat = mat.reshape(1,1);
    index.knnSearch(mat,indices,dists,3);
}
catch (Exception e)
{
    qWarning() << "index search failure" << e.err.c_str() << e.msg.c_str();
}
catch (exception& e)
{
    qWarning() << "index search failure" << e.what();
}

for (int i = 0; i < indices.rows; i++ )
{
    QTime matchtime(0,0,0,0);
    int matchms = frames.at( indices.at<int>(i,0)).position;
    matchtime = matchtime.addMSecs(matchms);
    int temp = dists.at<int>(i,1) - dists.at<int>(i,0);
    qDebug() << "frame"<<  timestamp.toString("hh:mm:ss") << "match at" << matchtime.toString("hh:mm:ss") << indices.at<int>(i,1) << indices.at<int>(i,2) << "distance" << temp;
}