解决方案:python 根据网页布局识别 算法_我最近用Python写了一个算法

优采云 发布时间: 2022-11-27 08:34

  解决方案:python 根据网页布局识别 算法_我最近用Python写了一个算法

  Java基础学习04(数组与方法)

  数组和方法 1. 完成的目标 1. 掌握数组的定义、方法的使用、引用传递 2. 掌握方法及其重载 3. 使用方法接收和返回数组 4. Java新特性支持对数组的操作 2.数组的定义和使用 数组是...

  -g 与 -rdynamic

  [-g vs -rdynamic] -g选项和-rdynamic选项的区别: 1. -g选项新增的是调试信息(一系列.debug_xxx段),供相关调试工具使用,如gdb,并且可以剥离。2,- ...

  JavaScript--DOM基础(19)

  // DOM(Document Object Model)是文档对象模型,用于HTML和XML文档的API(应用程序编程接口);// DOM 描绘了一个分层的节点树,允许开发者添加/删除和修改页面。..

  

" />

  Linux相关

  可以使用secureCRT远程连接Linux系统,进入tomcat,启动tomcat:bin/startup.sh查看实时日志状态:tail -f logs/catalina.out

  UWP手绘视频创作工具技术分享系列

  开头先说说写这篇文章的初衷。刚来画图的时候,通读了UWP App的代码,发现里面确实有很多高深的技术点,也有很多问题,比如可扩展性、耦合性、性能、功能等等。所以我们决定从头开始重构这个产品,做...

  【转载】Netty

  转载自什么是 Netty?本质:JBoss制作的Jar包用途:快速开发高性能、高可靠的web服务器和客户端程序优点:提高...

  Python selenium-webdriver浏览器常用操作(十)

  

