【问题标题】:Eclipse giving "weird" error concerning opencvEclipse 给出关于 opencv 的“奇怪”错误
【发布时间】:2014-08-14 05:01:40
【问题描述】:

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

我在使用cv::namedWindow()cv::imshow() 时出现的错误。 错误是:

这里是 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)

它看起来在上面找到,但后来......

这是 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;
}

我想知道这是否会发生,因为我现在编译 opencv 的方式与我在原始系统上编译它的方式相比。

【问题讨论】:

  • 您发现发生了什么吗?我有完全相同的问题。很多奇怪的错误。不管我重建了多少次。
  • 王,看我接受的答案。

标签: c++ eclipse opencv compiler-errors


【解决方案1】:

当我升级 Eclipse 时,这种情况一直发生在我身上。它有Member declaration not foundinvalid overload of endlInvalid arguments ... 的所有奇怪错误,现在我发现这是工作区中的信息,旧项目对于新的 CDT codan 不是最新的。这个问题其实很容易解决:Project-&gt;C/C++ index-&gt;Rebuild。完成后,所有奇怪的错误都会消失。

【讨论】:

    【解决方案2】:

    在执行此操作之前,我曾尝试刷新、清洁和重建 3 次,但似乎在发布后我尝试了第四次,以确保它确实有效。

    【讨论】:

      【解决方案3】:

      此表达式无效:"Input" + number。您不能只将字符串文字与数字连接起来。好吧,你可以,但结果不会是你所期望的。

      幸运的是,您正在编程 C++,这意味着您可以使用 std::stringstd::to_string(如果您有兼容 C++11 的编译器):std::string("Input") + std::to_string(number)

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

      【讨论】:

        猜你喜欢
        • 2018-01-22
        • 2017-11-11
        • 1970-01-01
        • 1970-01-01
        • 2012-05-21
        • 2014-11-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多