0

I prepared this small verifiable .ui in Figure 1 that replicates the issue I have:

small example

I am trying to use the QPushButton "Print Screen Both Images" to incrementally save images on Left and Right of the QGraphicsView into two different folders present on my Desktop, see below Figure 2:

destination_folders

I can take a print screen of either the leftScene or the rightScene by just clicking on their related QPushButton Print Screen Left and Print Screen Right.

However, I am trying for this specific case not to use QFileDialog as I need to silently and incrementally save the images in the two different destination folders as I move on with the right/left arrow.

See below the snipped of code I am using:

mainwindow.h

public:
    void bothPrintScreen(const std::string& pathImg);
private slots:
    void on_bothPrintScreen_clicked(const std::string& imgPath);
private:
    int counterA=0;
    int counterB=0;

mainwindow.cpp

void MainWindow::on_bothPrintScreen_clicked(const std::string& imgPath)
{
    bothPrintScreen(imgPath);
}

void MainWindow::bothPrintScreen(const std::string& pathImg){
    cv::Mat left, right;
    std::string outA = pathImg+"/printScreenA_"+std::to_string(counterA++)+".png";
    cv::imwrite(outA,left);
    std::string outB = pathImg+"/printScreenB_"+std::to_string(counterB++)+".png";
    cv::imwrite(outB,right);
}

I am missing something in the code but I am not sure what exactly.

The compiler is seinding this allocate()/deallocate() error that I don't understand:

compiler_error

Please shed light on this matter.

Emanuele
  • 2,194
  • 6
  • 32
  • 71
  • It's linker errors. Add opencv to the LIBS in your qt project file or in CMake. – Nuzhny Mar 01 '19 at 10:40
  • Hi Nuzhny, thanks for the comment. Could you please put a couple of lines of code so that I can mark your answer as correct? :) – Emanuele Mar 01 '19 at 13:58
  • I mean this: https://stackoverflow.com/questions/47611221/add-opencv-library-to-every-qt-project – Nuzhny Mar 01 '19 at 14:00
  • Yes exactly, if you can add here that lines of code I will mark your answer as correct because the compiler is working now – Emanuele Mar 01 '19 at 14:08

1 Answers1

1

It need to add OpenCV libraries to the your Qt project (like this)

INCLUDEPATH += -I/usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_stitching -lopencv_superres ...and another libraries
Nuzhny
  • 1,869
  • 1
  • 7
  • 13