Change to CAP_DSHOW for VideoCapture
This commit is contained in:
+20
-14
@@ -436,25 +436,25 @@ class HomeWindow(QWidget):
|
||||
for camera in self.cameraList: # Loop all Cameras
|
||||
ok, frame = camera.capture.read() #Capture a frame
|
||||
|
||||
if not ok: # Check if captured frame is valid, if even one frame is invalide the whole capture failed
|
||||
if not ok: # A single failed grab shouldn't discard what other cameras saw
|
||||
self.logger.log(f"Could not grab frame for calibration sample, from camera {camera.index}.")
|
||||
return
|
||||
|
||||
h, w = frame.shape[:2]
|
||||
continue
|
||||
|
||||
h, w = frame.shape[:2]
|
||||
self.logger.log(f"cam{camera.index} capture size = {w}x{h}")
|
||||
|
||||
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Turn the frame black and white
|
||||
gray = 255 - gray # Invert the color of the frame, as the ChArCuo board I use is inverted (to save printer Ink)
|
||||
|
||||
h, w = gray.shape[:2]
|
||||
h, w = gray.shape[:2]
|
||||
self.logger.log(f"cam{camera.index} capture size = {w}x{h}")
|
||||
|
||||
#This is apparently a fast check, bevor i detect the actuall board
|
||||
corner, ids, _ = self.arcuo_detector.detectMarkers(gray) #Detect ChArCuo Markers
|
||||
if ids is None or len(ids) == 0: #Check if Markers where found, if none where found the sample is invalid
|
||||
if ids is None or len(ids) == 0: #Board not visible from this camera this time, skip it, not the whole sample
|
||||
self.logger.log(f"Not enought markers found for calibration sample, from camera {camera.index}.")
|
||||
return
|
||||
|
||||
continue
|
||||
|
||||
# Detecting the Charcuo board and evaluating if its good as a sample
|
||||
result = self.charuco_detector.detectBoard(gray)
|
||||
|
||||
@@ -463,12 +463,12 @@ class HomeWindow(QWidget):
|
||||
|
||||
if charuco_ids is None:
|
||||
self.logger.log(f"Not enought markers found for calibration sample, from camera {camera.index}.")
|
||||
return
|
||||
|
||||
continue
|
||||
|
||||
if len(charuco_ids) < MIN_CHARUCO_CORNERS:
|
||||
self.logger.log(f"Not enought markers found for calibration sample, from camera {camera.index}.")
|
||||
return
|
||||
|
||||
continue
|
||||
|
||||
# Adding the sample for the current camera to detections
|
||||
detections[camera.index] = CharucoDetection(
|
||||
camera_id = camera.index,
|
||||
@@ -477,12 +477,18 @@ class HomeWindow(QWidget):
|
||||
gray_frame = gray
|
||||
)
|
||||
|
||||
# All cameras found valide markers so the sample capture was succesfull
|
||||
# Need at least two cameras' worth of detections for this sample to be
|
||||
# useful for stereo pairing (a single-camera detection can still help
|
||||
# that camera's intrinsics, but can't contribute to any camera pair).
|
||||
if len(detections) < 2:
|
||||
self.logger.log("Not enough cameras saw the board in this sample, discarding.")
|
||||
return
|
||||
|
||||
self.calibration_samples.append(
|
||||
CalibrationSample(detections=detections)
|
||||
)
|
||||
|
||||
self.logger.log("Added calibration sample.")
|
||||
self.logger.log(f"Added calibration sample ({len(detections)}/{len(self.cameraList)} cameras saw the board).")
|
||||
|
||||
def updateCameras(self):
|
||||
self._clearLayout()
|
||||
|
||||
Reference in New Issue
Block a user