Reputation: 516
I am running ubuntu 12.04. I have a c++ project that I wrote and compiled fine in Eclipse(the version before luna). I had some issues with my system and had to do a OS reinstall. Now I am using Eclipse luna and the project gives a strange error when using some of the openCV functionality.
The errors I am having occur when I use the cv::namedWindow()
and the cv::imshow()
.
Errors are:
Here is eclipse console output:
00:21:45 **** Incremental Build of configuration Debug for project MySOM ****
make all
Building target: MySOM
Invoking: Cross G++ Linker
g++ -L/usr/local/lib -o "MySOM" ./src/LoadFile.o ./src/Model.o ./src/Node.o ./src/SOM.o ./src/main.o -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab
Finished building target: MySOM
00:21:45 Build Finished (took 210ms)
It looks find above but then...
Here is the Problems tab in eclipse:
Description Resource Path Location Type
Invalid arguments '
Candidates are:
bool imwrite(const ? &, const cv::_InputArray &, const ? &)
' SOM.cpp /MySOM/src line 211 Semantic Error
Invalid arguments '
Candidates are:
cv::Mat imread(const ? &, int)
' LoadFile.cpp /MySOM/src line 10 Semantic Error
Invalid arguments '
Candidates are:
void imshow(const ? &, const cv::_InputArray &)
' main.cpp /MySOM/src line 22 Semantic Error
Invalid arguments '
Candidates are:
void namedWindow(const ? &, int)
' main.cpp /MySOM/src line 21 Semantic Error
main.cpp
#include "Node.h"
#include <iostream>
#include "SOM.h"
#include <string>
#include "opencv2/core/core.hpp"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>//FOR TESTING
void MyPause(std::string msg){
if(msg != ""){
std::cout << "[+] " << msg << std::endl;
}
std::cout << "Press enter to continue" << std::endl;
std::cin.get();
}
void DisplayMat(cv::Mat img){
static int number = 0;
cv::namedWindow( "Input" + number, cv::WINDOW_AUTOSIZE );// ERROR HERE
cv::imshow( "Input" + number, img );//ERROR HERE
cv::waitKey(0);
number++;
return;
}
std::string filename = "/home/myUserName/Code/projectFiles/testMedia/myYellow.jpg";
int main(){
//cv::Mat inputImg = LoadFile(filename);
SOM som(filename);
MyPause("After SOM initialization");
DisplayMat(som.inputImg);
MyPause("END OF MAIN");
return 0;
}
I wonder if this could be occurring because of how I compiled opencv now compared to how i compiled it on my original system.
Upvotes: 2
Views: 998
Reputation: 8163
This keeps happening to me when I upgrade the eclipse. It has all the strange error of Member declaration not found
, invalid overload of endl
, Invalid arguments ...
, Now I figured out that it is the info in the workspace and old projects were not up-to-date for the new CDT codan. It is actually very easy to solve this problem: Project->C/C++ index->Rebuild
. After it is done, all strange errors will go away.
Upvotes: 2
Reputation: 409136
This expression is not valid: "Input" + number
. You can't just concatenate string literals with numbers. Well you can but the result will not be what you expect.
Fortunately you are programming C++, which means you can use std::string
and std::to_string
(if you have a C++11 compatible compiler): std::string("Input") + std::to_string(number)
.
If you don't have C++11, and therefore not std::to_string
, then you can use e.g. the Boost lexical cast library, or std::istringstream
to format the string, or other formatting functions/libraries.
Upvotes: 1
Reputation: 516
I had tried refreshing, cleaning, and rebuilding 3 times before doing this but it seems that after posting I tried a fourth just to be sure and behold it has worked.
Upvotes: 1