示例#1
0
        public ActionResult UploadFace(int?id)
        {
            ActionResult res = AjaxSubmit(id);

//             string message = System.Web.HttpContext.Current.Request.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath);
//             Response.Write("<script language=VBScript>MsgBox " + message + "</script>");
            if ((Session["ContentStream"] != null) &&
                (Session["ContentStream"].GetType() == typeof(byte[])))
            {
                byte[] arr = (byte[])Session["ContentStream"];
                OpenCvSharp.IplImage[] imgs = null;
                OpenCvSharp.IplImage   img  = support.ByteArrayToIplImage(arr, OpenCvSharp.LoadMode.Unchanged);
                if (img != null)
                {
                    imgs = HaarCascade.GetFaces(img);
                }
                if (imgs != null && imgs.Length > 0)
                {
                    Session["ContentStream"] = support.IplImageToByteArray(imgs[0]);
                    Session["ContentLength"] = imgs[0].ImageSize;
                }
                else
                {
                    Session["ContentLength"] = null;
                    Session["ContentStream"] = null;

                    Response.Write("error");

                    return(null);
                }
                OpenCvSharp.Cv.ReleaseImage(img);
            }
            return(res);
        }