Visualizzazione post con etichetta Charuco. Mostra tutti i post
Visualizzazione post con etichetta Charuco. Mostra tutti i post

giovedì 10 luglio 2025

Calibrazione PiCam HQ 12 Mpx

 Ho provato a calibrare la PiCam HQ 12.3 Mpx con sensore Sony IMX477

In modalita' foto la risoluzione e' 4056x3040 mentre in modalita' video parte da 640x480 30 fps


Ho usato sia una serie di foto sia un video usando lo script a link sottostante


 https://github.com/yumashino/Camera-Calibration-with-ChArUco-Board/tree/main

 


 

rispetto alla documentazione non e' piu' necessario usare libcam ma per scattare le foto si usa

 

rpicam-still --encoding png -o img_01.png

rpicam-still --raw -o 01.jpg (salva anche in DNG)

per i video

rpicam-vid  -t 10s --width 2028 --height 1080 -o test.mp4 (salva 10 secondi in h264)

 

calibration_time: "Thu 10 Jul 2025 07:32:59 CEST"
image_width: 4032
image_height: 3024
flags: 0
camera_matrix: !!opencv-matrix
   rows: 3
   cols: 3
   dt: d
   data: [ 3377.8915344697502, 0., 2032.4285452943598, 0.,
       3394.7675726553693, 1455.5140917783713, 0., 0., 1. ]
distortion_coefficients: !!opencv-matrix
   rows: 1
   cols: 5
   dt: d
   data: [ 0.24433970441928685, -1.371442972691743,
       0.0033488938962143514, -0.00060884641206734576,
       2.3798752100481146 ]
avg_reprojection_error: 2.668497308654219



lunedì 23 settembre 2024

Spot Robot Calibration Board Boston Bynamics e OpenCV

Ho avuto la fortuna di poter usare una enorma Charuco Board legata al cane robot Spot della Boston Dynamics


Nonostante non sia esplicitamente indicato si tratta di una Charuco Board 4x4_100 di 9 colonne e 4 righe

Per usarla per calibrare una camera si puo' usare il seguente script OpenCV

Attenzione: per funzionare lo script necessita setLegacyPattern(True)

import os
import numpy as np
import cv2

# ------------------------------
# ENTER YOUR REQUIREMENTS HERE:
ARUCO_DICT = cv2.aruco.DICT_4X4_250
SQUARES_VERTICALLY = 9
SQUARES_HORIZONTALLY = 4
SQUARE_LENGTH = 0.115
MARKER_LENGTH = 0.09
# ...
PATH_TO_YOUR_IMAGES = './hikvision'
# ------------------------------

def calibrate_and_save_parameters():
# Define the aruco dictionary and charuco board
dictionary = cv2.aruco.getPredefinedDictionary(ARUCO_DICT)
board = cv2.aruco.CharucoBoard((SQUARES_VERTICALLY, SQUARES_HORIZONTALLY), SQUARE_LENGTH, MARKER_LENGTH, dictionary)
board.setLegacyPattern(True)
params = cv2.aruco.DetectorParameters()
params.cornerRefinementMethod = 0


image_files = [os.path.join(PATH_TO_YOUR_IMAGES, f) for f in os.listdir(PATH_TO_YOUR_IMAGES) if f.endswith(".jpg")]
image_files.sort()

all_charuco_corners = []
all_charuco_ids = []

for image_file in image_files:
print(image_file)
image = cv2.imread(image_file)
marker_corners, marker_ids, _ = cv2.aruco.detectMarkers(image, dictionary, parameters=params)

# If at least one marker is detected
if len(marker_ids) > 0:
charuco_retval, charuco_corners, charuco_ids = cv2.aruco.interpolateCornersCharuco(marker_corners, marker_ids, image, board)

if charuco_retval:
all_charuco_corners.append(charuco_corners)
all_charuco_ids.append(charuco_ids)

# Calibrate camera
retval, camera_matrix, dist_coeffs, rvecs, tvecs = cv2.aruco.calibrateCameraCharuco(all_charuco_corners, all_charuco_ids, board, image.shape[:2], None, None)

# Save calibration data
np.save('hik_camera_matrix.npy', camera_matrix)
np.save('hik_dist_coeffs.npy', dist_coeffs)


cv2.destroyAllWindows()

calibrate_and_save_parameters()







Analisi MNF su spettri di riflettanza di plastica

Devo cerca di lavorare su spettri di riflettanza di plastica e la prima domanda e': quale sono le bande significative? Sono partito dal ...