1.修改webrtc使正常播放

湖北-大华摄像头
LAPTOP-S9HJSOEB\昊天 12 months ago
parent 88d2fe4f34
commit accea288f9

@ -42,7 +42,7 @@ html {--antd-wave-shadow-color: @primary-color;}
.ant-alert-info .ant-alert-icon {color: #1890ff;}
.ant-alert-warning {background-color: #fffbe6;border: 1px solid #ffe58f;}
.ant-alert-warning .ant-alert-icon {color: #faad14;}
.ant-alert-error {background-color: #fff1f0;border: 1px solid #ffa39e;}
.ant-alert-error {background-color: color(~`colorPalette("@{text-color-secondary}", 1)`);border: 1px solid #ffa39e;}
.ant-alert-error .ant-alert-icon {color: #f5222d;}
.ant-alert-close-icon {background-color: transparent;border: none;}
.ant-alert-close-icon .anticon-close {color: @text-color-secondary;}
@ -1377,7 +1377,7 @@ tr.ant-table-expanded-row:hover {background: #fbfbfb;}
.ant-tag-pink-inverse {color: #fff;background: #eb2f96;border-color: #eb2f96;}
.ant-tag-magenta {color: #eb2f96;background: #fff0f6;border-color: #ffadd2;}
.ant-tag-magenta-inverse {color: #fff;background: #eb2f96;border-color: #eb2f96;}
.ant-tag-red {color: #f5222d;background: #fff1f0;border-color: #ffa39e;}
.ant-tag-red {color: #f5222d;background: color(~`colorPalette("@{text-color-secondary}", 1)`);border-color: #ffa39e;}
.ant-tag-red-inverse {color: #fff;background: #f5222d;border-color: #f5222d;}
.ant-tag-volcano {color: #fa541c;background: #fff2e8;border-color: #ffbb96;}
.ant-tag-volcano-inverse {color: #fff;background: #fa541c;border-color: #fa541c;}

@ -6,7 +6,7 @@ export default {
},
getRealTimeList: {
method: "POST",
url: "/realTime",
url: "/cameraIo/realTimeCamera",
name: "获取实时监控列表"
},
getHistoryList: {
@ -243,6 +243,47 @@ export default {
name: '品规模板下载',
method: 'GET'
},
EaseAiController: {
url: '/EaseAiController',
name: 'easeai简单测试',
method: 'POST'
},
cameraIoConfigPage: {
url: '/cameraIo/config/page',
name: '获取列表',
method: 'POST'
},
cameraIoConfigAdd: {
url: '/cameraIo/config',
name: '新增预置点',
method: 'POST'
},
cameraIoConfigDel: {
url: '/cameraIo/config',
name: '删除预置点',
method: 'DELETE'
},
sseGetUid: {
url: '/sse/index',
name: '获取sseUid',
method: 'GET'
},
getDeviceTree: {
url: '/cameraIo/getDeviceTree',
name: '获取设备树',
method: 'POST'
},
sseClose: {
url: '/sse/closeSse',
name: '断连sse',
method: 'POST'
},
cameraIoConfigPut: {
url: '/cameraIo/config',
name: '修改预置点',
method: 'PUT'
},
stockExportModel: {
url: '/stock/export/model',
name: '库存模板下载',

@ -10,7 +10,7 @@
<slot name="title">{{ title }}</slot>
</a-layout-header>
</div>
<div class="header-right">
<!-- <div class="header-right">
<div class="header-top-right-circle" @click="visible = !visible"></div>
<a-badge :count="count" @click="openPlc">
<a-icon type="bell" style="font-size:20px;cursor:pointer"/>
@ -30,7 +30,7 @@
<a href="javascript:;" @click="logout">退</a>
</div>
</a-popover>
</div>
</div> -->
</div>
</template>

@ -51,15 +51,25 @@ const routes = [{
},
{
path: 'historyMonitoring',
name: 'historyMonitoring',
path: 'test',
name: 'test',
meta: {
icon: 'book',
name: '历史数据'
icon: 'video-camera',
name: '测试'
},
component: () => import('@/views/historyMonitoring/index')
component: () => import('@/views/picTest/index'),
},
// {
// path: 'historyMonitoring',
// name: 'historyMonitoring',
// meta: {
// icon: 'book',
// name: '历史数据'
// },
// component: () => import('@/views/historyMonitoring/index')
// },
// {
// path: 'alarmLog',
// name: 'alarmLog',
// meta: {
@ -68,32 +78,32 @@ const routes = [{
// },
// component: () => import('@/views/alarmVideos/alarmLog')
// },
{
path: 'checkManage',
name: 'checkManage',
meta: {
icon: 'form',
name: '盘点管理',
},
component: () => import('@/views/checkManage/index'),
},
{
path: 'checkOperation',
name: 'checkOperation',
meta: {
name: '盘点操作'
},
component: () => import('@/views/checkManage/checkOperation'),
},
{
path: 'checkHistory',
name: 'checkHistory',
meta: {
icon: 'tag',
name: '盘点历史',
},
component: () => import('@/views/historyCheck/index'),
},
// {
// path: 'checkManage',
// name: 'checkManage',
// meta: {
// icon: 'form',
// name: '盘点管理',
// },
// component: () => import('@/views/checkManage/index'),
// },
// {
// path: 'checkOperation',
// name: 'checkOperation',
// meta: {
// name: '盘点操作'
// },
// component: () => import('@/views/checkManage/checkOperation'),
// },
// {
// path: 'checkHistory',
// name: 'checkHistory',
// meta: {
// icon: 'tag',
// name: '盘点历史',
// },
// component: () => import('@/views/historyCheck/index'),
// },
// {
// path: 'stockHistory',
// name: 'stockHistory',
@ -111,15 +121,15 @@ const routes = [{
// },
// component: () => import('@/views/stockLog/logPage'),
// },
{
path: 'roadwayManage',
name: 'roadwayManage',
meta: {
icon: 'build',
name: '巷道管理'
},
component: () => import('@/views/roadwayManage/index')
},
// {
// path: 'roadwayManage',
// name: 'roadwayManage',
// meta: {
// icon: 'build',
// name: '巷道管理'
// },
// component: () => import('@/views/roadwayManage/index')
// },
{
path: 'cameraManage',
name: 'cameraManage',

@ -311,8 +311,11 @@ export default {
if(this.type=='test') {
this.$router.go(-1);
}else if(this.type=='config') {
if(this.player != null){
this.player.destroy()
}
this.$router.go(-1);
this.player.destroy();
}
},

@ -47,12 +47,20 @@
@sure="submit"
@close="closeModel"
/>
<modelCamera
:visible.sync="visible"
:modelType="modelType"
:modelData.sync="modelData"
@sure="submit"
@close="closeModel"
/>
</div>
</template>
<script>
import Model from "./model.vue"
import modelCamera from "./modelCamera.vue"
import ioModel from "./ioModel.vue"
const columns = [
{

File diff suppressed because it is too large Load Diff

@ -0,0 +1,790 @@
<template>
<a-modal
v-model="isShow"
@cancel="handleCancel"
:footer="null"
:maskClosable="false"
width="1600px"
:bodyStyle="{padding:0,display:'flex'}"
:centered="true"
class="config-model"
>
<video width="900"
height="600"
:id="`config-camera${id}`"
autoplay muted ></video>
<div class="operation-list">
<div class="operation-item">
<img :src="zoomSubUrl" alt="" @mousedown="zoomDecStart"
@mouseup="zoomDecStop" @mouseleave="zoomDecStop">
<span>变倍</span>
<img :src="zoomAddUrl" alt="" @mousedown="zoomAddStart"
@mouseup="zoomAddStop" @mouseleave="zoomAddStop">
</div>
<div class="operation-item">
<img :src="focusSubUrl" alt="" @mousedown="focusDecStart"
@mouseup="focusDecStop" @mouseleave="focusDecStop">
<span>变焦</span>
<img :src="focusAddUrl" alt="" @mousedown="focusAddStart"
@mouseup="focusAddStop" @mouseleave="focusAddStop">
</div>
<div class="operation-item">
<img :src="irisSubUrl" alt="" @mousedown="irisDecStart" @mouseup="irisDecStop" @mouseleave="irisDecStop">
<span>光圈</span>
<img :src="irisAddUrl" alt="" @mousedown="irisAddStart" @mouseup="irisAddStop" @mouseleave="irisAddStop">
</div>
</div>
<div class="direction-list">
<div class="direction-item">
<img :src="leftUpUrl" alt="" @mousedown="leftUpStart" @mouseup="leftUpStop" @mouseleave="leftUpStop">
<img :src="upUrl" alt="" @mousedown="upStart" @mouseup="upStop" @mouseleave="upStop">
<img :src="rightUpUrl" alt="" @mousedown="rightUpStart" @mouseup="rightUpStop" @mouseleave="rightUpStop">
</div>
<div class="direction-item">
<img :src="leftUrl" alt="" @mousedown="leftStart" @mouseup="leftStop" @mouseleave="leftStop">
<img :src="rightUrl" alt="" @mousedown="rightStart" @mouseup="rightStop" @mouseleave="rightStop">
</div>
<div class="direction-item">
<img :src="leftDownUrl" alt="" @mousedown="leftDownStart"
@mouseup="leftDownStop" @mouseleave="leftDownStop">
<img :src="downUrl" alt="" @mousedown="downStart" @mouseup="downStop" @mouseleave="downStop">
<img :src="rightDownUrl" alt="" @mousedown="rightDownStart"
@mouseup="rightDownStop" @mouseleave="rightDownStop">
</div>
</div>
<div class="config-table">
<h2>球机配置</h2>
<a-table
:columns="columns"
:row-key="record => record.name"
:data-source="configData"
@change="getConfigIoList"
bordered
:pagination="false"
:scroll="{y:335}"
>
<span slot="name" slot-scope="text,record">
<a-button type="link" @click="toPtz(record)">{{text}}({{record.code}})</a-button>
</span>
<span slot="position" slot-scope="text, record">
<div v-if="text">
已写入
<a-button type="link" class="plc" @click="coverage(0,record)">
覆盖
</a-button>
</div>
<a-button type="primary" class="plc" v-else @click="coverage(0,record)">
写入
</a-button>
</span>
</a-table>
</div>
</a-modal>
</template>
<script>
var formItemAcrossLayout = { //formItemAcrossLayoutitem
labelCol: { span: 8 }, //lable
wrapperCol: { span: 14 }, //input
};
var formItemVerticalLayout = { //formItemVerticalLayoutitem
labelCol: { span: 4 },
wrapperCol: { span: 8, offset: 4 },
};
const columns = [
{
title: 'PLC IO指令',
dataIndex: 'name',
scopedSlots: { customRender: 'name' }
},
{
title: '配置',
dataIndex: 'position',
scopedSlots: { customRender: 'position' }
}
];
import WebRtcPlayer from "../../../public/static/webrtcplayer"
export default {
props:[ 'visible', 'modelType', 'modelData'],
watch: {
//visibleisShowprops
visible: function(newVal){
this.isShow = newVal; //newValvisible
// newVal && this.showConfirm(); //newValshowConfirm
},
modelType: function(newVal){
this.type = newVal;
},
modelData: function(newVal){
// console.log(newVal)
this.mdata=newVal
console.log(this.type)
if(newVal.id && this.type=='edit'){
this.id = newVal.id
// console.log('watch')
this.$nextTick(()=>{ //this.$nextTick
this.form.setFieldsValue({ //setFieldsValue form
name:newVal.name,
ip:newVal.ip,
rtsp:newVal.rtsp,
rtcServer:newVal.rtcServer,
rtcServerPort:newVal.rtcServerPort
})
})
}else if (newVal.id && this.type=='config'){
this.id = newVal.id
this.mdata = newVal
console.log(newVal)
}
},
},
data() {
return {
isShow:false,
player:null,
type:'',
title:'',
closable:false,//modelX
formItemAcrossLayout,
formItemVerticalLayout,
confirmLoading: false,
form: this.$form.createForm(this, { name: 'dynamic_rule' }),
id:'',
mdata:[],
//
zoomSubUrl:require('@/assets/sub-icon.png'),
zoomAddUrl:require('@/assets/add-icon.png'),
focusSubUrl:require('@/assets/sub-icon.png'),
focusAddUrl:require('@/assets/add-icon.png'),
irisSubUrl:require('@/assets/sub-icon.png'),
irisAddUrl:require('@/assets/add-icon.png'),
leftUpUrl:require('@/assets/left-up-icon.png'),
upUrl:require('@/assets/up-icon.png'),
rightUpUrl:require('@/assets/right-up-icon.png'),
leftUrl:require('@/assets/left-icon.png'),
rightUrl:require('@/assets/right-icon.png'),
leftDownUrl:require('@/assets/left-down-icon.png'),
downUrl:require('@/assets/down-icon.png'),
rightDownUrl:require('@/assets/right-down-icon.png'),
columns,
configData:[]
};
},
mounted() {
if (this.$route.query.modelType == 'test') {
this.isShow = true
this.id = this.$route.query.modelData.id
this.type = this.$route.query.modelType
this.mdata = this.$route.query.modelData
this.$nextTick(() => {
this.autoPlay(this.id)
})
} else if (this.$route.query.modelType == 'config') {
this.isShow = true
this.id = this.$route.query.modelData.id
this.getConfigIoList()
this.type = this.$route.query.modelType
this.mdata = this.$route.query.modelData
this.$nextTick(() => {
this.autoPlay(this.id)
})
}
},
destroy(){
if(this.player != null){
this.player.destroy()
}
},
methods: {
handleOk() {
this.confirmLoading = true;
setTimeout(() => {
this.form.validateFields((err, values) => {
console.log(values)
if (!err) {
console.log(this.title)
if(this.type=='add'){
this.$api.httpApi.addCamera({
data:values
}).then(res => {
if(res.code==200){
this.$emit('sure',false)
this.$message.success('新增球机成功');
}
}).catch(err => {
});
}else if(this.type=='edit'){
values.id = this.id
this.$api.httpApi.editCamera({
data:values
}).then(res => {
if(res.code==200){
this.$emit('sure',false)
this.$message.success('编辑球机成功');
}
}).catch(err => {
});
}
}
});
this.confirmLoading = false;
}, 500);
},
handleCancel() {
console.log('Clicked cancel button');
this.$emit('close', false, {})
if(this.type=='test') {
this.$router.go(-1);
}else if(this.type=='config') {
if(this.player != null){
this.player.destroy()
}
this.$router.go(-1);
}
},
autoPlay(id){
let video = document.getElementById('config-camera'+id);
if(video){
let server = this.mdata.rtcServer+":"+this.mdata.rtcServerPort
console.log("server:"+server)
let player = new WebRtcPlayer(server,video,'camera'+id);
console.log("okkkkkk")
//player.load('camera'+id);
this.player = player
}
},
getConfigIoList(){
this.$axios.post('/camera/'+this.id+'/io/list', {
data: {
}
}).then(res => {
console.log(res)
if(res.code==200){
this.configData=res.data
}
}).catch(err => {
});
},
coverage(type,data){
this.$api.httpApi.writeInCameraIoptz({
data: {
cameraId: this.id,
cameraIOId: data.id,
name: data.name,
code: data.code,
type: type
}
}).then(res => {
this.getConfigIoList()
}).catch(err => {
});
},
toPtz(data){
this.$api.httpApi.cameraIoToPtz({
data: {
cameraId:this.id,
cameraIOId:data.id,
name:data.name,
}
}).then(res => {
console.log(res)
}).catch(err => {
});
},
zoomDecStart(){
console.log('变倍-按下')
this.zoomSubUrl=require('@/assets/sub-active-icon.png')
this.$axios.post('/camera/control/zoomDec/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
zoomDecStop(){
console.log('变倍-抬起')
this.zoomSubUrl=require('@/assets/sub-icon.png')
this.$axios.post('/camera/control/zoomDec/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
zoomAddStart(){
console.log('变倍+按下')
this.zoomAddUrl=require('@/assets/add-active-icon.png')
this.$axios.post('/camera/control/zoomAdd/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
zoomAddStop(){
console.log('变倍+抬起')
this.zoomAddUrl=require('@/assets/add-icon.png')
this.$axios.post('/camera/control/zoomAdd/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
focusDecStart(){
console.log('变焦-按下')
this.focusSubUrl=require('@/assets/sub-active-icon.png')
this.$axios.post('/camera/control/focusDec/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
focusDecStop(){
console.log('变焦-抬起')
this.focusSubUrl=require('@/assets/sub-icon.png')
this.$axios.post('/camera/control/focusDec/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
focusAddStart(){
console.log('变焦+按下')
this.focusAddUrl=require('@/assets/add-active-icon.png')
this.$axios.post('/camera/control/focusAdd/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
focusAddStop(){
console.log('变焦+抬起')
this.focusAddUrl=require('@/assets/add-icon.png')
this.$axios.post('/camera/control/focusAdd/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
irisDecStart(){
console.log('光圈-按下')
this.irisSubUrl=require('@/assets/sub-active-icon.png')
this.$axios.post('/camera/control/irisDec/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
irisDecStop(){
console.log('光圈-抬起')
this.irisSubUrl=require('@/assets/sub-icon.png')
this.$axios.post('/camera/control/irisDec/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
irisAddStart(){
console.log('光圈+按下')
this.irisAddUrl=require('@/assets/add-active-icon.png')
this.$axios.post('/camera/control/irisAdd/start/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
irisAddStop(){
console.log('光圈+抬起')
this.irisAddUrl=require('@/assets/add-icon.png')
this.$axios.post('/camera/control/irisAdd/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftUpStart(){
console.log('左上鼠标按下')
this.leftUpUrl=require('@/assets/left-up-active-icon.png')
this.$axios.post('/camera/control/leftUp/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftUpStop(){
console.log('左上鼠标抬起')
this.leftUpUrl=require('@/assets/left-up-icon.png')
this.$axios.post('/camera/control/leftUp/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
upStart(){
console.log('上鼠标按下')
this.upUrl=require('@/assets/up-active-icon.png')
this.$axios.post('/camera/control/up/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
upStop(){
console.log('上鼠标抬起')
this.upUrl=require('@/assets/up-icon.png')
this.$axios.post('/camera/control/up/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightUpStart(){
console.log('右上鼠标按下')
this.rightUpUrl=require('@/assets/right-up-active-icon.png')
this.$axios.post('/camera/control/rightUp/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightUpStop(){
console.log('右上鼠标抬起')
this.rightUpUrl=require('@/assets/right-up-icon.png')
this.$axios.post('/camera/control/rightUp/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftStart(){
// console.log(this.id)
console.log('左转鼠标按下')
this.leftUrl=require('@/assets/left-active-icon.png')
this.$axios.post('/camera/control/left/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftStop(){
this.leftUrl=require('@/assets/left-icon.png')
console.log('左转鼠标抬起')
this.$axios.post('/camera/control/left/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightStart(){
console.log('右转鼠标按下')
this.rightUrl=require('@/assets/right-active-icon.png')
this.$axios.post('/camera/control/right/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightStop(){
console.log('右转鼠标抬起')
this.rightUrl=require('@/assets/right-icon.png')
this.$axios.post('/camera/control/right/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftDownStart(){
console.log('左下鼠标按下')
this.leftDownUrl=require('@/assets/left-down-active-icon.png')
this.$axios.post('/camera/control/leftDown/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
leftDownStop(){
console.log('左下鼠标抬起')
this.leftDownUrl=require('@/assets/left-down-icon.png')
this.$axios.post('/camera/control/leftDown/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
downStart(){
console.log('下鼠标按下')
this.downUrl=require('@/assets/down-active-icon.png')
this.$axios.post('/camera/control/down/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
downStop(){
console.log('下鼠标抬起')
this.downUrl=require('@/assets/down-icon.png')
this.$axios.post('/camera/control/down/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightDownStart(){
console.log('右下鼠标按下')
this.rightDownUrl=require('@/assets/right-down-active-icon.png')
this.$axios.post('/camera/control/rightDown/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
rightDownStop(){
console.log('右下鼠标抬起')
this.rightDownUrl=require('@/assets/right-down-icon.png')
this.$axios.post('/camera/control/rightDown/stop/'+this.id, {
data: {}
}).then(res => {
}).catch(err => {
})
},
},
};
</script>
<style lang="scss" scoped>
.add-edit-model{
.across-layout{
display: flex;
}
.ant-divider-horizontal{
margin:6px 0;
}
}
.test-model{
position:fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color:rgba(0,0,0,0.5);
z-index:1000;
display: flex;
align-items: center;
justify-content: center;
#video-test {
width: 100%;
height: 100%;
}
.video-close{
position: absolute;
right: 20px;
top: 20px;
color: #ffffff;
font-size: 24px;
width: 32px;
height: 32px;
background: rgba(0,0,0,0.5);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
z-index: 10;
}
.operation-list{
position: absolute;
right: 200px;
bottom: 20px;
/*width: 150px;*/
/*border: solid 1px blue;*/
z-index: 10;
.operation-item{
img{
width: 42px;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-user-drag: none;
user-select: none;
}
span{
padding: 5px 10px;
background: rgba(0,0,0,0.5);
font-size: 18px;
color: #ffffff;
}
}
}
.direction-list{
position: absolute;
right: 30px;
bottom: 20px;
width: 150px;
z-index: 10;
/*border: solid 1px blue;*/
.direction-item{
display: flex;
align-items: center;
justify-content: space-between;
img{
width: 42px;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-user-drag: none;
user-select: none;
}
}
}
img{
cursor: pointer;
}
}
.config-model{
display: flex;
align-items: center;
justify-content: center;
.operation-list{
position: absolute;
right: 1000px;
bottom: 20px;
/*width: 150px;*/
/*border: solid 1px blue;*/
z-index: 10;
.operation-item{
img{
width: 32px;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-user-drag: none;
user-select: none;
}
span{
padding: 3px 6px;
background: rgba(0,0,0,0.5);
font-size: 16px;
color: #ffffff;
}
}
}
.direction-list{
position: absolute;
right: 830px;
bottom: 20px;
width: 150px;
z-index: 10;
/*border: solid 1px blue;*/
.direction-item{
display: flex;
align-items: center;
justify-content: space-between;
img{
width: 32px;
-webkit-user-select: none;
-ms-user-select: none;
-webkit-user-drag: none;
user-select: none;
}
}
}
img{
cursor: pointer;
}
.config-table {
width: 800px;
height: 600px;
overflow: hidden;
h2 {
padding: 15px;
font-size: 20px;
background: #fafafa;
margin: 0;
}
}
}
.vxgplayer{
border: none;
margin: 0;
display: block;
}
.ant-btn{
white-space: inherit;
text-align: left;
}
</style>

@ -0,0 +1,191 @@
<template>
<div class="app-container">
<!-- 图片上传区域 -->
<a-upload
:before-upload="beforeUpload"
showUploadlist="false"
@change="handleChange"
:custom-request="uploadImage"
accept=".jpg,.jpeg,.png,.bmp"
>
<a-button>点击选择图片</a-button>
</a-upload>
<!-- 获取区域坐标按钮 -->
<a-input v-model="typeID" placeholder="Basic usage" />
<a-button v-if="typeID!=''&& coordinates.length>0" @click="getCoordinates"></a-button>
<a-button v-if="typeID!=''&& coordinates.length>0" @click="removeCoordinates"></a-button>
<!-- 显示坐标 -->
<div
v-if="coordinates.length"
class="coordinates"
>
<p><strong>坐标:</strong> {{ coordinates }}</p>
</div>
<!-- 图片展示区域 -->
<div
v-if="imageUrl&&typeID!=''"
class="image-container"
@mousedown="onMouseDown"
@mouseup="onMouseUp"
@mousemove="onMouseMove"
>
<img
:src="imageUrl"
alt="Selected Image"
ref="image"
style="width: 100%;height: 100%;object-fit: none;"
/>
<!-- 绘制矩形 -->
<div
v-if="isDrawing"
:style="squareStyle"
class="square"
></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
imageUrl: "", // URL
isDrawing: false, //
startX: 0, //
startY: 0, //
currentX: 0, //
currentY: 0, //
typeID:"",
fileName: '', //
coordinates: [], //
visible:false,
modelType:'',
modelData:[],
};
},
computed: {
squareStyle() {
//
const width = Math.abs(this.currentX - this.startX);
const height = Math.abs(this.currentY - this.startY);
const left = Math.min(this.startX, this.currentX);
const top = Math.min(this.startY, this.currentY);
return {
width: `${width}px`,
height: `${height}px`,
left: `${left}px`,
top: `${top}px`,
position: "absolute",
border: "2px solid red",
};
},
},
methods: {
//
getCoordinates(){
console.log(this.typeID);
this.$api.httpApi.EaseAiController({
data: {
locationURL: this.typeID+"/"+this.fileName,
yoloBodies: this.coordinates,
}
}).then(res => {
this.$message.info(`选定的区域坐标: ${JSON.stringify(this.coordinates)}`
);
}).catch(err => {
});
},
removeCoordinates(){
this.typeID ='';
this.imageUrl = '';
this.coordinates =[];
},
handleChange(info){
},
beforeUpload(file) {
console.log(file.name); //
this.fileName = file.name;
const isJPG =
file.type === "image/jpeg" || file.type === "image/png";
if (!isJPG) {
this.$message.error("只能选择JPG/PNG 图片!");
}
return isJPG;
},
//
uploadImage({ file, onSuccess }) {
const reader = new FileReader();
reader.onload = (e) => {
this.imageUrl = e.target.result;
onSuccess(null, file);
};
reader.readAsDataURL(file);
},
//
onMouseDown(event) {
const rect = this.$refs.image.getBoundingClientRect();
this.startX = event.clientX - rect.left;
this.startY = event.clientY - rect.top;
this.isDrawing = true;
},
//
onMouseMove(event) {
if (!this.isDrawing) return;
const rect = this.$refs.image.getBoundingClientRect();
this.currentX = event.clientX - rect.left;
this.currentY = event.clientY - rect.top;
},
//
onMouseUp() {
if (!this.isDrawing) return;
const width = Math.abs(this.currentX - this.startX);
const height = Math.abs(this.currentY - this.startY);
if (width > 0 && height > 0) {
//
this.coordinates.push({
x: Math.min(this.startX, this.currentX),
y: Math.min(this.startY, this.currentY),
width,
height,
typeID:this.typeID
});
}
this.isDrawing = false;
},
//
logCoordinates() {
console.log(this.coordinates);
this.$message.info(
`选定的区域坐标: ${JSON.stringify(this.coordinates)}`
);
},
},
};
</script>
<style scoped>
.app-container {
padding: 20px;
}
.image-container {
position: relative;
display: inline-block;
margin-top: 20px;
}
.square {
position: absolute;
border: 2px solid red;
}
.coordinates {
margin-top: 20px;
}
</style>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save