Results 1 to 1 of 1

Thread: cvLoadImage & realloc(): invalid pointer

  1. #1
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cvLoadImage & realloc(): invalid pointer

    Hello,

    i'm trying to use QtCreator + opencv, i think i have everything well installed, in fact, y can run some smalls programs. I created a Qt project with a .ui where i placed a button, and when it's clicked it calls a function that does the following:

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. QFileDialog dialog(this);
    4. dialog.setDirectory(QDir::homePath());
    5. dialog.setFileMode(QFileDialog::ExistingFiles);
    6. QStringList fileNames;
    7. if (dialog.exec())
    8. fileNames = dialog.selectedFiles();
    9.  
    10. for (int i = 0; i < fileNames.size(); i++) {
    11. qDebug() << "file "+fileNames.at(i);
    12. }
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

    This works correctly, i can choose several files and it prints the names after on the console but.... i am trying to load each image as an IplImage like this:

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <stdlib.h>
    4. #include <stdio.h>
    5. #include <math.h>
    6. #include <cv.h>
    7. #include <highgui.h>
    8.  
    9. #include <QFileDialog>
    10. #include <QDebug>
    11. using namespace cv;
    12. using namespace std;
    13.  
    14. MainWindow::MainWindow(QWidget *parent) :
    15. QMainWindow(parent),
    16. ui(new Ui::MainWindow)
    17. {
    18. ui->setupUi(this);
    19. }
    20.  
    21. MainWindow::~MainWindow()
    22. {
    23. delete ui;
    24. }
    25.  
    26. void MainWindow::on_pushButton_clicked()
    27. {
    28. QFileDialog dialog(this);
    29. dialog.setDirectory(QDir::homePath());
    30. dialog.setFileMode(QFileDialog::ExistingFiles);
    31. QStringList fileNames;
    32. if (dialog.exec())
    33. fileNames = dialog.selectedFiles();
    34.  
    35. for (int i = 0; i < fileNames.size(); i++) {
    36. qDebug() << "file "+fileNames.at(i);
    37. IplImage* img = cvLoadImage("/home/cae/Descargas/lena.jpg");
    38.  
    39. }
    40.  
    41. }
    To copy to clipboard, switch view to plain text mode 

    and it doesn't work, it builds correctly, but when i run, i dont reach to see the gui, i recieve the following error:

    Qt Code:
    1. Starting /home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV...
    2. *** Error in `/home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV': realloc(): invalid pointer:] 0x00007f0b6faa8340 ***
    3. ======= Backtrace: =========
    4. /lib/x86_64-linux-gnu/libc.so.6(+0x7f576)[0x7f0b6ea08576]
    5. /lib/x86_64-linux-gnu/libc.so.6(realloc+0x300)[0x7f0b6ea0cda0]
    6. /home/cae/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QListData7reallocEi+0x26)[0x7f0b6f53be46]
    7. /home/cae/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN9QListData7prependEv+0x82)[0x7f0b6f53c012]
    8. /home/cae/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(_ZN10QTextCodecC1Ev+0x85)[0x7f0b6f6f5be5]
    9. /home/cae/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x2728b9)[0x7f0b6f6f98b9]
    10. /home/cae/Qt5.0.2/5.0.2/gcc_64/lib/libQt5Core.so.5(+0x272d0d)[0x7f0b6f6f9d0d]
    11. .
    12. .
    13. .
    14. ======= Memory map: ========
    15. 00400000-00407000 r-xp 00000000 08:05 541441 /home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV
    16. 00606000-00607000 r--p 00006000 08:05 541441 /home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV
    17. 00607000-00608000 rw-p 00007000 08:05 541441 /home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV
    18. 01331000-01352000 rw-p 00000000 00:00 0 [heap]
    19. 7f0b5fdb0000-7f0b5fdb3000 r-xp 00000000 08:05 1576774 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
    20. 7f0b5fdb3000-7f0b5ffb2000 ---p 00003000 08:05 1576774 /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
    21. .
    22. .
    23. .
    24.  
    25. The program has unexpectedly finished.
    26. /home/cae/code/computerVision/build-testCV-Desktop_Qt_5_0_2_GCC_64bit-Debug/testCV exited with code 0
    To copy to clipboard, switch view to plain text mode 



    My .pro file:

    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2013-06-10T22:34:06
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = testCV
    12. TEMPLATE = app
    13. CONFIG += console
    14.  
    15. SOURCES += main.cpp\
    16. mainwindow.cpp
    17.  
    18. HEADERS += mainwindow.h
    19.  
    20. FORMS += mainwindow.ui
    21.  
    22. INCLUDEPATH+=/home/cae/OpenCV-2.4.2/include/opencv
    23. LIBS += -L/usr/local/lib
    24. LIBS += -lopencv_core
    25. LIBS += -lopencv_imgproc
    26. LIBS += -lopencv_highgui
    27. LIBS += -lopencv_ml
    28. LIBS += -lopencv_video
    29. LIBS += -lopencv_features2d
    30. LIBS += -lopencv_calib3d
    31. LIBS += -lopencv_objdetect
    32. LIBS += -lopencv_contrib
    33. LIBS += -lopencv_legacy
    34. LIBS += -lopencv_flann
    35. LIBS += -lopencv_nonfree
    To copy to clipboard, switch view to plain text mode 

    i'm searching related errors to realloc(): invalid pointer & cvLoadImage, but i'm not able to find anything helpfull.... can you help me please?


    Added after 1 5 minutes:


    Sorry,

    apparently opencv was not well installed.... i reinstalled it and now it works.

    i followed this blog: http://opencvstart.blogspot.com.es/
    Last edited by cae; 29th August 2013 at 10:51.

Similar Threads

  1. realloc() and qRealloc problem
    By harmodrew in forum Newbie
    Replies: 1
    Last Post: 10th August 2010, 12:28
  2. deleting invalid pointer
    By hollowhead in forum General Programming
    Replies: 11
    Last Post: 30th April 2010, 10:47
  3. *** glibc detected ***: free(): invalid pointer
    By codebehind in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2008, 22:45
  4. realloc
    By mickey in forum General Programming
    Replies: 1
    Last Post: 4th May 2008, 19:59
  5. itemChange() glibc invalid pointer
    By dreamer in forum Qt Programming
    Replies: 2
    Last Post: 3rd May 2008, 09:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.