Show the Python (cv2) code this page runs
import cv2, numpy as np
nx, ny, square = 9, 6, 25.0 # inner corners, mm
objp = np.zeros((nx * ny, 3), np.float32)
objp[:, :2] = np.mgrid[0:nx, 0:ny].T.reshape(-1, 2) * square
# live: found, corners = cv2.findChessboardCorners(gray, (nx, ny),
# cv2.CALIB_CB_ADAPTIVE_THRESH | cv2.CALIB_CB_NORMALIZE_IMAGE | cv2.CALIB_CB_FAST_CHECK)
# capture (each view):
corners = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
objpoints.append(objp); imgpoints.append(corners)
rms, K, dist, rvecs, tvecs, std_in, std_ex, per_view = \
cv2.calibrateCameraExtended(objpoints, imgpoints, (w, h), None, None)
newK, roi = cv2.getOptimalNewCameraMatrix(K, dist, (w, h), alpha)
mapx, mapy = cv2.initUndistortRectifyMap(K, dist, None, newK, (w, h), cv2.CV_32FC1)
undistorted = cv2.remap(frame, mapx, mapy, cv2.INTER_LINEAR)
ok, rvec, tvec = cv2.solvePnP(objp, corners, K, dist) # distance = |tvec|
It is the real OpenCV-Python 4.10 compiled to WebAssembly (Pyodide), running inside a Web Worker. Your video never leaves your computer.