可视化大屏中用vue实现海康威视AR鹰眼画面(物联网项目—涉及硬件设备的连接)

这篇具有很好参考价值的文章主要介绍了可视化大屏中用vue实现海康威视AR鹰眼画面(物联网项目—涉及硬件设备的连接)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

具体效果可参照海康公众号的演示视频https://mp.weixin.qq.com/s/K7C8BJGgwq3E1woXK7F6SQ

项目效果图:

可视化大屏中用vue实现海康威视AR鹰眼画面(物联网项目—涉及硬件设备的连接)
可视化大屏中用vue实现海康威视AR鹰眼画面(物联网项目—涉及硬件设备的连接)

能够在项目中播放鹰眼视频,其实前端的代码很少。

因为海康威视的AR鹰眼视频已经做成了一个集成控件,也就是一套完整的系统,相当于AR画面里面的东西都不需要重新写,只需要在自己的项目中调用AR控件的开关即可。

前提是需要获取已有的海康鹰眼设备的ip,端口号,账号和密码(需要海康公司提供),并且需要拉网络专线到视频监控室,当海康威视的运维安装好系统后接好网后,前端获取到海康的arIndexCode就可以看到鹰眼视频了。

重点是选取项目需要的部分,加入到自己的项目中就可以了;

html文件demo(har.min.js文件需要海康提供)

