Help With QtConcurrent:mappedReduce, "no matching function call to 'mappedReduce(..."
-
Hi,
I'm trying to do some parallel image processing using QtConcurrent and opencv. The basic idea of the process is to read in some rows or columns from images take, the mean if more than 1 row or column and then output the single resulting row/column. This is then reduced by stacking all the lines together to create an image. Now mappedreduce seems like the perfect way to do this concurrently, but I can't get it to compile. I'm getting errors about no matching function call for the main mappedReduce function and "couldn't deduce return type" errors within that. It would be a great help if someone could point out where I'm going wrong here. ThanksCall to start the process on run button clicked:
void MainWindow::runLinescanClicked() { this->updateImageRange(); imageRangeData* lsRangeData = this->parseImageRange(ui->linescanLineNumberLE->text()); bool vert = ui->linescanVertRB->isChecked(); QList<linescanData> images; for(int i=imageLow; i<= imageHigh; i++) { linescanData data; data.vert = vert; data.range = lsRangeData->range; data.rangeLow = lsRangeData->low; data.rangeHigh = lsRangeData->high; data.single = lsRangeData->single; data.imageFolder = ui->imageFolderLE->text(); data.imagePrefix = ui->imagePrefixLE->text(); data.imageNumber = i; data.imageNumberStart = imageLow; data.imageNumberEnd = imageHigh; images.append(data); } QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); }
linscanLoadAndPick map function and linesToImage reduce function:
linescanIntermediate linescanLoadAndPick(const linescanData &data) { QString filename = data.imageFolder + data.imagePrefix + QString::number(data.imageNumber) + ".tif"; cv::Mat image = cv::imread(filename.toStdString(), CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_GRAYSCALE); // if working vertical cv::Mat newData; if(data.vert) { if(data.range) newData = cv::Mat(image.rows, data.rangeHigh - data.rangeLow, CV_16U, cv::mean(image.colRange(data.rangeLow, data.rangeHigh))); else newData = image.col(data.single); } else { if(data.range) newData = cv::Mat(data.rangeHigh - data.rangeLow, image.cols, CV_16U, cv::mean(image.rowRange(data.rangeLow, data.rangeHigh))); else newData = image.row(data.single); } linescanIntermediate returnData; returnData.imageNumberStart = data.imageNumberStart; returnData.imageNumber = data.imageNumber; returnData.vert = data.vert; returnData.data = newData; return returnData; } cv::Mat linesToImage(cv::Mat &finalImage, const linescanIntermediate &data) { int insertLoc = data.imageNumberStart - data.imageNumber; if(data.vert) data.data.copyTo(finalImage.col(insertLoc)); else data.data.copyTo(finalImage.row(insertLoc)); return finalImage; }
Corresponding defs:
struct linescanData { bool vert; bool range; int single; int rangeLow; int rangeHigh; QString imageFolder; QString imagePrefix; int imageNumber; int imageNumberStart; int imageNumberEnd; cv::Mat data; }; struct linescanIntermediate { int imageNumberStart; int imageNumber; bool vert; cv::Mat data; }; linescanIntermediate linescanLoadAndPick(const linescanData &data); cv::Mat linesToImage(cv::Mat &finalImage, const linescanIntermediate &data);
-
Hi,
I'm trying to do some parallel image processing using QtConcurrent and opencv. The basic idea of the process is to read in some rows or columns from images take, the mean if more than 1 row or column and then output the single resulting row/column. This is then reduced by stacking all the lines together to create an image. Now mappedreduce seems like the perfect way to do this concurrently, but I can't get it to compile. I'm getting errors about no matching function call for the main mappedReduce function and "couldn't deduce return type" errors within that. It would be a great help if someone could point out where I'm going wrong here. ThanksCall to start the process on run button clicked:
void MainWindow::runLinescanClicked() { this->updateImageRange(); imageRangeData* lsRangeData = this->parseImageRange(ui->linescanLineNumberLE->text()); bool vert = ui->linescanVertRB->isChecked(); QList<linescanData> images; for(int i=imageLow; i<= imageHigh; i++) { linescanData data; data.vert = vert; data.range = lsRangeData->range; data.rangeLow = lsRangeData->low; data.rangeHigh = lsRangeData->high; data.single = lsRangeData->single; data.imageFolder = ui->imageFolderLE->text(); data.imagePrefix = ui->imagePrefixLE->text(); data.imageNumber = i; data.imageNumberStart = imageLow; data.imageNumberEnd = imageHigh; images.append(data); } QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); }
linscanLoadAndPick map function and linesToImage reduce function:
linescanIntermediate linescanLoadAndPick(const linescanData &data) { QString filename = data.imageFolder + data.imagePrefix + QString::number(data.imageNumber) + ".tif"; cv::Mat image = cv::imread(filename.toStdString(), CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_GRAYSCALE); // if working vertical cv::Mat newData; if(data.vert) { if(data.range) newData = cv::Mat(image.rows, data.rangeHigh - data.rangeLow, CV_16U, cv::mean(image.colRange(data.rangeLow, data.rangeHigh))); else newData = image.col(data.single); } else { if(data.range) newData = cv::Mat(data.rangeHigh - data.rangeLow, image.cols, CV_16U, cv::mean(image.rowRange(data.rangeLow, data.rangeHigh))); else newData = image.row(data.single); } linescanIntermediate returnData; returnData.imageNumberStart = data.imageNumberStart; returnData.imageNumber = data.imageNumber; returnData.vert = data.vert; returnData.data = newData; return returnData; } cv::Mat linesToImage(cv::Mat &finalImage, const linescanIntermediate &data) { int insertLoc = data.imageNumberStart - data.imageNumber; if(data.vert) data.data.copyTo(finalImage.col(insertLoc)); else data.data.copyTo(finalImage.row(insertLoc)); return finalImage; }
Corresponding defs:
struct linescanData { bool vert; bool range; int single; int rangeLow; int rangeHigh; QString imageFolder; QString imagePrefix; int imageNumber; int imageNumberStart; int imageNumberEnd; cv::Mat data; }; struct linescanIntermediate { int imageNumberStart; int imageNumber; bool vert; cv::Mat data; }; linescanIntermediate linescanLoadAndPick(const linescanData &data); cv::Mat linesToImage(cv::Mat &finalImage, const linescanIntermediate &data);
-
@jsulm compiler output looks like this:
../NicksImageProcessor/mainwindow.cpp: In member function 'void MainWindow::runLinescanClicked()': ../NicksImageProcessor/mainwindow.cpp:79:132: error: no matching function for call to 'mappedReduced(QList<linescanData>&, linescanIntermediate (*)(const linescanData&), cv::Mat (*)(cv::Mat&, const linescanIntermediate&), QtConcurrent::ReduceOption)' QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); ^ In file included from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/QtConcurrentMap:1:0, from ../NicksImageProcessor/mainwindow.cpp:7: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:121:21: note: candidate: template<class ResultType, class Sequence, class MapFunctor, class ReduceFunctor> QFuture<T> QtConcurrent::mappedReduced(const Sequence&, MapFunctor, ReduceFunctor, QtConcurrent::ReduceOptions) QFuture<ResultType> mappedReduced(const Sequence &sequence, ^ C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:121:21: note: template argument deduction/substitution failed: ../NicksImageProcessor/mainwindow.cpp:79:132: note: couldn't deduce template parameter 'ResultType' QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); ^ In file included from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/QtConcurrentMap:1:0, from ../NicksImageProcessor/mainwindow.cpp:7: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:134:74: note: candidate: template<class Sequence, class MapFunctor, class ReduceFunctor> QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(const Sequence&, MapFunctor, ReduceFunctor, QtConcurrent::ReduceOptions) QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(const Sequence &sequence, ^ C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:134:74: note: template argument deduction/substitution failed: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h: In substitution of 'template<class Sequence, class MapFunctor, class ReduceFunctor> QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(const Sequence&, MapFunctor, ReduceFunctor, QtConcurrent::ReduceOptions) [with Sequence = QList<linescanData>; MapFunctor = linescanIntermediate (*)(const linescanData&); ReduceFunctor = cv::Mat (*)(cv::Mat&, const linescanIntermediate&)]': ../NicksImageProcessor/mainwindow.cpp:79:132: required from here C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:134:74: error: invalid use of incomplete type 'struct QtPrivate::ReduceResultType<cv::Mat (*)(cv::Mat&, const linescanIntermediate&)>' In file included from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:49:0, from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/QtConcurrentMap:1, from ../NicksImageProcessor/mainwindow.cpp:7: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentfunctionwrappers.h:246:8: note: declaration of 'struct QtPrivate::ReduceResultType<cv::Mat (*)(cv::Mat&, const linescanIntermediate&)>' struct ReduceResultType; ^ In file included from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/QtConcurrentMap:1:0, from ../NicksImageProcessor/mainwindow.cpp:7: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:148:21: note: candidate: template<class ResultType, class Iterator, class MapFunctor, class ReduceFunctor> QFuture<T> QtConcurrent::mappedReduced(Iterator, Iterator, MapFunctor, ReduceFunctor, QtConcurrent::ReduceOptions) QFuture<ResultType> mappedReduced(Iterator begin, ^ C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:148:21: note: template argument deduction/substitution failed: ../NicksImageProcessor/mainwindow.cpp:79:132: note: deduced conflicting types for parameter 'Iterator' ('QList<linescanData>' and 'linescanIntermediate (*)(const linescanData&)') QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); ^ In file included from C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/QtConcurrentMap:1:0, from ../NicksImageProcessor/mainwindow.cpp:7: C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:162:74: note: candidate: template<class Iterator, class MapFunctor, class ReduceFunctor> QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(Iterator, Iterator, MapFunctor, ReduceFunctor, QtConcurrent::ReduceOptions) QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(Iterator begin, ^ C:/Qt/5.10.0/mingw53_32/include/QtConcurrent/qtconcurrentmap.h:162:74: note: template argument deduction/substitution failed: ../NicksImageProcessor/mainwindow.cpp:79:132: note: deduced conflicting types for parameter 'Iterator' ('QList<linescanData>' and 'linescanIntermediate (*)(const linescanData&)') QFuture<cv::Mat> final = QtConcurrent::mappedReduced(images, &linescanLoadAndPick, &linesToImage, QtConcurrent::UnorderedReduce); ^ Makefile.Debug:609: recipe for target 'debug/mainwindow.o' failed mingw32-make[1]: Leaving directory 'C:/Users/elp14nab/Documents/Qt/build-NicksImageProcessor-Desktop_Qt_5_10_0_MinGW_32bit-Debug' mingw32-make[1]: *** [debug/mainwindow.o] Error 1 Makefile:36: recipe for target 'debug' failed mingw32-make: *** [debug] Error 2