Skip to content

Commit

Permalink
wip5
Browse files Browse the repository at this point in the history
  • Loading branch information
yakir12 committed Dec 19, 2024
1 parent d09d4b0 commit 930d0ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/detect_fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ function fit_model(sz, objpoints, imgpointss, n_corners, with_distortion, aspec
imagePoints = OpenCV.InputArray[Float32.(reshape(stack(imgpoints), 2, 1, :)) for imgpoints in imgpointss]
imageSize = OpenCV.Size{Int32}(sz...)

cammat = convert(Matrix{Float64}, I(3))
cammat = convert(Matrix{Float32}, I(3))
cammat[1,:] .= aspect
cameraMatrix = OpenCV.Mat(Float32.(reshape(cammat, 1, 3, 3)))
distCoeffs = OpenCV.Mat(Array{Float32}(undef, 1, 1, 5))

flags = OpenCV.CALIB_ZERO_TANGENT_DIST + OpenCV.CALIB_FIX_K3 + OpenCV.CALIB_FIX_K2 + (with_distortion ? 0 : OpenCV.CALIB_FIX_K1) + OpenCV.CALIB_FIX_ASPECT_RATIO

r = OpenCV.InputArray[Array{Float32}(undef, 3, 1, prod(n_corners)) for _ in 1:nfiles]
t = OpenCV.InputArray[Array{Float32}(undef, 3, 1, prod(n_corners)) for _ in 1:nfiles]
# r = OpenCV.InputArray[Array{Float32}(undef, 3, 1, prod(n_corners)) for _ in 1:nfiles]
r = OpenCV.InputArray[ones(Float32, 3, 1, prod(n_corners)) for _ in 1:nfiles]
# t = OpenCV.InputArray[Array{Float32}(undef, 3, 1, prod(n_corners)) for _ in 1:nfiles]
t = OpenCV.InputArray[ones(Float32, 3, 1, prod(n_corners)) for _ in 1:nfiles]

x, mtx, dist, rvecs, tvecs = OpenCV.calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, r, t, flags, CRITERIA)

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ end
_, xys2 = CameraCalibrations._detect_corners(file, n_corners, sz)
return xys2
end
if xys xys2
@show n_corners, ratio
end
@test xys == xys2
end
end
Expand Down

0 comments on commit 930d0ba

Please sign in to comment.