C++11 如何使用QPushButton和OpenCV::imwrite以增量方式保存QGraphicsView上加载的图像
我在图1中准备了这个小型的可验证的.ui,它复制了我的问题: 我尝试使用QPushButton打印屏幕将两个图像以增量方式保存在QGraphicsView左侧和右侧的图像到我桌面上的两个不同文件夹中,请参见下图2: 我只需点击相关的QPushButton print screen Left和print screen Right,就可以获得leftScene或rightScene的打印屏幕 但是,在这种特定情况下,我尝试不使用QFileDialog,因为我需要在使用右/左箭头前进时,以静默和增量方式将图像保存在两个不同的目标文件夹中 请参见下面我正在使用的代码片段: 主窗口 mainwindow.cpp 我在代码中遗漏了一些东西,但我不确定具体是什么 编译器正在处理我不理解的分配/取消分配错误:C++11 如何使用QPushButton和OpenCV::imwrite以增量方式保存QGraphicsView上加载的图像,c++11,qt5,opencv3.0,qgraphicsview,qgraphicsscene,C++11,Qt5,Opencv3.0,Qgraphicsview,Qgraphicsscene,我在图1中准备了这个小型的可验证的.ui,它复制了我的问题: 我尝试使用QPushButton打印屏幕将两个图像以增量方式保存在QGraphicsView左侧和右侧的图像到我桌面上的两个不同文件夹中,请参见下图2: 我只需点击相关的QPushButton print screen Left和print screen Right,就可以获得leftScene或rightScene的打印屏幕 但是,在这种特定情况下,我尝试不使用QFileDialog,因为我需要在使用右/左箭头前进时,以静默和增量方
请说明这件事 它需要将OpenCV库添加到Qt项目中
这是链接器错误。将opencv添加到qt项目文件或CMake.Hi Nuzhny中的LIBS中,感谢您的评论。请你写几行代码,这样我就可以把你的答案标记为正确了我的意思是:没错,如果你能在这里添加代码行,我会将你的答案标记为正确,因为编译器现在正在工作
public:
void bothPrintScreen(const std::string& pathImg);
private slots:
void on_bothPrintScreen_clicked(const std::string& imgPath);
private:
int counterA=0;
int counterB=0;
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);
}
INCLUDEPATH += -I/usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_stitching -lopencv_superres ...and another libraries