ZoeGreenn 2015-12-29 11:54 采纳率: 0%
浏览 2917
已结题

qt上编译opencv程序出错

编译提取棋盘格角点的的程序,但是一直显示cvFindChessboardCorners这个函数有问题,请大神指教!
错误如下:

 ../qt_subpix1/main.cpp: In function 'int main(int, char**)':
../qt_subpix1/main.cpp:14:19: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    char* filename="1.jpg";
                   ^
../qt_subpix1/main.cpp:20:12: warning: unused variable 'c' [-Wunused-variable]
       char c=getchar();
            ^
../qt_subpix1/main.cpp:37: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.
         ^
../qt_subpix1/main.cpp:37: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.
                                     ^
../qt_subpix1/main.cpp:38:4: error: 'cvFindChessboardCorners' was not declared in this scope
    );
    ^
../qt_subpix1/main.cpp:58:4: error: 'cvDrawChessboardCorners' was not declared in this scope
    );
    ^
../qt_subpix1/main.cpp: At global scope:
../qt_subpix1/main.cpp:11:5: warning: unused parameter 'argc' [-Wunused-parameter]
 int main(int argc, char** argv)
     ^
../qt_subpix1/main.cpp:11:5: warning: unused parameter 'argv' [-Wunused-parameter]
make: *** [main.o] Error 1

程序源码如下:

 /* hellochess.cpp */
#include <iostream>
#include <stdlib.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <math.h>
using namespace std;


int main(int argc, char** argv)
{
   cout << "Draw Chess OpenCV!"<<endl;
   char* filename="1.jpg";
   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=9;//interior number of row corners.(this can be countered by fingers.)
   int corner_col=11;//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.
   );
   //-------------obtain subpixel accuracy on those corners-----------------------
   int half_win_size=3;//the window size will be 3+1+3=7
   int iteration=20;
   double epislon=0.1;
   cvFindCornerSubPix(
         imgGrey,
         corners,
         corner_count,
         cvSize(half_win_size,half_win_size),
         cvSize(-1,-1),//no ignoring the neighbours of the center corner
         cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,iteration,epislon)
   );
   //-------Draw the corner pattern-------
   cvDrawChessboardCorners(
        imgRGB,
        pattern_size,
        corners,
        corner_count,
        found
   );
   //to summary a bit of findings.
   //<<&quot;found=&quot;<<found<<endl;
   //cout<<&quot;x=&quot;<<corners&#91;2&#93;.x;
   //cout<<&quot;,y=&quot;<<corners&#91;2&#93;.y<<endl;
   cvNamedWindow("Find and Draw ChessBoard", CV_WINDOW_AUTOSIZE );
   cvShowImage( "Find and Draw ChessBoard", imgRGB );
   cvWaitKey(0);
   cvReleaseImage(&imgGrey);
   cvReleaseImage(&imgRGB);
   cvDestroyWindow("Find and Draw ChessBoard");
   return 0;
}

  • 写回答

3条回答 默认 最新

  • 道亦无名 博客专家认证 2015-12-29 12:05
    关注

    看看是不是库的路径图片说明

    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services