예제 #1
0
        public static Rect getCropFaceRect(int[] argb, FaceInfo faceInfo, int imageWidth)
        {
            int[] points = new int[8];

            faceInfo.GetRectPoints(points);

            int left   = points[2];
            int top    = points[3];
            int right  = points[6];
            int bottom = points[7];

            int width  = right - left;
            int height = bottom - top;

            width  = width * 3 / 2;
            height = height * 2;
            //
            left = (int)(faceInfo.MCenterX - width / 2);
            top  = (int)(faceInfo.MCenterY - height / 2);

            height = height * 4 / 5;
            //
            left = Math.Max(left, 0);
            top  = Math.Max(top, 0);

            Rect region = new Rect(left, top, left + width, top + height);

            adjustRect(argb, width, region);
            return(region);
        }
예제 #2
0
        public Rect getFaceRectTwo(FaceInfo faceInfo, ImageFrame frame)
        {
            Rect rect = new Rect();

            int[] points = new int[8];
            faceInfo.GetRectPoints(points);
            int left   = points[2];
            int top    = points[3];
            int right  = points[6];
            int bottom = points[7];
            //        int previewWidth=surfaViews[typeIndex].getWidth();
            //        int previewHeight=surfaViews[typeIndex].getHeight();
            int previewWidth;
            int previewHeight;

            //        previewWidth = surface_one.getWidth();
            //        previewHeight = surface_one.getHeight();
            if (camemra1IsRgb)
            {
                previewWidth  = surface_one.MeasuredWidth;
                previewHeight = surface_one.MeasuredHeight;
            }
            else
            {
                previewWidth  = surface_two.MeasuredWidth;
                previewHeight = surface_two.MeasuredHeight;
            }

            float scaleW = 1.0f * previewWidth / frame.getWidth();
            float scaleH = 1.0f * previewHeight / frame.getHeight();
            int   width  = (right - left);
            int   height = (bottom - top);

            left = (int)((faceInfo.MCenterX - width / 2) * scaleW);
            top  = (int)((faceInfo.MCenterY - height / 2) * scaleW);
            //        left = (int) ((faceInfo.mCenter_x)* scaleW);
            //        top =  (int) ((faceInfo.mCenter_y) * scaleW);
            rect.Top    = top < 0 ? 0 : top;
            rect.Left   = left < 0 ? 0 : left;
            rect.Right  = (left + width) > frame.getWidth() ? frame.getWidth() : (left + width);
            rect.Bottom = (top + height) > frame.getHeight() ? frame.getHeight() : (top + height);
            return(rect);
        }
예제 #3
0
        /**
         * 获取人脸框区域。
         *
         * @return 人脸框区域
         */
        // TODO padding?
        public Rect getFaceRect(FaceInfo faceInfo, ImageFrame frame)
        {
            Rect rect = new Rect();

            int[] points = new int[8];
            faceInfo.GetRectPoints(points);

            int left   = points[2];
            int top    = points[3];
            int right  = points[6];
            int bottom = points[7];

            //            int width = (right - left) * 4 / 3;
            //            int height = (bottom - top) * 4 / 3;
            //
            //            left = getInfo().mCenter_x - width / 2;
            //            top = getInfo().mCenter_y - height / 2;
            //
            //            rect.top = top;
            //            rect.left = left;
            //            rect.right = left + width;
            //            rect.bottom = top + height;

            //            int width = (right - left) * 4 / 3;
            //            int height = (bottom - top) * 5 / 3;
            int width  = (right - left);
            int height = (bottom - top);

            //            left = getInfo().mCenter_x - width / 2;
            //            top = getInfo().mCenter_y - height * 2 / 3;
            left = (int)(faceInfo.MCenterX - width / 2);
            top  = (int)(faceInfo.MCenterY - height / 2);


            rect.Top    = top < 0 ? 0 : top;
            rect.Left   = left < 0 ? 0 : left;
            rect.Right  = (left + width) > frame.getWidth() ? frame.getWidth() : (left + width);
            rect.Bottom = (top + height) > frame.getHeight() ? frame.getHeight() : (top + height);

            return(rect);
        }