update fps fix

This commit is contained in:
TPP-G6
2026-02-07 12:08:15 +08:00
parent b8b180d848
commit f2234f82f0
3 changed files with 25 additions and 19 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

+23 -17
View File
@@ -50,23 +50,23 @@ def create_plot():
grad_brush = make_gradient_brush(theme_color, max_alpha=120) grad_brush = make_gradient_brush(theme_color, max_alpha=120)
show_values = False show_values = False
title_font = QFont("Segoe UI", 14, QFont.Bold) # title_font = QFont("Segoe UI", 14, QFont.Bold)
axis_font = QFont("Segoe UI", 10, QFont.Bold) # axis_font = QFont("Segoe UI", 10, QFont.Bold)
p1 = win.addPlot(title="Normal") p1 = win.addPlot(title="Normal")
p1.titleLabel.item.setFont(title_font) # p1.titleLabel.item.setFont(title_font)
p1.getAxis('left').setStyle(showValues=show_values) p1.getAxis('left').setStyle(showValues=show_values)
p1.showGrid(x=True, y=True, alpha=0.3) p1.showGrid(x=True, y=True, alpha=0.3)
win.nextRow() win.nextRow()
p2 = win.addPlot(title="Shear X") p2 = win.addPlot(title="Shear X")
p2.titleLabel.item.setFont(title_font) # p2.titleLabel.item.setFont(title_font)
p2.getAxis('left').setStyle(showValues=show_values) p2.getAxis('left').setStyle(showValues=show_values)
p2.showGrid(x=True, y=True, alpha=0.3) p2.showGrid(x=True, y=True, alpha=0.3)
win.nextRow() win.nextRow()
p3 = win.addPlot(title="Shear Y") p3 = win.addPlot(title="Shear Y")
p3.titleLabel.item.setFont(title_font) # p3.titleLabel.item.setFont(title_font)
p3.getAxis('left').setStyle(showValues=show_values) p3.getAxis('left').setStyle(showValues=show_values)
p3.setLabel('bottom', 'Time', units='s') p3.setLabel('bottom', 'Time', units='s')
p3.getAxis('bottom').label.setFont(axis_font) # p3.getAxis('bottom').label.setFont(axis_font)
p3.showGrid(x=True, y=True, alpha=0.3) p3.showGrid(x=True, y=True, alpha=0.3)
plot_af = p1.plot(pen=line_pen, fillLevel=0, fillBrush=grad_brush) plot_af = p1.plot(pen=line_pen, fillLevel=0, fillBrush=grad_brush)
plot_tfx = p2.plot(pen=line_pen, fillLevel=0, fillBrush=grad_brush) plot_tfx = p2.plot(pen=line_pen, fillLevel=0, fillBrush=grad_brush)
@@ -147,11 +147,12 @@ def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--video","-v", type=str, default="s1.mp4", help="视频文件路径") parser.add_argument("--video","-v", type=str, default="s1.mp4", help="视频文件路径")
parser.add_argument("--fps", type=float, default=30)
args = parser.parse_args() args = parser.parse_args()
fps_video = args.fps
arrow_writer = cv2.VideoWriter(args.video.replace(".mp4", "_arrows.mp4"), cv2.VideoWriter_fourcc(*'mp4v'), 30, (384, 384)) arrow_writer = cv2.VideoWriter(args.video.replace(".mp4", "_arrows.mp4"), cv2.VideoWriter_fourcc(*'mp4v'), fps_video, (384, 384))
pyqt_writer = cv2.VideoWriter(args.video.replace(".mp4", "_pyqt.mp4"), cv2.VideoWriter_fourcc(*'mp4v'), 30, (1600, 1200)) pyqt_writer = cv2.VideoWriter(args.video.replace(".mp4", "_pyqt.mp4"), cv2.VideoWriter_fourcc(*'mp4v'), fps_video, (1600, 1200))
depth_writer = cv2.VideoWriter(args.video.replace(".mp4", "_depth.mp4"), cv2.VideoWriter_fourcc(*'mp4v'), 30, (384, 384)) depth_writer = cv2.VideoWriter(args.video.replace(".mp4", "_depth.mp4"), cv2.VideoWriter_fourcc(*'mp4v'),fps_video, (384, 384))
sensor1 = orisys.Sensor(args.video, config_name="./config/prototype_of3.json", cal_path= "./config/dd01a_98.npy", isstitch=True, cuda=False, verbose=True) sensor1 = orisys.Sensor(args.video, config_name="./config/prototype_of3.json", cal_path= "./config/dd01a_98.npy", isstitch=True, cuda=False, verbose=True)
@@ -162,7 +163,6 @@ def main():
while True: while True:
sensor1.get_img() # 提取并拼接复眼图像 sensor1.get_img() # 提取并拼接复眼图像
sensor1.compute_deformation() # 计算形变和分解 sensor1.compute_deformation() # 计算形变和分解
sensor1.compute_contact() sensor1.compute_contact()
# 提取信息: # 提取信息:
@@ -170,11 +170,14 @@ def main():
# 帧率,时间戳: FPS, TIMESTAMP # 帧率,时间戳: FPS, TIMESTAMP
# 变形量总和: FNORMAL , FSHEARX, FSHEARY : 法向,切向(X),切向(Y) # 变形量总和: FNORMAL , FSHEARX, FSHEARY : 法向,切向(X),切向(Y)
fps, fn, fx, fy, flow, depth_map = sensor1.read_info(sensor1.info.FPS, sensor1.info.FNORMAL, sensor1.info.FSHEARX, sensor1.info.FSHEARY, sensor1.info.VRAW, sensor1.info.DEPTH) fps, fn, fx, fy, flow, depth_map = sensor1.read_info(sensor1.info.FPS, sensor1.info.FNORMAL, sensor1.info.FSHEARX, sensor1.info.FSHEARY, sensor1.info.VRAW, sensor1.info.DEPTH)
print(fps,fn,fx,fy) frame_count += 1
print(fps,fn,fx,fy,frame_count)
if sensor1.img is None:
break
# 显示向量场 # 显示向量场
# Background color #24292E (BGR) # Background color #24292E (BGR)
black_img = np.full_like(sensor1.img, bg_color) black_img = np.full_like(sensor1.img, bg_color)
arrows = orisys.util.draw_arrows(black_img, flow, threshold=2, grid_spacing=20, arrow_scale=0.5, colormap=cv2.COLORMAP_PARULA, below_threshold_color=text_color) arrows = orisys.util.draw_arrows(black_img, flow, threshold=1, grid_spacing=20, arrow_scale=0.5, colormap=cv2.COLORMAP_PARULA, below_threshold_color=text_color)
cv2.imshow("Deformation", arrows) cv2.imshow("Deformation", arrows)
# 显示深度图 # 显示深度图
@@ -192,11 +195,11 @@ def main():
# cv2.imshow("Depth Map", cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET)) # cv2.imshow("Depth Map", cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET))
# 显示图表 - 更新时间轴 # 显示图表 - 更新时间轴
current_time = time.time() - start_time elapsed_time = time.time() - start_time
for i in range(3): for i in range(3):
data[:-1, 0, i] = data[1:, 0, i] # shift time data left data[:-1, 0, i] = data[1:, 0, i] # shift time data left
data[:-1, 1, i] = data[1:, 1, i] # shift force data left data[:-1, 1, i] = data[1:, 1, i] # shift force data left
data[-1, 0, :] = frame_count/30.0 # set current time for all plots data[-1, 0, :] = frame_count/fps_video # set current time for all plots
data[-1, 1, 0] = fn data[-1, 1, 0] = fn
data[-1, 1, 1] = abs(fx) data[-1, 1, 1] = abs(fx)
data[-1, 1, 2] = abs(fy) data[-1, 1, 2] = abs(fy)
@@ -214,7 +217,7 @@ def main():
below = data_plot[:, 1, :] < plot_threshold below = data_plot[:, 1, :] < plot_threshold
data_plot[:, 1, :] = np.where(below, 0, data_plot[:, 1, :]) data_plot[:, 1, :] = np.where(below, 0, data_plot[:, 1, :])
update(plot_af, plot_tfx, plot_tfy, data_plot, p1, p2, p3) # Update plot update(plot_af, plot_tfx, plot_tfy, data_plot, p1, p2, p3) # Update plot
frame_count += 1 # frame_count += 1
# Convert pyqtgraph plot to image # Convert pyqtgraph plot to image
# Grab the GraphicsLayoutWidget as QPixmap # Grab the GraphicsLayoutWidget as QPixmap
@@ -222,7 +225,10 @@ def main():
# Convert QPixmap to QImage # Convert QPixmap to QImage
qimg = pixmap.toImage() qimg = pixmap.toImage()
# Convert QImage to numpy array (RGB format) # Convert QImage to numpy array (RGB format)
qimg = qimg.convertToFormat(QImage.Format_RGB888) # Qt6/PySide6: QImage.Format.Format_RGB888; Qt5: QImage.Format_RGB888
QImg = QtGui.QImage
fmt = getattr(QImg.Format, 'Format_RGB888', None) or getattr(QImg, 'Format_RGB888')
qimg = qimg.convertToFormat(fmt)
width = qimg.width() width = qimg.width()
height = qimg.height() height = qimg.height()
# Convert QImage to numpy array # Convert QImage to numpy array
+1 -1
View File
@@ -434,7 +434,7 @@ class Sensor:
except: except:
pass # Some backends don't support this property pass # Some backends don't support this property
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G')) self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M', 'J', 'P', 'G'))
# self.cap.set(cv2.CAP_PROP_FPS, self._config_fps) self.cap.set(cv2.CAP_PROP_FPS, self._config_fps)
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, self._config_resolution_raw[0]) self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, self._config_resolution_raw[0])
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, self._config_resolution_raw[1]) self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, self._config_resolution_raw[1])