zoukankan      html  css  js  c++  java
  • 【openCV学习笔记】【3】高斯模糊一张图片(_cvSmooth相关编译错误)

    代码如下:

    #include <iostream>
    #include <opencv/highgui.h>
    #include <opencv/cv.h>
    
    
    void example(IplImage* image)
    {
        // Create some windows to show the input
        // and output images in.
        //
        cvNamedWindow("Example2_4-in", CV_WINDOW_AUTOSIZE);
        cvNamedWindow("Example2_4-out", CV_WINDOW_AUTOSIZE);
        
        // Create a window to show our input image
        //
        cvShowImage("Example2_4-in", image);
        
        // Create an image to hold the smoothed output
        //
        IplImage* out = cvCreateImage(
                                      cvGetSize(image),
                                      IPL_DEPTH_8U,
                                      3
                                      );
        printf("%d %d", cvGetSize(image).height, cvGetSize(image).width);
        
        // Do the smoothing
        //
        cvSmooth(image, image, CV_GAUSSIAN, 3, 3);
        //cvSmooth(out, out, CV_GAUSSIAN, 3, 3);
        
        // Show the smoothed image in the output window
        //
        cvShowImage("Example2_4-out", out);
        
        // Be tidy
        //
        cvReleaseImage(&out);
        
        // Wait for the user to hit a key, then clean up the windows
        //
        cvWaitKey(0);
        cvDestroyWindow("Example2_4-in");
        cvDestroyWindow("Example2_4-out");
        
    }
    
    int main(int argc, char** argv)
    {
        IplImage* img = cvLoadImage("/Users/apple/Pictures/openCV/standard_img/lena.jpg");
        cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE);
        cvShowImage("Example1", img);
        example(img);
        //  cvWaitKey(0);
        cvReleaseImage(&img);
        cvDestroyWindow("Example1");
    }

    起初编译时出现错误:

    Undefined symbols for architecture x86_64:
      "_cvSmooth", referenced from:
          _main in main.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    在stackoverflow上一个回答非常给力。

    http://stackoverflow.com/questions/9219612/undefined-symbols-cvsmooth-in-opencv2-3-1-on-mac

    Add libopencv_imgproc.dylib to your Xcode project and you should be off to the races.

  • 相关阅读:
    岩石圈
    地球及其圈层结构
    如何请教一个技术问题
    中国游戏路在何方?
    5.4删除二叉搜索树的任意元素
    5.3 删除二叉搜索树的最大元素和最小元素
    uni-app开发小程序准备阶段
    5.2二叉搜索树遍历(前序、中序、后序、层次、广度优先遍历)
    5.1二叉搜索树基础
    【loj
  • 原文地址:https://www.cnblogs.com/turtle920/p/4909215.html
Copyright © 2011-2022 走看看