Eclipse提供了关于opencv的“怪异”错误。

时间:2022-06-28 09:47:42

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.

我正在运行ubuntu 12.04。我有一个c++项目,我在Eclipse中编写并编译了fine(在luna之前的版本)。我的系统有些问题,必须重新安装操作系统。现在我使用Eclipse luna,在使用openCV的一些功能时,项目给出了一个奇怪的错误。

The errors I am having occur when I use the cv::namedWindow() and the cv::imshow(). Errors are:

当我使用cv::namedWindow()和cv::imshow()时,会出现错误。错误:

Here is eclipse console output:

以下是eclipse控制台输出:

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:

这里是eclipse中的Problems选项卡:

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

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.

我不知道这是否会发生,因为我现在已经编译了opencv,而不是我在原来的系统上编译它。

3 个解决方案

#1


1  

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.

在做这个之前,我尝试了三次刷新、清洗和重建,但似乎在发布之后,我尝试了第四次,只是为了确保它成功了。

#2


1  

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).

幸运的是,您正在编程c++,这意味着您可以使用std::string和std::to_string(如果您有一个c++ 11兼容的编译器):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.

如果您没有c++ 11,因此没有std::to_string,那么您可以使用Boost lexical cast库,或者std::istringstream来格式化字符串,或者其他格式化函数/库。

#3


1  

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.

当我升级eclipse时,这种情况一直发生在我身上。它有成员声明的所有奇怪错误没有发现,无效超载的endl,无效的参数…现在我发现工作空间中的信息和旧的项目并不是最新的CDT codan。实际上很容易解决这个问题:Project->C/ c++索引->重建。完成后,所有奇怪的错误都会消失。

#1


1  

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.

在做这个之前,我尝试了三次刷新、清洗和重建,但似乎在发布之后,我尝试了第四次,只是为了确保它成功了。

#2


1  

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).

幸运的是,您正在编程c++,这意味着您可以使用std::string和std::to_string(如果您有一个c++ 11兼容的编译器):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.

如果您没有c++ 11,因此没有std::to_string,那么您可以使用Boost lexical cast库,或者std::istringstream来格式化字符串,或者其他格式化函数/库。

#3


1  

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.

当我升级eclipse时,这种情况一直发生在我身上。它有成员声明的所有奇怪错误没有发现,无效超载的endl,无效的参数…现在我发现工作空间中的信息和旧的项目并不是最新的CDT codan。实际上很容易解决这个问题:Project->C/ c++索引->重建。完成后,所有奇怪的错误都会消失。