I have eight different videos. And I am trying to show these videos in a split window. My video quality is 720p. But I need to fit in small frame. When I resize the video with p = convert_to_Qt_format.scaled(256, 450, Qt.KeepAspectRatio) as a 256x450 I couldn't get good quality of video. How can I resize as a good quality. What is your suggestion to me?
@pyqtSlot(list)
def update_image(self, cv_img = []):
"""Updates the image_label with a new opencv image"""
qt_img = []
for i in range(0,8):
# qt_img.append(0)
qt_img.append(self.convert_cv_qt(cv_img[i]))
self.ui.video1.setPixmap(qt_img[0])
self.ui.video2.setPixmap(qt_img[1])
self.ui.video3.setPixmap(qt_img[2])
self.ui.video4.setPixmap(qt_img[3])
self.ui.video5.setPixmap(qt_img[4])
self.ui.video6.setPixmap(qt_img[5])
self.ui.video7.setPixmap(qt_img[6])
self.ui.video8.setPixmap(qt_img[7])
def convert_cv_qt(self, cv_img):
"""Convert from an opencv image to QPixmap"""
rgb_image = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)
h, w, ch = rgb_image.shape
bytes_per_line = ch * w
convert_to_Qt_format = QtGui.QImage(rgb_image.data, w, h, bytes_per_line, QtGui.QImage.Format_RGB888)
p = convert_to_Qt_format.scaled(256, 450, Qt.KeepAspectRatio)
return QPixmap.fromImage(p)
Note that
QImage::scaled()has an optional parametertransformModethat defaults toQt::FastTransformation. If you passQt::SmoothTransformationthe results should be better, because bilinear filtering is used.