When the original image detects the face area, a problem occurs when assigning the face area to an image created using the cvcreateimage function.
Shows the problem image. The original code is as follows:
[CPP]
View plaincopyprint?
- Cvsize tmpsize;
- Tmpsize. width = width;
- Tmpsize. Height = height;
- Iplimage * tmpimg = cvcreateimage (tmpsize, ipl_depth_8u, 1 );
- Int M = starty;
- For (INT I = 0; I
- {
- Int n = startx;
- // Int widthstep = tmpimg-> widthstep;
- For (Int J = 0; j <width; j ++)
- {
- * (Tmpimg-> imagedata + I * <span style = "color: RGB (255, 0, 0);"> width </span> + J) =
- * (Image-> imagedata + M * image-> <span style = "color: RGB (255, 0, 0);"> width </span> + n );
- N ++;
- }
- M ++;
- }
CvSize tmpSize;tmpSize.width = width;tmpSize.height = height;IplImage *tmpImg = cvCreateImage(tmpSize, IPL_DEPTH_8U, 1);int m = startY;for(int i=0; i
Because the variable iplimage-> width is not the width after 4-byte alignment, the width in the svsize is not necessarily a multiple of 4 bytes when the image is created using cvcreateimage, the preceding Code uses width to cause image crossover. You can replace width with widthstep to solve the problem.
Images from the Internet