Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-skynet-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-skynet-admin
Commits
1ba85521
Commit
1ba85521
authored
Sep 23, 2021
by
朱松文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现在线版热力图
parent
457f4cd1
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
384 additions
and
58 deletions
+384
-58
myVideo.scss
src/assets/scss/myVideo.scss
+7
-0
data.d.ts
src/components/MyVideo/data.d.ts
+7
-21
index.vue
src/components/MyVideo/index.vue
+4
-3
index.ts
src/components/MyVideo/myContainer/index.ts
+35
-0
index.ts
src/components/MyVideo/track/index.ts
+47
-29
trackData.ts
src/mock/trackData.ts
+275
-0
index.vue
src/views/dashboard/index.vue
+9
-5
No files found.
src/assets/scss/myVideo.scss
View file @
1ba85521
.my-container
{
position
:
relative
;
width
:
100%
;
height
:
calc
(
100%
-
30px
);
// border: 1px solid red;
}
.najiu-dog-track
{
position
:
absolute
;
top
:
30px
;
...
...
src/components/MyVideo/data.d.ts
View file @
1ba85521
export
interface
TrackData
{
time
:
number
,
position
:
PostitionData
,
shape
:
Shape
,
videoShape
?:
VideoShape
,
beginTime
?:
number
,
endTime
?:
number
}
export
interface
PostitionData
{
top
:
number
,
left
:
number
}
export
interface
Shape
{
width
:
number
,
height
:
number
}
export
interface
VideoShape
{
width
:
number
,
height
:
number
DogId
:
string
,
FrameIndex
:
numbner
,
HasRope
:
boolean
,
x1
:
number
,
y1
:
number
,
x2
:
number
,
y2
:
number
}
\ No newline at end of file
src/components/MyVideo/index.vue
View file @
1ba85521
...
...
@@ -10,6 +10,7 @@ import { Component, Vue, Prop } from "vue-property-decorator";
import
"
video.js/dist/video-js.min.css
"
;
import
videojs
from
"
video.js
"
;
import
"
@/components/MyVideo/track/index
"
;
import
"
@/components/MyVideo/myContainer/index
"
;
import
"
@/assets/scss/myVideo.scss
"
;
import
{
TrackData
}
from
"
./data
"
;
...
...
@@ -55,9 +56,9 @@ export default class MyVideo extends Vue {
},
},
function
onPlayerReady
()
{
//@ts-ignore
this
.
addChild
(
"
DogTrack
"
);
_this
.
dogTrack
=
this
.
getChild
(
"
DogTrack
"
);
const
myContainer
=
this
.
addChild
(
"
MyContainer
"
);
myContainer
.
addChild
(
"
DogTrack
"
);
_this
.
dogTrack
=
myContainer
.
getChild
(
"
DogTrack
"
);
_this
.
dogTrack
.
initData
(
_this
.
trackData
);
this
.
play
();
}
...
...
src/components/MyVideo/myContainer/index.ts
0 → 100644
View file @
1ba85521
import
videojs
from
'
video.js
'
const
Component
=
videojs
.
getComponent
(
'
Component
'
);
//实现自己的容器
class
MyContainer
extends
Component
{
constructor
(
player
,
options
)
{
super
(
player
,
options
)
}
createEl
()
{
const
container
=
document
.
createElement
(
"
div
"
)
container
.
classList
.
add
(
"
my-container
"
)
container
.
onclick
=
()
=>
{
//播放状态
if
(
this
.
player_
.
paused
())
{
this
.
player_
.
play
()
}
else
{
this
.
player_
.
pause
()
}
}
container
.
oncontextmenu
=
function
()
{
console
.
log
(
"
鼠标右键
"
)
return
false
}
return
container
}
handleClick
(
event
)
{
console
.
log
(
"
container
"
,
event
)
}
}
videojs
.
registerComponent
(
"
MyContainer
"
,
MyContainer
)
\ No newline at end of file
src/components/MyVideo/track/index.ts
View file @
1ba85521
...
...
@@ -9,9 +9,12 @@ class DogTrack extends Component {
myel
=
undefined
defaultWidth
=
0
defaultHeight
=
0
defaultElWidth
=
""
defaultElHeight
=
""
fullWidth
=
0
fullHeight
=
0
firstShowTrack
=
false
isReplaceDisplayNone
=
false
arrayIndex
=
0
preCurrentTime
=
0
constructor
(
player
,
options
)
{
super
(
player
,
options
);
...
...
@@ -22,13 +25,11 @@ class DogTrack extends Component {
player
.
on
(
"
timeupdate
"
,
(
e
)
=>
this
.
update
(
e
))
player
.
on
(
"
fullscreenchange
"
,
(
e
)
=>
this
.
fullScreenChange
.
call
(
this_
,
e
,
player
))
player
.
on
(
"
ended
"
,
(
e
)
=>
{
console
.
log
(
"
ended
"
,
e
)
player
.
on
(
"
ended
"
,
()
=>
{
this
.
arrayIndex
=
0
;
})
}
createEl
():
HTMLDivElement
{
const
el
=
document
.
createElement
(
"
div
"
)
el
.
id
=
"
trackDiv
"
...
...
@@ -39,11 +40,8 @@ class DogTrack extends Component {
fullScreenChange
(
e
,
player
)
{
if
(
player
.
isFullscreen
())
{
this
.
myel
.
style
.
width
=
`
${
this
.
myel
.
offsetWidth
*
(
e
.
currentTarget
.
offsetWidth
/
this
.
defaultWidth
)}
px`
this
.
myel
.
style
.
height
=
`
${
this
.
myel
.
offsetHeight
*
(
e
.
currentTarget
.
offsetHeight
/
this
.
defaultHeight
)}
px`
}
else
{
this
.
myel
.
style
.
width
=
this
.
defaultElWidth
this
.
myel
.
style
.
height
=
this
.
defaultElHeight
this
.
fullWidth
=
e
.
currentTarget
.
offsetWidth
this
.
fullHeight
=
e
.
currentTarget
.
offsetHeight
}
}
...
...
@@ -51,12 +49,34 @@ class DogTrack extends Component {
if
(
this
.
processing
||
this
.
trackData
.
length
===
0
||
!
this
.
myel
)
return
this
.
processing
=
true
const
currentTime
=
this
.
player_
.
currentTime
()
*
1000
for
(
let
i
=
0
;
i
<
this
.
trackData
.
length
;
i
++
)
{
//假如调整的播放时间则初始数组索引
if
(
currentTime
-
this
.
preCurrentTime
<=
0
)
{
this
.
dispose
()
}
//上次播放时间
this
.
preCurrentTime
=
currentTime
const
firstFrameIndex
=
this
.
trackData
[
0
].
FrameIndex
*
40
for
(
let
i
=
this
.
arrayIndex
;
i
<
this
.
trackData
.
length
;
i
++
)
{
const
d
=
this
.
trackData
[
i
]
if
(
currentTime
>
d
.
beginTime
&&
currentTime
<
d
.
endTime
)
{
this
.
myel
.
style
.
top
=
`
${
d
.
position
.
top
}
%`
this
.
myel
.
style
.
left
=
`
${
d
.
position
.
left
}
%`
if
(
firstFrameIndex
<=
currentTime
&&
currentTime
<=
d
.
FrameIndex
*
40
)
{
//
this
.
arrayIndex
=
i
console
.
log
(
"
arrayIndex
"
,
this
.
arrayIndex
,
d
.
FrameIndex
)
if
(
!
this
.
player_
.
isFullscreen
())
{
//跟踪框大小
this
.
myel
.
style
.
width
=
`
${(
d
.
x2
-
d
.
x1
)
*
this
.
defaultWidth
}
px`
this
.
myel
.
style
.
height
=
`
${(
d
.
y2
-
d
.
y1
)
*
this
.
defaultHeight
}
px`
}
else
{
this
.
myel
.
style
.
width
=
`
${(
d
.
x2
-
d
.
x1
)
*
this
.
fullWidth
}
px`
this
.
myel
.
style
.
height
=
`
${(
d
.
y2
-
d
.
y1
)
*
this
.
fullHeight
}
px`
}
//跟踪框位置
this
.
myel
.
style
.
top
=
`
${
d
.
y1
*
100
}
%`
this
.
myel
.
style
.
left
=
`
${
d
.
x1
*
100
}
%`
if
(
!
this
.
isReplaceDisplayNone
)
{
this
.
isReplaceDisplayNone
=
true
this
.
myel
.
className
=
this
.
myel
.
className
.
replace
(
/display-none/ig
,
""
)
}
break
;
}
}
...
...
@@ -66,21 +86,19 @@ class DogTrack extends Component {
initData
(
data
:
TrackData
[])
{
this
.
trackData
.
length
=
0
if
(
!
data
||
data
.
length
===
0
)
return
;
this
.
trackData
=
data
;
this
.
myel
=
document
.
getElementById
(
"
trackDiv
"
)
this
.
myel
.
style
.
width
=
`
${
data
[
0
].
shape
.
width
}
px`
this
.
myel
.
style
.
height
=
`
${
data
[
0
].
shape
.
height
}
px`
this
.
defaultElHeight
=
this
.
myel
.
style
.
height
this
.
defaultElWidth
=
this
.
myel
.
style
.
width
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
d
=
data
[
i
]
if
(
i
===
data
.
length
-
1
)
{
this
.
trackData
.
push
({
...
d
,
beginTime
:
d
.
time
,
endTime
:
Number
.
MAX_SAFE_INTEGER
})
}
else
{
this
.
trackData
.
push
({
...
d
,
beginTime
:
d
.
time
,
endTime
:
data
[
i
+
1
].
time
})
}
this
.
dispose
()
const
this_
=
this
setTimeout
(()
=>
{
this
.
player_
.
currentTime
((
this_
.
trackData
[
0
].
FrameIndex
*
40
-
30
)
/
1000
)
},
100
);
}
console
.
log
(
"
data
"
,
this
.
trackData
)
dispose
()
{
this
.
arrayIndex
=
0
this
.
myel
.
classList
.
add
(
"
display-none
"
)
this
.
isReplaceDisplayNone
=
false
}
hideTrackDiv
()
{
...
...
src/mock/trackData.ts
0 → 100644
View file @
1ba85521
This diff is collapsed.
Click to expand it.
src/views/dashboard/index.vue
View file @
1ba85521
...
...
@@ -13,7 +13,7 @@
<div
class=
"player"
ref=
"player-container"
>
<MyVideo
ref=
"myVideo"
v-if=
"width > 0 &&
videoUrl
"
v-if=
"width > 0 &&
trackData.length > 0
"
:src=
"videoUrl"
:trackData=
"trackData"
:width=
"width"
...
...
@@ -39,7 +39,7 @@ import MyVideo from "@/components/MyVideo/index.vue";
import
CameraData
from
"
@/mock/cameraData
"
;
import
{
DogData
}
from
"
@/components/DogInfo/data
"
;
import
{
TrackData
}
from
"
@/components/MyVideo/data
"
;
import
cameraData
from
"
@/mock/camera
Data
"
;
import
dogTrackData
from
"
@/mock/track
Data
"
;
@
Component
({
components
:
{
Camera
,
DogInfo
,
Search
,
MyVideo
}
})
export
default
class
Dashboard
extends
BaseVue
{
...
...
@@ -49,8 +49,11 @@ export default class Dashboard extends BaseVue {
width
=
0
;
height
=
0
;
videoUrl
=
""
;
trackData
:
TrackData
[]
=
[]
;
trackData
:
TrackData
[];
mounted
()
{
this
.
trackData
=
dogTrackData
.
filter
(
(
d
)
=>
d
.
DogId
===
"
1440845582095753223
"
);
this
.
$nextTick
(()
=>
{
const
p
=
this
.
$refs
[
"
player-container
"
];
//@ts-ignore
...
...
@@ -59,13 +62,14 @@ export default class Dashboard extends BaseVue {
this
.
height
=
p
.
offsetHeight
;
//todo:
this
.
videoUrl
=
CameraData
.
dogData
[
0
].
videoUrl
;
this
.
trackData
=
cameraData
.
dogData
[
0
].
trackData
;
});
}
handlePlay
(
dog
:
DogData
):
void
{
this
.
videoUrl
=
dog
.
videoUrl
;
this
.
trackData
=
dog
.
trackData
;
this
.
trackData
=
dogTrackData
.
filter
(
(
d
)
=>
d
.
DogId
===
"
1440845582095753223
"
);
//@ts-ignore
this
.
$refs
[
"
myVideo
"
].
onSrcChange
(
this
.
videoUrl
,
this
.
trackData
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment