ExamplesΒΆ
GUIs
GUI objects can be instantiated in multiple ways. You may simply run the Argus launcher from terminal:
$ Argus
which will bring up a Tkinter window with 6 buttons that each launches a GUI.
Or you may instantiate any of the GUI objects within a python console or script:
import argus_gui as ag
# bring up DWarp
ag.dwarpGUI()
# bring up Sync
ag.syncGUI()
# bring up Patterns
ag.patternsGUI()
# bring up Calibrate
ag.calibrateGUI()
# bring up Wand
ag.wandGUI()
# bring up Clicker
ag.clickerGUI()
Finally, Argus comes with executable scripts that can accomplish the same tasks as these GUIs in command line:
# undistort a video
$ argus-dwarp movie.mp4 --model "GoPro Hero4 Black" --mode 1080p-120fps-wide --write --ofile undistorted_movie.mp4
# find the offset between three videos
$ argus-sync "a.mp4,b.mp4,c.mp4"
# find patterns in a video and write to a pickle file
$ argus-patterns patterns.mp4 patterns.pkl
# solve for camera intrinsics and pinhole distortion coefficients, write to a CSV
$ argus-calibrate patterns.pkl intrinsics.csv --inverted
# use SBA to solve for DLT coefficients and output 3D coordinates
$ argus-wand cams.txt project_name --paired_points wand-xypts.csv --scale 1
For more information on the function and use of the GUIs please consult the GUI section of the documenation found at http://argus.web.unc.edu.
Other functions
Argus can be used to accomplish a variety of other camera calibration tasks. Here are a few examples:
"""
Undistorting and redistorting points from an array
"""
from argus_gui import DistortionProfile
# getting a profile, Model: GoPro Hero4 Black, Mode: 1440p-80fps-wide'
dis = DistortionProfile()
prof = dis.get_coefficients('GoPro Hero4 Black', '1440p-80fps-wide')
# pixel coordinate array
pts = np.array([[100., 250.],[15., 525.]])
print 'Original pixel coordinates: ', pts
# undistort
pts = undistort_pts(pts, prof)
print 'Undistorted pixel coordinates: ', pts
# redistort back
pts = redistort_pts(pts, prof)
print 'Redistorted pixel coordinates: ', pts
"""
Undistorting a frame from a movie, saving as a png
"""
# filname
movie = '1080p_120_test.mp4'
# make a distortion profile
dis = DistortionProfile()
prof = dis.get_coefficients('GoPro Hero4 Black', '1080p-120fps-wide')
# get an undistorter object
undistorter = dis.get_undistorter()
undistorter.set_movie(movie)
# undistort frame number 10
array = undistorter.undistort_frame(10, '10.png')
"""
Undistorting an array
"""
# undistort the image array returned (double undistortion)
array = undistorter.undistort_array(array, '10_2.png')
"""
Load some DLT coefficients, and uv coordinates, make a camera profile, then project
back and forth
"""
# set our distortion profile to another camera
dis.set_coefficients(model = 'GoPro Hero4 Black', mode = '1080p-120fps-narrow')
prof = dis.get_coefficients()
# get a camera profile (list of distortion profiles)
# here each distortion profile is the same, so we use this method
cam_pro = dis.get_cam_profile(ncams = 3)
# load som DLT coefficients
dlt = np.loadtxt('test-dlt-coefficients.csv', delimiter = ',').T
# load some points
points = pd.DataFrame.from_csv('pts.csv', index_col = False).as_matrix()
# undistort them
points[:,:2] = undistort_pts(points[:,:2], prof)
points[:,2:4] = undistort_pts(points[:,2:4], prof)
points[:,4:] = undistort_pts(points[:,4:], prof)
# project into 3D space
xyz = uv_to_xyz(points, cam_pro, dlt)
# project back into the image plane for camera 1
uv = dlt_inverse(dlt[0], xyz)
# plot the reprojection to see how good the mapping is
plt.scatter(uv[:,0], uv[:,1], c= 'b')
plt.scatter(points[:,0], points[:,1], c = 'r')
plt.show()
"""
Solve for our own DLT coefficients
"""
L1, er = solve_dlt(xyz, points[:,:2], prof)
L2, er = solve_dlt(xyz, points[:,2:4], prof)
L3, er = solve_dlt(xyz, points[:,4:], prof)
"""
Triangulate pixel coordinates with camera intrinsics
"""
# get the distorted points
points = pd.DataFrame.from_csv('pts.csv', index_col = False).as_matrix()
# triangulate
xyz = multiTriangulator(points, cam_pro)
xyz = xyz.triangulate()
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(xyz[:,0], xyz[:,1], xyz[:,2])
plt.show()
"""
Get reprojection errors
"""
errors = get_repo_errors(xyz, points, cam_pro, dlt)
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot(range(len(errors[0])), errors[0])
plt.show()
"""
Bootstrap to get confidence intervals, spline weights and tolerances
"""
CIs, weights, tols = bootstrapXYZs(points, errors, cam_pro, dlt)