opencv3.0.0出现无法解析的外部命令

opencv3.0.0出现无法解析的外部命令
头文件代码:
#if !defined COLORDETECT
#define COLORDETECT

#include
#include

class ColorDetector {

private:

// minimum acceptable distance
int maxDist;

// target color
cv::Vec3b target;

// image containing color converted image
cv::Mat converted;
bool useLab;

// image containing resulting binary map
cv::Mat result;

public:

// empty constructor
// default parameter initialization here
ColorDetector() : maxDist(100), target(0, 0, 0), useLab(false) {}

// extra constructor for Lab color space example
ColorDetector(bool useLab) : maxDist(100), target(0, 0, 0), useLab(useLab) {}

// full constructor
ColorDetector(uchar blue, uchar green, uchar red, int mxDist = 100, bool useLab = false) : maxDist(mxDist), useLab(useLab) {

    // target color
    setTargetColor(blue, green, red);
}

// Computes the distance from target color.
int getDistanceToTargetColor(const cv::Vec3b& color) const {
    return getColorDistance(color, target);
}

// Computes the city-block distance between two colors.
int getColorDistance(const cv::Vec3b& color1, const cv::Vec3b& color2) const {

    return abs(color1[0] - color2[0]) +
        abs(color1[1] - color2[1]) +
        abs(color1[2] - color2[2]);

    // Or:
    // return static_cast<int>(cv::norm<int,3>(cv::Vec3i(color[0]-color2[0],color[1]-color2[1],color[2]-color2[2])));

    // Or:
    // cv::Vec3b dist;
    // cv::absdiff(color,color2,dist);
    // return cv::sum(dist)[0];
}

// Processes the image. Returns a 1-channel binary image.
cv::Mat process(const cv::Mat &image);

cv::Mat operator()(const cv::Mat &image) {

    cv::Mat input;
    input = image;
    if (useLab) { // Lab conversion
        cv::cvtColor(image, input, CV_BGR2Lab);
    }

    cv::Mat output;
    // compute absolute difference with target color
    cv::absdiff(input, cv::Scalar(target), output);
    // split the channels into 3 images
    std::vector<cv::Mat> images;
    cv::split(output, images);
    // add the 3 channels (saturation might occurs here)
    output = images[0] + images[1] + images[2];
    // apply threshold
    cv::threshold(output,  // input image
        output,  // output image
        maxDist, // threshold (must be < 256)
        255,     // max value
        cv::THRESH_BINARY_INV); // thresholding type

    return output;
}

// Getters and setters

// Sets the color distance threshold.
// Threshold must be positive, otherwise distance threshold
// is set to 0.
void setColorDistanceThreshold(int distance) {

    if (distance < 0)
        distance = 0;
    maxDist = distance;
}

// Gets the color distance threshold
int getColorDistanceThreshold() const {

    return maxDist;
}

// Sets the color to be detected
void setTargetColor(uchar blue, uchar green, uchar red) {

    // BGR order
    target = cv::Vec3b(blue, green, red);

    if (useLab) {
        // Temporary 1-pixel image
        cv::Mat tmp(1, 1, CV_8UC3);
        tmp.at<cv::Vec3b>(0, 0) = cv::Vec3b(blue, green, red);

        // Converting the target to Lab color space 
        cv::cvtColor(tmp, tmp, CV_BGR2Lab);

        target = tmp.at<cv::Vec3b>(0, 0);
    }
}

// Sets the color to be detected
void setTargetColor(cv::Vec3b color) {

    target = color;
}

// Gets the color to be detected
cv::Vec3b getTargetColor() const {

    return target;
}

};

#endif

主函数代码:
#include
#include
#include
#include
#include"colordetector.h"

int main()
{
// 1. Create image processor object
ColorDetector cdetect;

// 2. Read input image
cv::Mat image = cv::imread("Schluss.jpg");
if (image.empty())
    return 0;

// 3. Set input parameters
cdetect.setTargetColor(250, 219, 133); // here blue sky

// 4. Process the image and display the result
cv::namedWindow("result");
cv::imshow("result", cdetect.process(image));

// or using functor
ColorDetector colordetector(250, 219, 133,  // color
    45, true); // Lab threshold
cv::namedWindow("result (functor)");
cv::imshow("result (functor)", colordetector(image));

cv::waitKey();

return 0;

}

依赖的库添加了:
D:\opencv\build\x64\vc12\lib\opencv_ts300.lib
D:\opencv\build\x64\vc12\lib\opencv_world300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_imgproc300.lib
D:\opencv\build\x64\vc12\staticlib\IlmImf.lib
D:\opencv\build\x64\vc12\staticlib\ippicvmt.lib
D:\opencv\build\x64\vc12\staticlib\libjpeg.lib
D:\opencv\build\x64\vc12\staticlib\libpng.lib
D:\opencv\build\x64\vc12\staticlib\libtiff.lib
D:\opencv\build\x64\vc12\staticlib\libwebp.lib
D:\opencv\build\x64\vc12\staticlib\opencv_calib3d300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_core300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_features2d300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_flann300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_hal300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_highgui300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_imgcodecs300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_imgproc300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_ml300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_objdetect300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_photo300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_shape300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_stitching300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_superres300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_video300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_videoio300.lib
D:\opencv\build\x64\vc12\staticlib\opencv_videostab300.lib
D:\opencv\build\x64\vc12\staticlib\zlib.lib

解决方案配置是Release x64

刚开始学OpenCV,请各位大佬帮帮我

c++
weixin_45222491
千日草 回复白色一大坨: 我一开始的确是只有一个lib,但是就是显示这个错误,所以我才添加其他lib的,但还是不行
7 个月之前 回复
phenix2009
白色一大坨 加了多余的库吧
7 个月之前 回复

1个回答

3.0版本哪儿用加那么多lib,明明一个opencv_world300.lib就可以了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问