<!DOCTYPE html>
<htmllang="en">
  <head>
    <metacharset="UTF-8"/>
    <metahttp-equiv="X-UA-Compatible"content="IE=edge"/>
    <metaname="viewport"content="width=device-width, initial-scale=1.0"/>
    <title>ARWebControl</title>
    <linkhref="./index.css"rel="stylesheet">
  </head>
  <body>
    <divclass="wrapper">
      <divclass="dash-board">
        <divclass="board-item">
          <p>控件消息订阅(启动前订阅)</p>
          <divclass="board-content">
            <form>
              <label>消息回调</label
              ><textareaid="callbackMessage"rows="7"readonly></textarea>
            </form>
            <divclass="form-buttons">
              <buttononclick="registerEvent('ar_connect_timeout')">
                监听控件连接超时
              </button>
              <buttononclick="registerEvent('ar_custom_message')">
                监听自定义消息
              </button>
              <buttononclick="registerEvent('ar_scene_change')">
                监听高点场景变更
              </button>
              <buttononclick="registerEvent('ar_keydown')">
                监听AR控件按键
              </button>
              <buttononclick="registerEvent('ar_closed')">
                监听AR控件关闭
              </button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>控件初始化/启动</p>
          <divclass="board-content">
            <form>
              <label>平台IP</label><inputid="ip"value="10.19.185.97"/><label>平台端口</label
              ><inputid="port"value="443"/><label>登录方式</label
              ><selectid="loginType"value="0">
                <optionvalue="0">明文登录</option>
                <optionvalue="1">密文登录</option>
              </select>
              <label>用户名</label><inputid="userName"value="admin"/>
              <label>登录凭据</label><inputid="credential"value="Hik12345"/>
              <label>网域Id</label><inputid="domainId"value="0"/>
              <label>AR高点编号</label><inputid="arIndexCode"/>
              <label>控件WS端口</label><inputid="wsPort"value="8888"/>
              <label>静默运行</label><inputid="background"type="checkbox"/>
            </form>
            <divclass="form-buttons">
              <buttononclick="setupAR()">启动</button>
              <buttononclick="frontRun()">取消静默运行</button>
              <buttononclick="backRun()">静默运行</button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>控件显示隐藏与关闭</p>
          <divclass="board-content">
            <buttonclass="show-buttons"onclick="showAR()">显示控件</button>
            <buttonclass="show-buttons"onclick="hideAR()">隐藏控件</button>
            <buttonclass="show-buttons"onclick="closeAR()">关闭控件</button>
          </div>
        </div>
        <divclass="board-item">
          <p>切换AR场景</p>
          <divclass="board-content">
            <form><label>AR高点编号</label><inputid="indexCodeChange"/></form>
            <divclass="form-buttons">
              <buttononclick="changeARScene()">切换</button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>隐藏控件</p>
          <divclass="board-content">
            <form>
              <label>内部控件</label
              ><selectid="hideControl"value="1">
                <optionvalue="1">组织树</option>
                <optionvalue="2">地图</option>
                <optionvalue="3">底部按钮</option>
                <optionvalue="4">关闭/最小化按钮</option>
                <optionvalue="5">搜索框</option>
                <optionvalue="6">报警</option>
                <optionvalue="7">工具箱</option>
              </select>
            </form>
            <divclass="form-buttons">
              <buttononclick="hideARControl()">隐藏</button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>发送自定义消息</p>
          <divclass="board-content">
            <form>
              <label>自定义消息</label
              ><textareaid="customMessage"rows="4"></textarea>
            </form>
            <divclass="form-buttons">
              <buttononclick="sendCustomMessage()">发送</button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>设置视频预览窗口</p>
          <divclass="board-content">
            <form>
              <label>窗口显示状态</label>
              <selectid="windowShowStatus"value="0">
                <optionvalue="0">显示</option>
                <optionvalue="1">隐藏</option>
                <optionvalue="2">关闭</option>
              </select>
              <label>监控点编号</label>
              <inputid="windowCameraIndexCode"/>
              <label>窗口标题</label>
              <inputid="windowTitle"/>
              <label>窗口X坐标</label>
              <inputid="windowX"value="0"/>
              <label>窗口Y坐标</label>
              <inputid="windowY"value="0"/>
            </form>
            <divclass="form-buttons">
              <buttononclick="setWindowStatus()">设置</button>
            </div>
          </div>
        </div>
        <divclass="board-item">
          <p>批量设置视频预览窗口位置</p>
          <divclass="board-content">
            <form>
              <label>已打开窗口</label
              ><select
                id="selectedVideo"
                value="请选择监控点"
                onchange="onSelectedItem(this.options[this.options.selectedIndex].value)"
              >
                <optionvalue="-1">请选择监控点</option>
              </select>
              <label>监控点编号</label><inputid="openedVideoIndex"/>
              <label>监控点名称</label><inputid="openedVideoName"/>
              <label>窗口X</label><inputid="openedVideoX"value="0"/>
              <label>窗口Y</label><inputid="openedVideoY"value="0"/>
            </form>
            <divclass="form-buttons">
              <buttononclick="batchMove()">批量移动</button>
            </div>
          </div>
        </div>
      </div>
      <divid="ar-div"></div>
    </div>
    <scripttype="text/javascript">
      this.showedVideoInfo= [];
      /**
       * 注册AR控件事件
       */
      functionregisterEvent(eventName) {
        window.control=har.ARWebControl.getInstance();
        consttextareaDom=document.getElementById("callbackMessage");
        control.on(eventName, (msg) => {
          switch (eventName) {
            case"ar_connect_timeout":
              textareaDom.value+=getMessage(
                "AR控件连接超时,请检查:1.是否安装AR客户端;2.登录信息是否正确;3.WS端口是否被占用;4.查看客户端日志确定原因。"
              );
              break;
            case"ar_custom_message":
              textareaDom.value+=getMessage(
                `接收来自AR传递的自定义消息:\n${msg}`
              );
              break;
            case"ar_scene_change":
              textareaDom.value+=getMessage(
                `AR高点场景变更:\n高点内部编号:${msg.sceneIndex}\n高点编号:${msg.sceneCode}\n高点名称:${msg.sceneName}`
              );
              break;
            case"ar_keydown":
              textareaDom.value+=getMessage(`AR内按键触发:${msg}`);
              break;
            case"ar_closed":
              textareaDom.value+=getMessage("AR控件关闭");
          }
        });
      }
      functiongetMessage(msg) {
        return`====================================\n${msg}\n====================================\n`;
      }
      /**
       *  启动AR
       */
      functionsetupAR() {
        window.control=har.ARWebControl.getInstance();
        consttextareaDom=document.getElementById("callbackMessage");
        control
          .setup({
            domId: "ar-div",
            loginType: +getInput("loginType"),
            ip: getInput("ip"),
            port: getInput("port"),
            userName: getInput("userName"),
            credentials: getInput("credential"),
            domainId: getInput("domainId"),
            arIndexCode: getInput("arIndexCode"),
            websocketPort: getInput("wsPort"),
            visible: !getInput("background"),
            processName:"chrome"
          })
          .then(() => {
            textareaDom.value+=getMessage("AR控件启动成功");
          })
          .catch((err) => {
            console.error(err.msg);
            textareaDom.value+=getMessage("AR控件启动失败");
          });
      }
      /**
       * 取消AR静默展示状态
       */
      functionfrontRun() {
        window.control?.setARShowMode(false);
      }
      /**
       * AR静默显示
       */
      functionbackRun() {
        window.control?.setARShowMode(true);
      }
      functiongetInput(id) {
        returndocument.getElementById(id).type==="checkbox"
          ?document.getElementById(id).checked
          : document.getElementById(id).value;
      }
      /**
       * 显示AR
       */
      functionshowAR() {
        letarDom=document.getElementById("ar-div");
        arDom.style="display:block;";
      }
      /**
       * 隐藏AR
       */
      functionhideAR() {
        letarDom=document.getElementById("ar-div");
        arDom.style="display:none;";
      }
      /**
       * 关闭AR
       */
      functioncloseAR() {
        window.control
          ?.close()
          .then(() => {
            consttextareaDom=document.getElementById("callbackMessage");
            textareaDom.value+=getMessage("JS关闭AR控件成功");
          })
          .catch((err) => {
            console.error(err.msg);
          });
      }
      /**
       * 切换AR高点场景
       */
      functionchangeARScene() {
        window.control?.changeARScene(getInput("indexCodeChange")).then(
          (ret) => {
            console.log("成功发送切换高点场景命令");
          },
          (err) => {
            console.error(err.msg);
          }
        );
      }
      /**
       * 隐藏AR内部的控件
       */
      functionhideARControl() {
        window.control
          ?.setControlsVisibility([getInput("hideControl")])
          .catch((err) => {
            console.error(err.msg);
          });
      }
      /**
       * 发送自定义消息
       */
      functionsendCustomMessage() {
        window.control
          ?.sendBusinessInfo(getInput("customMessage"))
          .catch((err) => {
            console.error(err.msg);
          });
      }
      /**
       * 设置视频预览窗口状态
       */
      functionsetWindowStatus() {
        conststatus=getInput("windowShowStatus");
        constname=getInput("windowTitle");
        constindexCode=getInput("windowCameraIndexCode");
        constleft=getInput("windowX");
        consttop=getInput("windowY");
        window.control
          ?.setVideoWindow(status, { indexCode, name, left: +left, top: +top })
          .catch((err) => {
            console.error(err.msg);
          });
        letinfo=this.showedVideoInfo.find((x) =>x.code==indexCode);
        if (info) {
          info.title=name;
          info.x=left;
          info.y=top;
          if (status===har.ARWindowStatus.CLOSE) {
            letindex=this.showedVideoInfo.indexOf(info);
            if (index>-1) {
              this.showedVideoInfo.splice(index, 1);
            }
          }
        } else {
          if (status===har.ARWindowStatus.VISIBLE) {
            this.showedVideoInfo.push({
              title: name,
              code: indexCode,
              x: left,
              y: top,
            });
          }
        }
        updateVideoList();
      }
      /**
       * 批量设置视频窗口位置
       */
      functionbatchMove() {
        letselect=document.getElementById("selectedVideo");
        this.onSelectedItem(select.options[select.options.selectedIndex]);
        letwindowList=this.showedVideoInfo.map((item) => {
          return {
            left: +item.x,
            top: +item.y,
            indexCode: item.code,
            name: item.title,
          };
        });
        window.control?.setVideoWindowList(windowList).catch((err) => {
          console.error(err.msg);
        });
      }
      /**
       * 选择一个已打开的窗口
       */
      functiononSelectedItem(v) {
        if (parseInt(v) ===-1) {
          this.lastSelectInfo=null;
          document.getElementById("openedVideoIndex").value="";
          document.getElementById("openedVideoName").value="";
          document.getElementById("openedVideoX").value=0;
          document.getElementById("openedVideoY").value=0;
          return;
        }
        if (this.lastSelectInfo) {
          this.lastSelectInfo.x=parseInt(
            document.getElementById("openedVideoX").value
          );
          this.lastSelectInfo.y=parseInt(
            document.getElementById("openedVideoY").value
          );
        }
        letinfo=this.showedVideoInfo.find((x) =>x.code==v);
        if (info) {
          document.getElementById("openedVideoIndex").value=info.code;
          document.getElementById("openedVideoName").value=info.title;
          document.getElementById("openedVideoX").value=info.x;
          document.getElementById("openedVideoY").value=info.y;
        }
        this.lastSelectInfo=info;
      }
      /**
       * 记录已打开的视频窗口信息
       */
      functionupdateVideoList() {
        letselect=document.getElementById("selectedVideo");
        select.options.length=1;
        if (this.showedVideoInfo.length==0) {
          this.onSelectedItem("-1");
        }
        this.showedVideoInfo.forEach((item) => {
          select.options.add(newOption(item.title, item.code));
        });
      }
    </script>
    <scriptsrc="./har.min.js"></script>
  </body>
