解決方法を教えてください [コードを実行しようとすると警告ウィンドウが表示される][1]
デバッグは問題なく成功していますが、コードを実行しようとすると、出力ウィンドウにメッセージが表示されます。Exception non gérée à 0x100e3cf2 dans shervinemami.exe : 0xC0000094: ゼロによる整数除算..これは、ゼロによる除算の例外があることを意味します。これはコードです:
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;
}