去除FFMPEG后端
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -104,6 +104,7 @@ def LIII(left_image):
|
||||
|
||||
|
||||
def LM(left_image):
|
||||
|
||||
return left_image[yt:yb, :]
|
||||
|
||||
|
||||
@@ -116,6 +117,7 @@ def RIV(right_image):
|
||||
|
||||
|
||||
def RM(right_image):
|
||||
|
||||
return right_image[yt:yb, :]
|
||||
|
||||
|
||||
@@ -194,7 +196,10 @@ class BirdView(BaseThread):
|
||||
return self.image[yt:yb, xl:xr]
|
||||
|
||||
def stitch_all_parts(self):
|
||||
|
||||
front, back, left, right = self.frames
|
||||
print(front.shape, back.shape, left.shape, right.shape)
|
||||
|
||||
np.copyto(self.F, FM(front))
|
||||
np.copyto(self.B, BM(back))
|
||||
np.copyto(self.L, LM(left))
|
||||
@@ -326,7 +331,8 @@ class BirdView(BaseThread):
|
||||
self.processing_mutex.lock()
|
||||
|
||||
self.update_frames(self.proc_buffer_manager.get().values())
|
||||
self.make_luminance_balance().stitch_all_parts()
|
||||
self.stitch_all_parts() # 直接拼接原始投影图像
|
||||
# self.make_luminance_balance().stitch_all_parts()
|
||||
self.make_white_balance()
|
||||
self.copy_car_image()
|
||||
self.buffer.add(self.image.copy(), self.drop_if_full)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import cv2
|
||||
from PyQt5.QtCore import qDebug
|
||||
|
||||
from .base_thread import BaseThread
|
||||
from .structures import ImageFrame
|
||||
from .utils import gstreamer_pipeline
|
||||
|
||||
|
||||
|
||||
@@ -11,11 +9,10 @@ class CaptureThread(BaseThread):
|
||||
|
||||
def __init__(self,
|
||||
device_id,
|
||||
# flip_method=2,
|
||||
flip_method=0,
|
||||
drop_if_full=True,
|
||||
api_preference=cv2.CAP_ANY,
|
||||
resolution=None,
|
||||
# use_gst=None,
|
||||
parent=None):
|
||||
"""
|
||||
device_id: device number of the camera.
|
||||
@@ -27,8 +24,7 @@ class CaptureThread(BaseThread):
|
||||
"""
|
||||
super(CaptureThread, self).__init__(parent)
|
||||
self.device_id = device_id
|
||||
# self.flip_method = flip_method
|
||||
# self.use_gst = None
|
||||
self.flip_method = flip_method
|
||||
self.drop_if_full = drop_if_full
|
||||
self.api_preference = api_preference
|
||||
self.resolution = resolution
|
||||
@@ -61,15 +57,25 @@ class CaptureThread(BaseThread):
|
||||
continue
|
||||
|
||||
# retrieve frame and add it to buffer
|
||||
_, frame = self.cap.retrieve()
|
||||
_, frame = self.cap.read()
|
||||
|
||||
# Skip empty frames (e.g., when camera capture times out)
|
||||
if frame is None or frame.size == 0:
|
||||
continue
|
||||
|
||||
# Apply image flip if needed
|
||||
if self.flip_method == 2:
|
||||
frame = cv2.rotate(frame, cv2.ROTATE_180)
|
||||
|
||||
# frame = cv2.resize(frame, (960, 640))
|
||||
img_frame = ImageFrame(self.clock.msecsSinceStartOfDay(), frame)
|
||||
self.buffer_manager.get_device(self.device_id).add(img_frame, self.drop_if_full)
|
||||
|
||||
# update statistics
|
||||
self.update_fps(self.processing_time)
|
||||
self.stat_data.frames_processed_count += 1
|
||||
# inform GUI of updated statistics
|
||||
self.update_statistics_gui.emit(self.stat_data)
|
||||
# self.update_fps(self.processing_time)
|
||||
# self.stat_data.frames_processed_count += 1
|
||||
# # inform GUI of updated statistics
|
||||
# self.update_statistics_gui.emit(self.stat_data)
|
||||
|
||||
qDebug("Stopping capture thread...")
|
||||
|
||||
@@ -83,7 +89,6 @@ class CaptureThread(BaseThread):
|
||||
# try to set camera resolution
|
||||
if self.resolution is not None:
|
||||
width, height = self.resolution
|
||||
|
||||
self.cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"YUYV"))
|
||||
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
|
||||
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
|
||||
|
||||
@@ -92,7 +92,7 @@ class FisheyeCameraModel(object):
|
||||
return cv2.transpose(image)[::-1]
|
||||
|
||||
else:
|
||||
return np.flip(cv2.transpose(image), 1)
|
||||
return cv2.transpose(image)[::-1]
|
||||
|
||||
def save_data(self):
|
||||
fs = cv2.FileStorage(self.camera_file, cv2.FILE_STORAGE_WRITE)
|
||||
|
||||
@@ -2,6 +2,7 @@ import cv2
|
||||
from PyQt5.QtCore import qDebug, QMutex
|
||||
|
||||
from .base_thread import BaseThread
|
||||
from . import param_settings as settings
|
||||
|
||||
|
||||
class CameraProcessingThread(BaseThread):
|
||||
@@ -47,10 +48,28 @@ class CameraProcessingThread(BaseThread):
|
||||
|
||||
self.processing_mutex.lock()
|
||||
raw_frame = self.capture_buffer_manager.get_device(self.device_id).get()
|
||||
|
||||
# Validate frame before processing
|
||||
if raw_frame.image is None or raw_frame.image.size == 0:
|
||||
self.processing_mutex.unlock()
|
||||
continue
|
||||
|
||||
und_frame = self.camera_model.undistort(raw_frame.image)
|
||||
pro_frame = self.camera_model.project(und_frame)
|
||||
flip_frame = self.camera_model.flip(pro_frame)
|
||||
self.processing_mutex.unlock()
|
||||
|
||||
# Check if the processed frame has valid dimensions
|
||||
name = self.camera_model.camera_name
|
||||
if name in settings.project_shapes:
|
||||
# For left and right cameras, the flip operation changes the shape
|
||||
if name in ['left', 'right']:
|
||||
expected_shape = settings.project_shapes[name] + (3,)
|
||||
else:
|
||||
expected_shape = settings.project_shapes[name][::-1] + (3,)
|
||||
if flip_frame.shape != expected_shape:
|
||||
print(f"Warning: {name} camera frame has unexpected shape {flip_frame.shape}, expected {expected_shape}")
|
||||
continue
|
||||
|
||||
self.proc_buffer_manager.sync(self.device_id)
|
||||
self.proc_buffer_manager.set_frame_for_device(self.device_id, flip_frame)
|
||||
|
||||
Reference in New Issue
Block a user