秒合约系统开发(开发项目)丨秒合约交易所系统开发(方案逻辑)/案例分析/源码设计/程序开发

简介:   Web3.0通过将信息交互从屏幕转移到物理空间,改变了终端用户体验,因而也有称Web3.0为“空间网络(Spatial Web)”。该“空间网络”包括空间交互层(利用智能眼镜或语音等实现实时信息交互)、数字信息层(借助传感和数字映射为每一个对象创建数字孪生)和物理层(通过感观了解和体验的世界)。

  

  Web3.0通过将信息交互从屏幕转移到物理空间,改变了终端用户体验,因而也有称Web3.0为“空间网络(Spatial Web)”。该“空间网络”包括空间交互层(利用智能眼镜或语音等实现实时信息交互)、数字信息层(借助传感和数字映射为每一个对象创建数字孪生)和物理层(通过感观了解和体验的世界)。

  DAPP是去中心化应用程序/分布式的应用程序,是底层区块链平台生态上衍生的各种分布式应用,也是区块链世界中的基础服务提供方。将应用程序分布在不同节点上,通过共识机制和区块链平台来完成任务的应用程序,它本身就是去中心化,不依赖于任何中心化服务器,促使用户交易更加安全。

  数据作为新型生产要素,能为实体经济带来放大、叠加和倍增作用,是做强做优做大数字经济的关键。建立数据可信流通体系,增强数据的可用、可信、可流通、可追溯水平,是激活数据要素潜能、赋能实体经济的重要途径。区块链技术具有去中心化、共识机制、不可篡改、可以追溯、规则透明等特点。

  int backendType[2];

  net->getSessionInfo(session,MNN::Interpreter::BACKENDS,backendType);

  MNN_PRINT("Session Info:memory use%f MB,flops is%f M,backendType is%d,batch size=%dn",memoryUsage,flops,backendType[0],argc-2);

  //获取输出tensor的信息

  auto output=net->getSessionOutput(session,NULL);

  if(nullptr==output||output->elementSize()==0){

  MNN_ERROR("Resize error,the model can't run batch:%dn",shape[0]);

  return 0;

  }

  //定义真正输入数据inputUser

  std::shared_ptr<Tensor>inputUser(new Tensor(input,Tensor::TENSORFLOW));

  auto bpp=inputUser->channel();

  auto size_h=inputUser->height();

  auto size_w=inputUser->width();

  MNN_PRINT("input:w:%d,h:%d,bpp:%dn",size_w,size_h,bpp);

  //依次填充batch张图片数据到inputUser

  for(int batch=0;batch<shape[0];++batch){

  auto inputPatch=argv[batch+2];

  int width,height,channel;

  auto inputImage=stbi_load(inputPatch,&width,&height,&channel,4);

  if(nullptr==inputImage){

  MNN_ERROR("Can't open%sn",inputPatch);

  return 0;

  }

  MNN_PRINT("origin size:%d,%dn",width,height);

  //trans是图像变换矩阵,可以用来做缩放、旋转等图像变换,避免引入opencv

  Matrix trans;

  //Set transform,from dst scale to src,the ways below are both ok

  #ifdef USE_MAP_POINT

  float srcPoints[]={

  0.0f,0.0f,

  0.0f,(float)(height-1),

  (float)(width-1),0.0f,

  (float)(width-1),(float)(height-1),

  };

  float dstPoints[]={

  0.0f,0.0f,

  0.0f,(float)(size_h-1),

  (float)(size_w-1),0.0f,

  (float)(size_w-1),(float)(size_h-1),

  };

  trans.setPolyToPoly((Point)dstPoints,(Point)srcPoints,4);

  #else

  trans.setScale((float)(width-1)/(size_w-1),(float)(height-1)/(size_h-1));

  #endif

  //MNN中使用CV::ImageProcess进行图像处理

  ImageProcess::Config config;

  config.filterType=BILINEAR;

  float mean[3]={103.94f,116.78f,123.68f};

  float normals[3]={0.017f,0.017f,0.017f};

  //float mean[3]={127.5f,127.5f,127.5f};

  //float normals[3]={0.00785f,0.00785f,0.00785f};

  ::memcpy(config.mean,mean,sizeof(mean));

  ::memcpy(config.normal,normals,sizeof(normals));

  //图像格式转换:RGBA(.png)->BGR(模型输入要求)

  config.sourceFormat=RGBA;

  config.destFormat=BGR;

  std::shared_ptr<ImageProcess>pretreat(ImageProcess::create(config));

  pretreat->setMatrix(trans);

  //执行图像处理

  pretreat->convert((uint8_t)inputImage,width,height,0,inputUser->host<uint8_t>()+inputUser->stride(0)batch*inputUser->getType().bytes(),size_w,size_h,bpp,0,inputUser->getType());

  stbi_image_free(inputImage);

  }

  //拷贝真实输入数据到会话中

  input->copyFromHostTensor(inputUser.get());

  //执行会话

  net->runSession(session);

  auto dimType=output->getDimensionType();

  if(output->getType().code!=halide_type_float){

  dimType=Tensor::TENSORFLOW;

  }

  //定义输出数据承接outputUser

  std::shared_ptr<Tensor>outputUser(new Tensor(output,dimType));

  //拷贝到outputUser

  output->copyToHostTensor(outputUser.get());

  //获取输出类型:可能是数据类型?

  auto type=outputUser->getType();

  //对每一张图

  for(int batch=0;batch<shape[0];++batch){

  MNN_PRINT("For Image:%sn",argv[batch+2]);

  auto size=outputUser->stride(0);

  //用std::pair承接序号,置信度

  std::vector<std::pair<int,float>>tempValues(size);

  //对每种输出类型,分别解析

  if(type.code==halide_type_float){

  auto values=outputUser->host<float>()+batch*outputUser->stride(0);

  for(int i=0;i<size;++i){

  tempValues<i>=std::make_pair(i,values<i>);

  }

  }

  if(type.code==halide_type_uint&&type.bytes()==1){

  auto values=outputUser->host<uint8_t>()+batch*outputUser->stride(0);

  for(int i=0;i<size;++i){

  tempValues<i>=std::make_pair(i,values<i>);

  }

  }

  if(type.code==halide_type_int&&type.bytes()==1){

  auto values=outputUser->host<int8_t>()+batch*outputUser->stride(0);

  for(int i=0;i<size;++i){

  tempValues<i>=std::make_pair(i,values<i>);

  }

  }

  //Find Max按置信度排序

  std::sort(tempValues.begin(),tempValues.end(),

  {return a.second>b.second;});

  //打印top10信息

  int length=size>10?10:size;

  for(int i=0;i<length;++i){

  MNN_PRINT("%d,%fn",tempValues<i>.first,tempValues<i>.second);

  }

  }

  return 0;

  }

