编程语言
首页 > 编程语言> > 直播短视频源码,身份证图片识别

直播短视频源码,身份证图片识别

作者:互联网

直播短视频源码,进行身份验证时,对上传的身份证图片实现正确识别的相关代码

public class IDCardModel
        {
            public string name;
            public string sex;
            public string birthday;
            public string nation;
            public string address;
            public string IDCard;
        }
        /// <summary>
        /// 获取身份证解析结果
        /// </summary>
        /// <param name="oldpath">身份证证件文件</param>
        /// <param name="temppathroot">身份证转换文件目录</param>
        /// <param name="toolroot">身份证转换工具目录</param>
        /// <returns></returns>
        public static IDCardModel GetIDCardModel(string oldpath, string temppathroot, string toolroot)
        {
            if (string.IsNullOrWhiteSpace(oldpath) || !File.Exists(oldpath) || !Directory.Exists(temppathroot))
            {
                return null;
            }
            T9.Util.FileUtil.DeleteFolderFile(temppathroot + @"\", 0);
            IDCardModel idcardmodel = null;
            string extension = System.IO.Path.GetExtension(oldpath);
            string newpath = temppathroot + @"\60.jpg";
            File.Copy(oldpath, newpath, true);
            Process process = new Process();//实例
            process.StartInfo.CreateNoWindow = true;//设定不显示窗口
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.FileName = "c:\\Windows\\System32\\cmd.exe"; //设定程序名 
            process.StartInfo.RedirectStandardInput = true; //重定向标准输入
            process.StartInfo.RedirectStandardOutput = true; //重定向标准输出
            process.StartInfo.RedirectStandardError = true;//重定向错误输出
            process.Start();
 
 
            process.StandardInput.WriteLine(@"d: ");  //先转到系统盘下
            process.StandardInput.WriteLine(@"cd " + toolroot + " ");  //再转到CMD所在目录下
            process.StandardInput.WriteLine(@"test.exe ");
 
 
            //process.StandardInput.WriteLine(@"cd rec_idc ");
            //process.StandardInput.WriteLine(@"test.exe ");
 
            string s; bool b = false;
            while ((s = process.StandardOutput.ReadLine()) != null)
            {
                if (s.Contains("time:"))
                {
                    break;
                }
                if (s.StartsWith("6"))
                {
                    s = process.StandardOutput.ReadLine();
                    if (s.StartsWith("ERROR"))
                    {
 
                    }
                    else
                    {
                        b = true;
                        string[] arr = s.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        idcardmodel = new IDCardModel();
                        idcardmodel.name = arr[0].Trim();
                        idcardmodel.sex = arr[1].Trim();
                        idcardmodel.birthday = arr[2].Trim();
                        idcardmodel.nation = arr[3].Trim();
                        idcardmodel.address = arr[4].Trim();
                        idcardmodel.IDCard = arr[5].Trim();
                        break;
                    }
 
                }
                s = "";
            }
            if (!b)
            {
                return null;
            }
 
            process.StandardInput.WriteLine("exit");
            process.WaitForExit();
 
            // process.Kill();
            process.Close();
            process.Dispose();
            return idcardmodel;
        }

 


```
以上就是 直播短视频源码,身份证图片识别实现的相关代码,更多内容欢迎关注之后的文章

标签:arr,string,idcardmodel,process,public,直播,StandardInput,身份证,源码
来源: https://www.cnblogs.com/yunbaomengnan/p/15015384.html