" />

  浏览器常用的一些方法和属性其实都是很简单的方法,但是在实际测试过程中却经常用到。浏览器加载url方法:get(url) 例子:driver.get("http//: ...

  node.js读写文件

  关于node.js的读写操作,应用场景非常多。例如,在一个这样的场景中,如何获取全局令牌。这涉及写入和读取操作。写操作:var fs = require("fs"); ...

  Elasticsearch 5.4.3实战--Java API调用:搜索

  ES有多种查询方式。我自己的业务需要查询多个字段。具体实现类代码如下。包 com.cs99lzzs.elasticsearch.service.imp;导入java。……

  Apache 风暴安装

  安装过程参考这里的过程介绍() 安装过程需要安装3...

  解决方案:Android实现Unity3D下RTMP推送的示例

  目录数据采集

推送

  简单调用进程完成接口初始化后,调用 Push() 接口调用 OpenPusher()InitAndSetConfig()ClosePusher() 相关事件处理摘要

  屏幕捕获有两种方案:

  1、直接封装安卓原生截屏项目,在Unity中提供接口,获取画面数据,获取画面权限后推送;

  2.如果只需要获取Unity的表单或相机数据即可推送出去,则可以获取需要的原创

数据

  在 Unity 下推送,然后封装原生 RTMP 推送接口,调用原生 SDK 实现数据推送,这种做法的好处是可以自定义需要采集的数据内容,只要按照原生 SDK 提供的接口完成数据对接,具体实现见本文。

  本文以 Android 平台为例,介绍 Unity 环境中的 Android 平台 RTMP 推送,数据采集在 Unity 中完成,数据编码推送,调用 Daniu Live SDK(官方)安卓平台 RTMP 直播推送 SDK 原生库外部二次封装接口,高效实现 RTMP 推送。事不宜迟,我们先去看图,看看效果。

  下图是 Android 平台 Unity 环境抓取屏幕,编码推送到 RTMP 服务器,然后 Windows 平台播放器拉取 RTMP 流,为了方便延迟效果,特别是在 Unity 窗口中对 Android 端显示当前时间,可以看到整体延迟以毫秒为单位:

  数据采集

推送

  Unity 数据采集

相对简单,可以轻松获取 RGB24 数据:

  

" />

  texture_ = new Texture2D(video_width_, video_height_, TextureFormat.RGB24, false); texture_.ReadPixels(new Rect(0, 0, video_width_, video_height_), 0, 0, false);质地_。应用();

  然后打电话给texture_。GetRawTextureData();只需获取数据。

  获取数据后,调用原生SDK封装的NT_PB_U3D_OnCaptureVideoRGB24PtrData()接口完成数据下发。

  进程的简单调用

  private void Start() {game_object_ = this.gameObject.name;AndroidJavaClass android_class = new AndroidJavaClass(“com.unity3d.player.UnityPlayer”);java_obj_cur_activity_ = android_class。GetStatic(“currentActivity”);pusher_obj_ = new AndroidJavaObject(“com.daniulive.smartpublisher.SmartPublisherUnity3d”);NT_PB_U3D_Init();//NT_U3D_SetSDKClientKey(“”, “”, 0);btn_encode_mode_.onClick.AddListener(OnEncodeModeBtnClicked);btn_pusher_.onClick.AddListener(OnPusherBtnClicked);btn_mute_.onClick.AddListener(OnMuteBtnClicked); }

  接口初始化完成后,调用 Push() 接口

  public void Push() {if (is_running){Debug。日志(“推送”。返回;}if (texture_ != null){UnityEngine。对象。销毁(texture_);texture_ = 空;}video_width_ = 屏幕。宽度;video_height_ = 屏幕。高度;scale_width_ = (video_width_ + 1) / 2;scale_height_ = (video_height_ + 1) / 2;if (scale_width_ % 2 != 0){scale_width_ = scale_width_ + 1; }if (scale_height_ % 2 != 0){scale_height_ = scale_height_ + 1; }texture_ = new Texture2D(video_width_, video_height_, TextureFormat。RGB24, false);// 获取输入框的网址字符串网址 = input_url_。

  发短信。修剪();如果(!url。StartsWith(“rtmp://”)){push_url_ = “rtmp://192。168。0。199:1935/hls/stream1“;}else{push_url_ = url; }OpenPusher();如果 (pusher_handle_ == 0)返回;NT_PB_U3D_Set_Game_Object(pusher_handle_, game_object_);/* ++ 预推参数配置可以在这里添加 ++ */InitAndSetConfig();NT_PB_U3D_SetPushUrl(pusher_handle_, push_url_);/* — 可以在此处添加预推送参数配置 — */int 标志 = NT_PB_U3D_StartPublisher(pusher_handle_);if (flag == DANIULIVE_RETURN_OK){Debug。log(“推送成功。}else{Debug。日志错误(“推送失败”);}is_running = 真; }

  调用 OpenPusher()。

  private void OpenPusher() {if ( java_obj_cur_activity_ == null ){Debug.LogError(“getApplicationContext is null”); return; }int audio_opt = 1;int video_opt = 1;pusher_handle_ = NT_PB_U3D_Open(audio_opt、video_opt、video_width_、video_height_);if (pusher_handle_ != 0)Debug.Log(“NT_PB_U3D_Open success”);elseDebug.LogError(“NT_PB_U3D_Open fail”); }

  InitAndSetConfig()

  private void InitAndSetConfig() {if (is_hw_encode_){int h264HWKbps = setHardwareEncoderKbps(true, video_width_, video_height_);D ebug.Log(“h264HWKbps: ” + h264HWKbps);int isSupportH264HWEncoder = NT_PB_U3D_SetVideoHWEncoder(pusher_handle_, h264HWKbps);if (isSupportH264HWEncoder == 0){Debug.Log(“太好了,它支持 h.264 硬件编码器!”); }}else {if (is_sw_vbr_mode_) //H.264 software encoder{int is_enable_vbr = 1; int video_quality = CalVideoQuality(video_width_, video_height_, true); int vbr_max_bitrate = CalVbrMaxKBitRate(video_width_, video_height_);NT_PB_U3D_SetSwVBRMode(pusher_handle_, is_enable_vbr, video_quality, vbr_max_bitrate);//NT_PB_U3D_SetSWVideoEncoderSpeed(pusher_handle_, 2);}}NT_PB_U3D_SetAudioCodecType(pusher_handle_, 1);NT_PB_U3D_SetFPS(pusher_handle_,25);NT_PB_U3D_SetGopInterval(pusher_handle_, 25*2);//NT_PB_U3D_SetSWVideoBitRate(pusher_handle_, 600, 1200); }

  

" />

  关闭推杆()

  private void ClosePusher() {if (texture_ != null){UnityEngine.Object.Destroy(texture_); texture_ = null; }int 标志 = NT_PB_U3D_StopPublisher(pusher_handle_);if (flag == DANIULIVE_RETURN_OK){Debug.Log(“Stop success..”); }else{Debug.LogError(“Stop Failed..”); }标志 = NT_PB_U3D_Close(pusher_handle_);if (flag == DANIULIVE_RETURN_OK){Debug.Log(“Close success..”); }else{Debug.LogError(“Close failed..”); }pusher_handle_ = 0;NT_PB_U3D_UnInit();is_running = 假; }

  为了便于测试,Update() 刷新当前时间:private void Update() {//Get current time hour = DateTime.Now.Hour; min = DateTime.Now.Minute; 毫秒 = DateTime.Now.Millisecond; second = DateTime.Now.Second; year = DateTime.Now.Year;

  month = DateTime.Now.Month; day = DateTime.Now.Day;GameObject.Find(“Canvas/Panel/LableText”).GetComponent().text = string.format(“{0:D2}:{1:D2}:{2:D2}:{3:D2} ” + “{4:D4}/{5:D2}/{6:D2}”, 小时, 分钟, 秒, 毫秒, 年, 月, 天); }

  相关事件处理

  public void onNTSmartEvent(string param) {if (!param。收录

(“,”)){调试。Log(“[onNTSmartEvent] android pass parameter error”);返回;}string[] strs = param。Split(',');字符串 player_handle =strs[0];字符串代码 = strs[1];字符串参数1 = strs[2];字符串参数2 = strs[3];字符串参数3 = strs[4];字符串参数4 = strs[5];D ebug。Log(“[onNTSmartEvent] code: 0x” + Convert。到字符串(转换。ToInt32(代码), 16));字符串 publisher_event = “”;开关(转换。ToInt32(code)){case EVENTID。EVENT_DANIULIVE_ERC_PUBLISHER_STARTED:publisher_event =“开始。

  。";破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_CONNECTING:publisher_event = “正在连接...”;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_CONNECTION_FAILED:publisher_event = “连接失败...”;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_CONNECTED:publisher_event = “连接成功...”;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_DISCONNECTED:publisher_event = “连接丢失...”;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_STOP:publisher_event = “关闭...”;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_RECORDER_START_NEW_FILE: publisher_event = “启动一个新的录制文件 : ” + param3;破;案例事件 ID。

  EVENT_DANIULIVE_ERC_PUBLISHER_ONE_RECORDER_FILE_FINISHED:publisher_event = “已生成录制文件 : ” + param3;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_SEND_DELAY:publisher_event = “发送延迟: ” + 参数1 + “ 帧: ”+ 参数2;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_CAPTURE_IMAGE:publisher_event = “快照: ” + 参数1 + “ 路径: ”+ 参数3;如果(转换。ToInt32(param1) == 0){publisher_event = publisher_event + “Snapshot intercepted success .”; }else{publisher_event = publisher_event + “无法拍摄快照。”; }破;案例事件 ID。EVENT_DANIULIVE_ERC_PUBLISHER_RTSP_URL:publisher_event = “RTSP 服务 URL: ” + param3;破;案例事件 ID。

  EVENT_DANIULIVE_ERC_PUSH_RTSP_SERVER_RESPONSE_STATUS_CODE:publisher_event = “收到 RTSP 状态代码,代码 ID:” + param1 + “,RTSP URL:” + param3;破;案例事件 ID。EVENT_DANIULIVE_ERC_PUSH_RTSP_SERVER_NOT_SUPPORT:publisher_event = “服务器不支持 RTSP 推送,RTSP URL 推送:” + param3;破;}调试。日志(publisher_event); }

  总结

  通过上述流程,可以实现Unity环境下屏幕或*敏*感*词*数据的RTMP推送和播放,体验毫秒级,有兴趣的开发者可以酌情参考。以上是 Android 在 Unity3D 下实现 RTMP

  推送的示例详情,有关 Android 在 Unity3D 下实现 RTMP 推送的更多信息,请关注其他相关文章!

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线