相关文章
|
2月前
|
安全 API 网络安全
数字货币交易所系统开发详细功能/需求项目/教程步骤/指南逻辑
Developing a digital currency exchange system is a complex project that requires multiple steps to complete. The following are the general steps for developing a digital currency exchange system
|
2月前
|
安全 区块链
数字货币秒合约/交易所系统开发详细程序/案例项目/需求设计/方案逻辑/源码步骤
The development of a digital currency second contract/exchange system requires the following functions:
|
2月前
|
安全 API 区块链
数字货币合约交易系统开发教程指南丨案例项目丨功能策略丨需求分析丨源码详细
Developing a digital currency contract trading system is a complex project, and the following are possible project requirements details:
|
2月前
|
安全
什么是外汇交易所系统开发步骤详细丨案例设计丨需求逻辑丨源码项目
The foreign exchange system is one of the key systems in the financial field, providing investors with foreign exchange trading services. When developing a foreign exchange exchange system
|
12月前
|
存储 供应链 算法
交易所项目系统开发案例详细丨交易所系统开发(源码逻辑)/方案设计/源码程序
  广义来讲,区块链技术是利用块链式数据结构来验证与存储数据、利用分布式节点共识算法来生成和更新数据、利用密码学的方式保证数据传输和访问的安全、利用由自动化脚本代码组成的智能合约来编程和操作数据的一种全新的分布式基础架构与计算方式。
|
2月前
|
监控 供应链 安全
dapp智能合约只涨不跌系统开发步骤详细/开发案例/功能需求/方案项目/源码功能
需求分析:明确系统的功能需求和业务逻辑。确定系统需要支持的资产类型、交易规则和逻辑限制等。
|
9月前
|
安全 区块链
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
阐述永续合约交易所系统开发方案逻辑及案例项目丨源码程序
|
10月前
|
安全
交易所开发正式版丨交易所系统开发详细指南/案例开发/功能需求/方案逻辑/项目设计/源码程序
Business requirement analysis: A detailed understanding of the business requirements of the exchange, including supported transaction types, transaction pair settings, fee mechanisms, user management, etc., to ensure that the development is in line with actual needs.
|
10月前
|
vr&ar
DeFi流动性质押项目系统开发详细步骤/方案逻辑/案例开发/源码程序
DeFi (Decentralized Finance) pledge mining is a blockchain based financial activity that combines pledge and mining mechanisms. It provides a new way to provide benefits to participants and promote the development of a centralized financial ecosystem.
|
10月前
|
区块链 安全
区块链交易所系统开发详细指南丨交易所系统开发功能逻辑/方案介绍/案例设计/逻辑项目/源码出售
User experience: The interface and user experience of blockchain exchanges should be intuitive, user-friendly, and easy to use and navigate. The platform should provide a simple and clear trading interface to facilitate users' buying and selling operations.