-5

帮助我如何解决它,[尝试执行我的代码时的警报窗口][1]

注意到调试很好并且成功但是当尝试执行代码时,我在输出窗口中收到一条消息;Exception non gérée à 0x100e3cf2 dans shervinemami.exe : 0xC0000094: Integer 除以零..这意味着有一个除以零的异常,这是代码:

        IplImage* LOULILI::cropFace(IplImage*image, CvPoint eye_left, CvPoint eye_right,double offset_pct[2], CvSize dest_sz)
          {
      //calculate offsets in original image
            double offset_h = offset_pct[0]* dest_sz.width;
            double offset_v = offset_pct[1]*dest_sz.height;
           //get the direction
           double   eye_directionX,eye_directionY;
           eye_directionX= double(eye_right.x - eye_left.x);
            eye_directionY=double(eye_right.y - eye_left.y);
          // calc rotation angle in radians
          double rotation;
          rotation =  double(-atan2(eye_directionY,eye_directionX )*180/PI);
           // distance between them
            double dist = distancePoints(eye_left, eye_right);
             //calculate the reference eye-width
             double reference = dest_sz.width - 2.0*offset_h;
           //scale factor
              double scale = dist/reference;
          //rotation par rapport à l'oeil gauche
         //matrice de rotation
      cv::Mat affine_matrix;
       affine_matrix =cv::getRotationMatrix2D( eye_left, rotation, scale );
           //mtx est la conversion de image IplImage* en matrice mtx
            cv::Mat mtx=cv::Mat(image,true); 
          cv::Mat mtx2;
         cv::warpAffine(mtx, mtx2, affine_matrix,mtx.size(),cv::INTER_LINEAR,                                cv::BORDER_CONSTANT,cv::Scalar::all(255));
  //mtx est la conversion de matrice mtx2 en  image IplImage* 
  //IplImage* image1 =&mtx2.operator IplImage();
 IplImage image1 =mtx2;
 IplImage* im22=(IplImage*)&image1;
      //crop the rotated image
         double crop_x =double(eye_left.x) - scale*offset_h;
       double crop_y =double(eye_left.y) - scale*offset_v;

 double crop_size0 = (double)dest_sz.width*scale;
  double crop_size1= (double)  dest_sz.height*scale;
         CvRect region;
       region.x=cvRound(crop_x);
       region.y=cvRound(crop_y);
        region.width=cvRound (crop_size0);
         region.height=cvRound(crop_size1);

            IplImage* im44=cropImage(im22,region);
          //crop((int(crop_xy[0]), int(crop_xy[1]), int(crop_xy[0]+crop_size[0]),                       int(crop_xy[1]+crop_size[1])))

          IplImage* image3=resizeImage(im44, dest_sz.width, dest_sz.width);
           return im44;
                  }
4

1 回答 1

0

该代码中没有整数除法,因此我们无法提供帮助。您可能希望在调试模式下编译并将调试器设置为在 C++ 异常时中断(您可以在 Visual Studio 的“异常”窗口中执行此操作)。

于 2012-05-06T00:50:49.160 回答