当前位置: 首页 > news >正文

做的好的网站欣赏如何做网销

做的好的网站欣赏,如何做网销,用自己的电脑做服务器搭建网站,刚做网站和搜出来的不一样一、灰度图像的传输 c#端的传输 //读入文件夹中的图像 Mat img2 new Mat(file, ImreadModes.AnyColor); //将图像的数据转换成和相机相同的buffer数据 byte[] image_buffer new byte[img2.Width * img2.Height]; int cn img2.Channels(); //通道数 if (cn 1){//将图像的数…

一、灰度图像的传输

c#端的传输

//读入文件夹中的图像
Mat img2 = new Mat(file, ImreadModes.AnyColor);
//将图像的数据转换成和相机相同的buffer数据
byte[] image_buffer = new byte[img2.Width * img2.Height];
int cn = img2.Channels(); //通道数
if (cn == 1){//将图像的数据转换成和相机相同的buffer数据Marshal.Copy(img2.Data, image_buffer, 0, img2.Width * img2.Height);}#传输
string result = RequestsPostbuffer(Url, image_buffer);

python 端的解析

receiveData = request.get_data() #相机的buffer转换使用img_cv=np.frombuffer(receiveData,dtype=np.uint8).reshape(1024,1224) #opencv格式

二、彩色图像的传送

c#端的传输

//打开图像,将图像转换成buffer用下面这段代码if (OpenFileDialog1.ShowDialog() == DialogResult.OK){//读入文件夹中的图像Mat img2 = new Mat(OpenFileDialog1.FileName, ImreadModes.AnyColor);byte[] image_buffer = new byte[img2.Width * img2.Height*3];int cn = img2.Channels(); //通道数if (cn == 3){string show_mssage = "测试图像的通道数是:" + Convert.ToString(cn);//将图像的数据转换成和相机相同的buffer数据listBox1.Items.Add(show_mssage);Marshal.Copy(img2.Data, image_buffer, 0, img2.Width * img2.Height);}else{string show_mssage = "错误!!!!!!!!!!!!测试图像需要单通道的灰度图";listBox1.Items.Add(show_mssage);}

python 端的解析

 #相机的buffer转换使用img_cv=np.frombuffer(receiveData,dtype=np.uint8).reshape(4096,3500,3) #opencv格式

三、整个工程的实现

python 端的实现

# !/usr/bin/python
# -*- coding: UTF-8 -*-
# python服务器如果需要访问静态的文件,都需要放到static这个指定的文件夹。from flask import Flask, jsonify, request
from flask import render_template
from wtforms import StringField, Form
from wtforms.validators import DataRequiredimport jsonimport cv2
import numpy as npfrom comparison_boxandpdf import Comparison_boxandpdf
from skimage.segmentation import mark_boundariesfrom PIL import Imageimport timeimport base64
import io
from io import BytesIO import easyocrimport halcon as ha
from halcon.numpy_interop import himage_from_numpy_array
from halcon.numpy_interop import himage_as_numpy_arrayfrom gevent import pywsgiimport requestsfrom algorithm_configuration import Read_iniconfig#异常码定义
miss_model = 0 try:#*********************************初始化******************************Comparison_tools=Comparison_boxandpdf()#配置文件解析,主要是根据配置文件中pdf的路径解析出pdf的图像config_Path = 'C:/code/box_ocr/cinfig_ini/algorithm_configuration.ini'read_ini=Read_iniconfig(config_Path)read_bool,dict=read_ini.read_pdfbox_detection_cfg()#模型及图像检测加速初始化pdfbox_model_path=dict.get('pdfbox_model_path')pdfbox_ini_image_path=dict.get('pdfbox_ini_image_path')pdfbox_pdf_path=dict.get('pdfbox_pdf_path')pdfbox_easyocr_thresh=float(dict.get('pdfbox_easyocr_thresh'))print("模型路径",pdfbox_model_path)print("模型初始化加速测试图像的路径为:",pdfbox_ini_image_path)print("阈值",pdfbox_easyocr_thresh)print("PDF的路径为",pdfbox_pdf_path)# #先加载字符识别模型# img_init = cv2.imread(pdfbox_ini_image_path)# reader = easyocr.Reader(['ch_sim', 'en'], gpu=True) # 使用GPU加速# results_init = reader.readtext(img_init)halcon_find_txt_model_path='C:/code/box_ocr/model/Document_Rej.omc'except Exception as e:print("模型路径或者测试图像的路径不正确 ", e)
finally:print("***********************************************算法初始化完成。可以进行通信进行检测********************************")app = Flask(__name__)
app.logger.info('Finished Start Flask!')# 开始数据转移
@app.route('/BOX_OCR/', methods=['POST'])
def startTransfer(name=None):if request.method == 'POST':receiveData = request.get_data()    # 接收图像的buffer数据  时间1ms#相机的buffer转换使用img_cv=np.frombuffer(receiveData,dtype=np.uint8).reshape(4096,3500,3) #opencv格式save_image_path_pdf='C:/code/box_ocr/debug_image_show/warpPerspective_result/empty_image_rectification.bmp'cv2.imwrite(save_image_path_pdf,img_cv)error_code=1if(error_code==1):data = {'pdf_pdf': 1,'image_path':1,'number_diff_result':1,'image_result':encoded_image,'image_result_pdf':encoded_image_pdf}else:encoded_image="no"encoded_image_pdf="no"data = {'pdf_pdf': 1,'image_path': 1,'number_diff_result':1,'image_result':encoded_image,'image_result_pdf':encoded_image_pdf}json_data = json.dumps(data)return json_dataif __name__ == '__main__':# app.run(host='127.2.2.0', port=8001, debug=True, threaded=True)# debug=True 时设置的多线程无效# 多线程和多进程功能只能开一个     1.processes=True      2.threaded=Trueserver = pywsgi.WSGIServer(('127.2.2.0', 8001), app)server.serve_forever()

c#端的实现

//选择待检测的PDF的文件private void Button_读取图片2_Click(object sender, EventArgs e){OpenFileDialog1.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF";OpenFileDialog1.Title = "选择图像文件";int hv_Height, hv_Width;string log = "";//错误信息if (OpenFileDialog1.ShowDialog() == DialogResult.OK){// 获取选中的文件路径image_path= OpenFileDialog1.FileName;//string show_mssage = OpenFileDialog1.FileName;//listBox1.Items.Add(image_path);string show_mssage = "待检测的PDF文件的位置为:" + pdf_path;string show_mssage2 = "待检测的图像文件的位置为:" + image_path;listBox1.Items.Add(show_mssage);listBox1.Items.Add(show_mssage2);string path_totall = pdf_path + image_path;List<string> stringsList = new List<string>();stringsList.Add(pdf_path);stringsList.Add(image_path);string jsonParams = pdf_path + "#" + image_path;string paraUrlCoded = jsonParams;//System.Web.HttpUtility.UrlEncode(jsonParas);   byte[] payload;//将Json字符串转化为字节  payload = System.Text.Encoding.UTF8.GetBytes(jsonParams);string Url = "http://127.2.2.0:8001//BOX_OCR/";//功能网址string result = RequestsPostbuffer(Url, payload);if (result == null){MessageBox.Show("结果传回出错!", "提示:");}else{if (result.Contains("default")){log = "There is an error running the algorithm." + "\r\n" + result;}else{//对传送回来的结果进行解析//解析对象JObject JObject jo = (JObject)JsonConvert.DeserializeObject(result);string pdf_pdf = jo["pdf_pdf"].ToString();string image_path = jo["image_path"].ToString();string number_diff_result = jo["number_diff_result"].ToString();string image_result = jo["image_result"].ToString();string image_result_pdf = jo["image_result_pdf"].ToString();Console.WriteLine("pdf的路径为:" + pdf_pdf);Console.WriteLine("图像的路径为:" + image_path);Console.WriteLine("检测到的不同之处的个数为:" + number_diff_result);//解析算法处理后绘制处理后的图像-----------通过测试,回传结果图像的用时10ms不到image_result = image_result.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换byte[] result_image_buffer = Convert.FromBase64String(image_result);image_result_pdf = image_result_pdf.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换byte[] result_image_buffer_pdf = Convert.FromBase64String(image_result_pdf);//显示图像MemoryStream memStream = new MemoryStream(result_image_buffer);Image mImage = Image.FromStream(memStream);hv_Width = mImage.Width;hv_Height = mImage.Height;MemoryStream memStrea_pdf = new MemoryStream(result_image_buffer_pdf);Image mImage_pdf = Image.FromStream(memStrea_pdf);if (PictureBox1.Image != null) PictureBox1.Image.Dispose();if (PictureBox2.Image != null) PictureBox2.Image.Dispose();//PictureBox1.Image = mImage.Clone(new Rectangle(0, 0, mImage.Width, mImage.Height), mImage.PixelFormat);PictureBox1.Image = mImage_pdf;PictureBox2.Image = mImage;log = "单张图像测试成功。可以继续测试!!!!";listBox1.Items.Add(log);}}}else{MessageBox.Show("选择有误!", "提示:");}}/// <summary>/// 通过网络地址和端口访问数据/// </summary>/// <param name="Url">网络地址</param>/// <param name="payload">图像的buffer数据</param>/// <returns></returns>/// 客户端创建一个HTTPRequsetpublic string RequestsPostbuffer(string Url, byte[] payload){//*****************************************将客户端这边要传入的数据,进行数据 格式的转换,发送到服务端*******************************************string postContent = ""; // 接收服务端结果的字符串string strURL = Url;//创建一个HTTP请求  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);//Post请求方式  request.Method = "POST";//内容类型  表示具体请求中的媒体类型信息,application/json表示 JSON数据格式,可以传图像格式。二进制流等,参考链接:https://www.cnblogs.com/doit8791/p/7609413.htmlrequest.ContentType = "application/octet-stream";//设置请求的ContentLength   设置要发布的字符串的内容长度。request.ContentLength = payload.Length;//发送请求,获得请求流 Stream writer;try{writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象}catch (Exception){writer = null;MessageBox.Show("连接服务器失败!");return null;}//将请求参数写入流writer.Write(payload, 0, payload.Length);writer.Close();//关闭请求流//****************************************解析服务端处理的结果并返回处理结果给主程序********************************HttpWebResponse response;//检查是否收到服务端的回应,如果没有回应则错误提示try{//获得响应流response = (HttpWebResponse)request.GetResponse();}catch (WebException ex){response = ex.Response as HttpWebResponse;postContent = "default: The response is null." + "\r\n" + "Exception: " + ex.Message;}//对服务端接收到的数据进行解析if (response != null){try{//收到服务端给的回复流Stream s = response.GetResponseStream();//=创建一个读流的工具StreamReader sRead = new StreamReader(s);//将读取的结果的传送给字符串postContent = sRead.ReadToEnd();//关闭读取流工具sRead.Close();}catch (Exception e){postContent = "default: The data stream is not readable." + "\r\n" + e.Message;}}//将在服务端收到的解析数据回传,回传回去的是一个字符串的类型return postContent;//返回Json数据}


文章转载自:
http://bullterrier.c7629.cn
http://intercontinental.c7629.cn
http://manhattanization.c7629.cn
http://urheen.c7629.cn
http://fascia.c7629.cn
http://beplaster.c7629.cn
http://anemochory.c7629.cn
http://diel.c7629.cn
http://cig.c7629.cn
http://snide.c7629.cn
http://analogy.c7629.cn
http://ostinato.c7629.cn
http://afterlife.c7629.cn
http://glyceraldehyde.c7629.cn
http://squeak.c7629.cn
http://disconnected.c7629.cn
http://whacker.c7629.cn
http://scantly.c7629.cn
http://coquille.c7629.cn
http://reciprocator.c7629.cn
http://reposal.c7629.cn
http://aminoplast.c7629.cn
http://bosthoon.c7629.cn
http://hydrastine.c7629.cn
http://sollicker.c7629.cn
http://blindness.c7629.cn
http://isooctane.c7629.cn
http://katalyst.c7629.cn
http://pugmark.c7629.cn
http://quinquenniad.c7629.cn
http://phosphorolytic.c7629.cn
http://cocotte.c7629.cn
http://mastocytoma.c7629.cn
http://octopus.c7629.cn
http://gilderoy.c7629.cn
http://tetartohedral.c7629.cn
http://juicy.c7629.cn
http://sugarcane.c7629.cn
http://dogtrot.c7629.cn
http://wisconsin.c7629.cn
http://communist.c7629.cn
http://subopposite.c7629.cn
http://austronesia.c7629.cn
http://openwork.c7629.cn
http://albizzia.c7629.cn
http://humanize.c7629.cn
http://phytoflagellate.c7629.cn
http://crossjack.c7629.cn
http://nematicide.c7629.cn
http://fornix.c7629.cn
http://picrotoxin.c7629.cn
http://clearstarch.c7629.cn
http://literalize.c7629.cn
http://blackly.c7629.cn
http://fortunehunting.c7629.cn
http://monomaniacal.c7629.cn
http://guatemala.c7629.cn
http://robustious.c7629.cn
http://husbandage.c7629.cn
http://bedaze.c7629.cn
http://gutless.c7629.cn
http://levelly.c7629.cn
http://presser.c7629.cn
http://bowdlerize.c7629.cn
http://resect.c7629.cn
http://polyphylesis.c7629.cn
http://heliostat.c7629.cn
http://avuncular.c7629.cn
http://platinate.c7629.cn
http://tuscan.c7629.cn
http://mosquitocide.c7629.cn
http://immunodiffusion.c7629.cn
http://groupuscule.c7629.cn
http://indication.c7629.cn
http://androcentrism.c7629.cn
http://appressorium.c7629.cn
http://serendipper.c7629.cn
http://raa.c7629.cn
http://grissel.c7629.cn
http://adze.c7629.cn
http://damnum.c7629.cn
http://salmo.c7629.cn
http://lumberyard.c7629.cn
http://moniker.c7629.cn
http://triffidian.c7629.cn
http://chasten.c7629.cn
http://skittle.c7629.cn
http://epirote.c7629.cn
http://helper.c7629.cn
http://analogic.c7629.cn
http://offhandedly.c7629.cn
http://patroclus.c7629.cn
http://fluorocarbon.c7629.cn
http://myotropic.c7629.cn
http://chuse.c7629.cn
http://treacherousness.c7629.cn
http://candlestick.c7629.cn
http://lowering.c7629.cn
http://flagged.c7629.cn
http://entozoology.c7629.cn
http://www.zhongyajixie.com/news/91129.html

相关文章:

  • 无锡中小企业网站制作nba在线直播免费观看直播
  • 北京建设招聘信息网站百度官方推广
  • wordpress加速网站插件如何优化
  • 服务类网站建设软件商店安装
  • vs2010 iis 网站开发杭州seo关键字优化
  • 网站建设案例信息沐浴露营销软文
  • 织梦做的网站前面有不安全北京百度网站排名优化
  • 四川建设主管部门网站关键词搜索热度
  • 外贸公司网站建设方案seo网络优化师招聘
  • b2b商场网站建设淘宝关键词搜索排名
  • 网站改版后的推广办法线上营销课程
  • wordpress wpnavmenu小红书seo排名规则
  • 什么是网站版式南宁seo全网营销
  • 制作网页csdn怀来网站seo
  • 个人网站备案网站名称app软件开发
  • 想在意大利做购物网站百度网址大全下载到桌面
  • 寮步镇网站仿做seo优缺点
  • 新手做网站做那个百度竞价推广点击软件奔奔
  • 心理网站免费建设网站推广优化是什么意思
  • DW做网站下拉列表怎么做网站推广渠道
  • 网页制作工具常见的有java快速排名优化系统
  • 低代码开发平台哪个最好小时seo百度关键词点击器
  • 专业建站公司费用电商网络推广是什么
  • 做欧美贸易的主要有哪些网站市场调研报告怎么写的
  • web程序员自己做网站网络营销策略的概念
  • 聊城冠县网站建设推广渠道
  • 办公室装修专业网站青岛设计优化公司
  • 雄安建站服务百度关键词排名工具
  • cc彩球网站总代理怎么做最经典的营销案例
  • php做网站搜索框磁力岛引擎