</html>
​

vue代码:

  1. 放置跳转鹰眼画面的盒子

<div id="ar-div"></div>

2.将海康ARweb控件的har.min.js文件放到项目中,在页面中引入;

import har from "../home/components/AR/har.min";

3.只需要加入开启控件的API即可直接进入到海康的鹰眼系统;

setupAR() {
  if (this.siteId == "23") {
  const control = har.ARWebControl.getInstance();
  control
    .setup({
      domId: "ar-div",//鹰眼画面的盒子
      loginType: 0,
      ip: "10.19.185.97",//AR鹰眼平台IP(海康提供的)
      port: "443",//AR鹰眼平台端口(海康提供的)
      userName: "admin",//平台用户名(海康提供的)
      credentials: "Hik12345",//平台密码(海康提供的)
      domainId: "0",//网域id
      arIndexCode: "gh001",//AR高点编号就是用于播放鹰眼视频的id(拉好鹰眼专线后才能确定)
      websocketPort: "8888",//控件WS端口
      visible: true,//控制鹰眼窗口是否可见
      processName: "chrome",//默认浏览器
    })
    .then(() => {
      this.isShow = true;
      // alert("控件启动成功")
    })
    .catch((err) => {
      console.error(err.msg);
      // alert("AR控件启动失败");
    });
}else {
        this.$message.warning("该工地暂无全景设备");
      }

4.点击坐标(site)后进入鹰眼文章来源地址https://www.toymoban.com/news/detail-452005.html

 const ARBtn = document.querySelector("#ar");
 ARBtn.onclick = this.setupAR;

到了这里,关于可视化大屏中用vue实现海康威视AR鹰眼画面(物联网项目—涉及硬件设备的连接)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 可视化大屏:mapbox+vue全攻略

    如题图,mapbox是一个支持真3D地形展示的webGIS框架,与常用的Leaflet、Cesium和Openlayers并称四大框架,本文将介绍mapbox-gl js 在 vue 中的用法。 各位可以自行搜索上面提到的或者其他的webGIS框架或者集成服务商,可以很轻松的比较出mapbox的优势: 支持3D地形、3D模型 支持多种坐标

    2023年04月24日
    浏览(38)
  • 【python可视化大屏】使用python实现可拖拽数据可视化大屏

    我在前几期分享了关于爬取weibo评论的爬虫,同时也分享了如何去进行数据可视化的操作。但是之前的可视化都是单独的,没有办法在一个界面上展示的。这样一来呢,大家在看的时候其实是很不方便的,就是没有办法一目了然的看到数据的规律。为了解决这个问题我使用p

    2024年02月03日
    浏览(42)
  • 【可视化大屏-3d机房监控】Vue与three.js搭建可视化机房监控

    演示网址:http://jstopo.top网站地址 3d机房地址:http://jstopo.top/threeTopo/#/monitor/index

    2024年03月10日
    浏览(42)
  • Echarts实现可视化大屏

    手把手带你做出一个可视化大屏,轻松完成期末大作业。 关注公众号” Python爬虫与数据分析 “回复“ 可视化大屏 ”获取代码及数据 涉及到的技术:Echarts、HTML、css、JavaScript Echarts官网: https://echarts.apache.org/handbook/zh/concepts/axis/ 目录 1、echarts同时展示多幅图 2、使用css优化

    2024年02月09日
    浏览(86)
  • Vue3 +Echarts5 可视化大屏——屏幕适配

    项目基于Vue3 + Echarts5 开发,屏幕适配是使用 scale 方案 Echarts组件按需引入,减少打包体积 地图组件封装(全国省份地图按需加载) 效果图: 大屏适配常用的方案有 rem + vw/vh 和 scale 。 rem + vw/vh 方案 结合使用rem(相对于根元素字体大小的单位)和vw/vh(视窗宽度/高度的单位

    2024年02月15日
    浏览(38)
  • Vue3 + Vite + TypeScript + dataV 打造可视化大屏

    网上有许多开源的可视化大屏项目,但是分析之后,还是想自己从 0 搭建一个可视化大屏项目,毕竟 Vue 一直在更新,自己搭建的可以使用最新版本的 Vue ,如果对版本没有太多要求的小伙伴们选择那些开源项目的基础上去修改也是很不错的。其次自己搭建一个项目,可以更好

    2024年02月03日
    浏览(33)
  • 【vue2可视化开发】新手会遇到的问题——大屏自适应

    开发可视化大屏第一步,必须要考虑适配不同屏幕的问题,在网络上查看资料,总结了一个目前最适合可视化开发的自适应方案——v-scale-screen组件 1. 安装 注:vue2使用v-scale-screen@1.0.0版本,vue3使用v-scale-screen@2.0.0版本 2. 在main.js中引用 3. 在vue组件中使用 v-scale-screen会将页面等

    2023年04月21日
    浏览(32)
  • 基于Echarts+Vue3的低代码可视化数据大屏拖拽设计器 vue拖拽设计大屏

    本产品是一款基于Vue3开发的可视化数据大屏拖拽设计器。提供一种简单易用的拖拽式数据可视化大屏设计方案,可帮助用户快速创建和定制自己的数据大屏,通过拖拽组件、调整布局和设置属性,实现数据展示的自由组合和个性化定制。 可视化编辑:通过拖拽组件、调整布

    2024年02月03日
    浏览(41)
  • ChatGPT 与前端技术实现制作大屏可视化

    像这样的综合案例实分析,我们可以提供案例,维度与指标数据,让ChatGPT与AIGC 帮写出完整代码,并进行一个2行2列的布局设置。 数据与指令如下: 商品名称    销量    目标    完成率 可乐    479    600    79.83% 雪碧    324    600    54.00% 红茶    379    600  

    2024年02月11日
    浏览(37)
  • 如何在移动端数据可视化大屏实现分析?

    本文由葡萄城技术团队于博客园原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具、解决方案和服务,赋能开发者。 项目想做数据可视化,想同时在PC端、手机端查看数据怎么办?业务主要关心的数据包括:销售数据、业绩达成、同比、环比,各

    2023年04月14日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包