Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
柳 佳乐
小型无人机目标检测系统前端
Commits
160a300a
Commit
160a300a
authored
Jun 06, 2024
by
柳 佳乐
Browse files
视频canvas绘制停止bug
parent
b527a08d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/views/home.vue
View file @
160a300a
...
@@ -80,7 +80,12 @@ export default {
...
@@ -80,7 +80,12 @@ export default {
houses
:
"
#FF5FF6
"
,
//房子
houses
:
"
#FF5FF6
"
,
//房子
bridge
:
"
#A200FF
"
,
//桥
bridge
:
"
#A200FF
"
,
//桥
boat
:
"
#00FFE4
"
,
//船
boat
:
"
#00FFE4
"
,
//船
}
},
canvasVideoId
:
null
,
videoFrameId
:
null
,
canvasVideoIdTure
:
false
,
videoFrameIdTure
:
false
,
}
}
},
},
created
()
{
created
()
{
...
@@ -98,6 +103,8 @@ export default {
...
@@ -98,6 +103,8 @@ export default {
canvasInit
(){
canvasInit
(){
let
myCanvas
=
this
.
$refs
.
myCanvas
let
myCanvas
=
this
.
$refs
.
myCanvas
let
ctx
=
myCanvas
.
getContext
(
'
2d
'
)
let
ctx
=
myCanvas
.
getContext
(
'
2d
'
)
this
.
canvasVideoIdTure
=
true
this
.
videoFrameIdTure
=
true
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
var
w
=
myCanvas
.
width
;
var
w
=
myCanvas
.
width
;
var
h
=
myCanvas
.
height
;
var
h
=
myCanvas
.
height
;
...
@@ -117,12 +124,13 @@ export default {
...
@@ -117,12 +124,13 @@ export default {
var
h
=
myCanvas
.
height
;
var
h
=
myCanvas
.
height
;
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
// 在Canvas画布 添加图片
// 在Canvas画布 添加图片
let
img
=
new
Image
()
this
.
canvasVideoIdTure
=
true
img
.
src
=
this
.
imageUrl
this
.
videoFrameIdTure
=
true
let
img
=
new
Image
();
img
.
src
=
this
.
imageUrl
;
img
.
onload
=
()
=>
{
img
.
onload
=
()
=>
{
this
.
imageInfo
.
width
=
img
.
width
this
.
imageInfo
.
width
=
img
.
width
this
.
imageInfo
.
height
=
img
.
height
this
.
imageInfo
.
height
=
img
.
height
let
w
=
img
.
width
*
800
/
img
.
width
;
let
w
=
img
.
width
*
800
/
img
.
width
;
let
h
=
img
.
height
*
600
/
img
.
height
;
let
h
=
img
.
height
*
600
/
img
.
height
;
myCanvas
.
width
=
w
myCanvas
.
width
=
w
...
@@ -147,6 +155,8 @@ export default {
...
@@ -147,6 +155,8 @@ export default {
var
w
=
myCanvas
.
width
;
var
w
=
myCanvas
.
width
;
var
h
=
myCanvas
.
height
;
var
h
=
myCanvas
.
height
;
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
this
.
canvasVideoIdTure
=
true
this
.
videoFrameIdTure
=
true
// 在Canvas画布 添加图片
// 在Canvas画布 添加图片
let
img
=
new
Image
()
let
img
=
new
Image
()
img
.
src
=
this
.
imageUrl
img
.
src
=
this
.
imageUrl
...
@@ -249,10 +259,15 @@ export default {
...
@@ -249,10 +259,15 @@ export default {
);
);
});
});
console
.
log
(
videoEl
.
width
,
videoEl
.
height
)
console
.
log
(
videoEl
.
width
,
videoEl
.
height
)
this
.
videoFrameIdTure
=
true
this
.
canvasVideoIdTure
=
false
const
videoRender
=
()
=>
{
const
videoRender
=
()
=>
{
window
.
requestAnimationFrame
(
videoRender
);
this
.
canvasVideoId
=
window
.
requestAnimationFrame
(
videoRender
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
drawImage
(
videoEl
,
0
,
0
,
w
,
h
);
ctx
.
drawImage
(
videoEl
,
0
,
0
,
w
,
h
);
if
(
this
.
canvasVideoIdTure
){
window
.
cancelAnimationFrame
(
this
.
canvasVideoId
)
}
};
};
videoRender
();
videoRender
();
},
},
...
@@ -286,10 +301,15 @@ export default {
...
@@ -286,10 +301,15 @@ export default {
"
HAVE_CURRENT_DATA or greater for first time.
"
,
"
HAVE_CURRENT_DATA or greater for first time.
"
,
);
);
});
});
this
.
canvasVideoIdTure
=
true
this
.
videoFrameIdTure
=
false
const
videoRender
=
()
=>
{
const
videoRender
=
()
=>
{
window
.
requestAnimationFrame
(
videoRender
);
this
.
videoFrameId
=
window
.
requestAnimationFrame
(
videoRender
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
clearRect
(
0
,
0
,
w
,
h
);
ctx
.
drawImage
(
videoEl
,
0
,
0
,
w
,
h
);
ctx
.
drawImage
(
videoEl
,
0
,
0
,
w
,
h
);
if
(
this
.
videoFrameIdTure
){
window
.
cancelAnimationFrame
(
this
.
videoFrameId
)
}
loadingInstance
.
close
();
loadingInstance
.
close
();
};
};
videoRender
();
videoRender
();
...
...
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