forked from SwimmingLiu/yolov7-Pyside6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcudatest.py
62 lines (51 loc) · 1.95 KB
/
cudatest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# import torch
# flag = torch.cuda.is_available()
# if flag:
# print("CUDA可使用")
# else:
# print("CUDA不可用")
#
# ngpu= 1
# # Decide which device we want to run on
# device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu")
# print("驱动为:",device)
# print("GPU型号: ",torch.cuda.get_device_name(0))
import sys
from PySide6.QtCore import Qt, QUrl
from PySide6.QtWidgets import QApplication, QMainWindow, QLabel, QHBoxLayout, QSlider
from PySide6.QtMultimedia import QMediaPlayer
from PySide6.QtMultimediaWidgets import QVideoWidget
class VideoPlayer(QMainWindow):
def __init__(self):
super().__init__()
# Create a media player object
self.mediaPlayer = QMediaPlayer()
# Set up the video widget
videoWidget = QVideoWidget()
self.mediaPlayer.setVideoOutput(videoWidget)
# Create a layout to hold the video widget and progress slider
layout = QHBoxLayout()
layout.addWidget(videoWidget)
self.slider = QSlider(Qt.Horizontal)
layout.addWidget(self.slider)
# Create a central widget to hold the layout
centralWidget = QLabel()
centralWidget.setLayout(layout)
self.setCentralWidget(centralWidget)
# Connect the slider to the media player
self.slider.sliderMoved.connect(self.setPosition)
self.mediaPlayer.positionChanged.connect(self.updateSlider)
self.mediaPlayer.durationChanged.connect(self.updateDuration)
# Load a media file
self.mediaPlayer.setSource(r"E:\YOLO\yolov7_ship\testvideo.mp4")
def setPosition(self, position):
self.mediaPlayer.setPosition(position)
def updateSlider(self, position):
self.slider.setValue(position)
def updateDuration(self, duration):
self.slider.setRange(0, duration)
if __name__ == "__main__":
app = QApplication(sys.argv)
player = VideoPlayer()
player.show()
sys.exit(app.exec_())