基于C#实现Winform界面调用名片识别接口

更新时间:2023-10-22 11:14:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

基于C#实现Winform界面调用名片识别接口

本程序适用于聚合名片识别接口:http://www.juhe.cn/docs/api/id/139

注:项目中如遇无法引用 System.Web.dll 问题,修改“项目属性”-“应用程序”-“目标框架” ,由“.NET Framework 4 Client Profile”修改为“.NET Framework 4”。然后再引用 .NET 4.0 的 System.Web.dll 即可

前台界面代码:

namespace mingpianshibie {

partial class Form1 {

///

/// Required designer variable. ///

private System.ComponentModel.IContainer components = null;

///

/// Clean up any resources being used. ///

///

protected override void Dispose(bool disposing) {

if (disposing && (components != null)) {

components.Dispose(); }

base.Dispose(disposing); }

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///

private void InitializeComponent()

{

this.open = new System.Windows.Forms.Button(); this.pixel = new System.Windows.Forms.Button();

this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.ImgToBase64 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();

this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); this.lb_show = new System.Windows.Forms.Label();

((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.groupBox1.SuspendLayout(); this.SuspendLayout(); //

// open //

this.open.Location = new System.Drawing.Point(414, 29); this.open.Name = \;

this.open.Size = new System.Drawing.Size(112, 29); this.open.TabIndex = 0;

this.open.Text = \选择图片\;

this.open.UseVisualStyleBackColor = true;

this.open.Click += new System.EventHandler(this.open_Click); //

// pixel //

this.pixel.Location = new System.Drawing.Point(414, 92); this.pixel.Name = \;

this.pixel.Size = new System.Drawing.Size(112, 29); this.pixel.TabIndex = 3;

this.pixel.Text = \灰度化处理\;

this.pixel.UseVisualStyleBackColor = true;

this.pixel.Click += new System.EventHandler(this.pixel_Click);

//

// pictureBox2 //

this.pictureBox2.Location = new System.Drawing.Point(6, 141);

this.pictureBox2.Name = \;

this.pictureBox2.Size = new System.Drawing.Size(373, 113);

this.pictureBox2.TabIndex = 5; this.pictureBox2.TabStop = false; //

// pictureBox1 //

this.pictureBox1.Location = new System.Drawing.Point(6, 17); this.pictureBox1.Name = \;

this.pictureBox1.Size = new System.Drawing.Size(373, 110); this.pictureBox1.TabIndex = 4; this.pictureBox1.TabStop = false; //

// ImgToBase64 //

this.ImgToBase64.Location = new System.Drawing.Point(414, 153);

this.ImgToBase64.Name = \;

this.ImgToBase64.Size = new System.Drawing.Size(112, 29); this.ImgToBase64.TabIndex = 6;

this.ImgToBase64.Text = \图片Base64转换\;

this.ImgToBase64.UseVisualStyleBackColor = true;

this.ImgToBase64.Click += new System.EventHandler(this.ImgToBase64_Click); //

// button2 //

this.button2.Location = new System.Drawing.Point(414, 216); this.button2.Name = \;

this.button2.Size = new System.Drawing.Size(112, 29); this.button2.TabIndex = 7;

this.button2.Text = \名片识别\;

this.button2.UseVisualStyleBackColor = true;

this.button2.Click += new System.EventHandler(this.button2_Click_1);

//

// groupBox1 //

this.groupBox1.BackColor = System.Drawing.SystemColors.Control;

this.groupBox1.Controls.Add(this.pictureBox1); this.groupBox1.Controls.Add(this.pictureBox2);

this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = \;

this.groupBox1.Size = new System.Drawing.Size(396, 260); this.groupBox1.TabIndex = 8;

this.groupBox1.TabStop = false;

this.groupBox1.Text = \图片展示\; //

// label1 //

this.label1.AutoSize = true;

this.label1.Location = new System.Drawing.Point(16, 299); this.label1.Name = \;

this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 9;

this.label1.Text = \识别结果:\; //

// lb_show //

this.lb_show.AutoSize = true;

this.lb_show.Location = new System.Drawing.Point(106, 299); this.lb_show.Name = \;

this.lb_show.Size = new System.Drawing.Size(0, 12); this.lb_show.TabIndex = 10; //

// Form1 //

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(553, 348); this.Controls.Add(this.lb_show); this.Controls.Add(this.label1); this.Controls.Add(this.groupBox1); this.Controls.Add(this.button2);

this.Controls.Add(this.ImgToBase64); this.Controls.Add(this.pixel); this.Controls.Add(this.open);

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;

this.Name = \;

this.Text = \名片识别\;

((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.groupBox1.ResumeLayout(false); this.ResumeLayout(false);

this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button open; private System.Windows.Forms.Button pixel;

private System.Windows.Forms.PictureBox pictureBox2; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button ImgToBase64; private System.Windows.Forms.Button button2;

private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lb_show; }

}

后台代码:

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;

using System.Drawing.Imaging; using System.Text;

using System.Windows.Forms; using System.IO; using System.Net;

using System.Net.Security; using System.Web;

using System.Security.Cryptography.X509Certificates; using System.Diagnostics;

namespace mingpianshibie {

public partial class Form1 : Form {

Bitmap curBitmap; Bitmap bitmap;

String strbaser64; public Form1() {

本文来源:https://www.bwwdw.com/article/oc6f.html

Top