ZoeGreenn 2015-12-26 08:50 采纳率: 0%
浏览 2437
已结题

Linux下编译opencv的cvDrawChessboardCorners函数出错

在linux上编译:

 zoegreen@zoegreen-Lenovo-IdeaPad-Y470:~/桌面/subpix_test$ g++ subpix2.cpp -o subpix2  `pkg-config --cflags --libs opencv`
subpix2.cpp: In function ‘int main()’:
subpix2.cpp:15:20: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
     char* filename="camara1.bmp";
                    ^
subpix2.cpp:38:9: error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope
         CV_CALIB_CB_ADAPTIVE_THRESH|CV_CALIB_CB_FILTER_QUADS// check page 382-383.
         ^
subpix2.cpp:38:37: error: ‘CV_CALIB_CB_FILTER_QUADS’ was not declared in this scope
         CV_CALIB_CB_ADAPTIVE_THRESH|CV_CALIB_CB_FILTER_QUADS// check page 382-383.
                                     ^
subpix2.cpp:40:9: error: ‘cvFindChessboardCorners’ was not declared in this scope
         );
         ^
subpix2.cpp:49:9: error: ‘cvDrawChessboardCorners’ was not declared in this scope
         );
         ^
zoegreen@zoegreen-Lenovo-IdeaPad-Y470:~/桌面/subpix_test$ 

请问是环境没配置号吗?但是我之前编译其它的opencv程序都是好的.
其中源程序如下:

 #include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/features2d/features2d.hpp"
//#include "opencv2/legacy/legacy.hpp"
using namespace std;


//by Huang, Haiqiao 25 Jun. 2011, fzyhhq@bift.edu.cn
//http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=14214

int main( )
{
    cout<<"Draw Chess OpenCV!"<<endl;  
    char* filename="camara1.bmp";
    IplImage* imgRGB = cvLoadImage(filename); 
    IplImage* imgGrey = cvLoadImage(filename,CV_LOAD_IMAGE_GRAYSCALE); 

    if (imgGrey==NULL){//image validation
        cout<< "No valid image input."<<endl; 
        char c=getchar();
        return 1;
    } 

    //-------find chessboard corners--------------
    int corner_row=13;//interior number of row corners.(this can be countered by fingers.)
    int corner_col=12;//interior number of column corners.
    int corner_n=corner_row*corner_col;
    CvSize pattern_size=cvSize(corner_row,corner_col);
    CvPoint2D32f* corners=new CvPoint2D32f[corner_n];
    int corner_count;

    int found=cvFindChessboardCorners(//returning non-zero means sucess.
        imgGrey,// 8-bit single channel greyscale image.
        pattern_size,//how many INTERIOR corners in each row and column of the chessboard.
        corners,//a pointer to an array where the corner locations can be recorded.
        &corner_count,// optional, if non-NULL, its a point to an integer where the nuber of corners found can be recorded.
        CV_CALIB_CB_ADAPTIVE_THRESH|CV_CALIB_CB_FILTER_QUADS// check page 382-383.

        );
     cout<<"corner_count = "<<corner_count;
    //-------Draw the corner pattern-------
    cvDrawChessboardCorners(
        imgRGB,
        pattern_size,
        corners,
        corner_count,
        found
        );

    //to summary a bit of findings.
    cout<<"found="<<found<<endl;
    cout<<"x="<<corners[2].x;
    cout<<",y="<<corners[2].y<<endl;

    cvNamedWindow("Find and Draw ChessBoard", 0 );
    cvShowImage( "Find and Draw ChessBoard", imgRGB );

    cvWaitKey(0); 

    cvReleaseImage(&imgGrey);
    cvReleaseImage(&imgRGB);
    cvDestroyWindow("Find and Draw ChessBoard"); 

    return 0;
  • 写回答

1条回答 默认 最新

  • devmiao 2016-02-05 23:52
    关注
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!