Computer Vision Toolbox Users Guide Unknown pdf download
Computer Vision Toolbox Users Guide Unknown pdf download
download
https://ebookbell.com/product/computer-vision-toolbox-users-
guide-unknown-49478960
https://ebookbell.com/product/matlab-computer-vision-system-toolbox-
documentation-6741128
Computer Vision Eccv 2022 17th European Conference Tel Aviv Israel
October 2327 2022 Proceedings Part Vi Shai Avidan
https://ebookbell.com/product/computer-vision-eccv-2022-17th-european-
conference-tel-aviv-israel-october-2327-2022-proceedings-part-vi-shai-
avidan-47217540
Computer Vision Eccv 2022 17th European Conference Tel Aviv Israel
October 2327 2022 Proceedings Part Viii Shai Avidan
https://ebookbell.com/product/computer-vision-eccv-2022-17th-european-
conference-tel-aviv-israel-october-2327-2022-proceedings-part-viii-
shai-avidan-47284126
https://ebookbell.com/product/computer-vision-in-medical-imaging-
chihau-chen-47986042
Computer Vision Statistical Models For Marrs Paradigm 1st Edition
Songchun Zhu
https://ebookbell.com/product/computer-vision-statistical-models-for-
marrs-paradigm-1st-edition-songchun-zhu-48225808
https://ebookbell.com/product/computer-vision-metrics-scott-
krig-48655120
https://ebookbell.com/product/computer-vision-algorithms-and-
applications-texts-in-computer-science-2nd-ed-2022-richard-
szeliski-48676718
https://ebookbell.com/product/computer-vision-and-machine-
intelligence-paradigms-for-sdgs-select-proceedings-of-
icrtaccvmip-2021-1st-ed-2023-r-jagadeesh-kannan-48909164
https://ebookbell.com/product/computer-vision-imaging-and-computer-
graphics-theory-and-applications-16th-international-joint-conference-
visigrapp-2021-virtual-event-february-810-2021-revised-selected-
papers-a-augusto-de-sousa-49113516
Computer Vision Toolbox™
User's Guide
R2023a
How to Contact MathWorks
Phone: 508-647-7000
v
Code Generation for Object Detection by Using YOLO v2 . . . . . . . . . . . . . 2-5
Activity Recognition from Video and Optical Flow Data Using Deep
Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-168
vi Contents
Evaluate a Video Classifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-196
vii
Generate Image from Segmentation Map Using Deep Learning . . . . . . 3-452
Find Image Rotation and Scale Using Automated Feature Matching . . . 4-25
viii Contents
Encode Point Cloud Data For Deep Learning . . . . . . . . . . . . . . . . . . . . . . 5-30
ix
Rotation Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-61
x Contents
Detect Cars Using Gaussian Mixture Models . . . . . . . . . . . . . . . . . . . . . . 8-98
Labelers
9
View Summary of ROI and Scene Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
xi
Get Started with the Video Labeler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48
Load Unlabeled Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48
Create Label Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-48
Label Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-54
Export Labeled Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-56
Label Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-58
Save App Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-59
xii Contents
Use Sublabels and Attributes to Label Ground Truth Data . . . . . . . . . . . 9-85
When to Use Sublabels vs. Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-85
Draw Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-86
Copy and Paste Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-86
Delete Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-87
Sublabel Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-88
Featured Examples
10
Localize and Read Multiple Barcodes in Image . . . . . . . . . . . . . . . . . . . . 10-2
xiii
Key Frame and Map Data Management . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Map Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-11
Local Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Loop Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Drift Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-15
xiv Contents
Support Package Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6
xv
Import from Video Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
Setting Block Parameters for this Example . . . . . . . . . . . . . . . . . . . . . . . 14-4
Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5
xvi Contents
Circle Grid Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-9
Custom Pattern Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-9
Object Detection
17
Train Custom OCR Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-2
Prepare Training Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-2
Train an OCR model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-4
Evaluate OCR training . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-5
xvii
Getting Started with Video Classification Using Deep Learning . . . . . . 17-14
Create Training Data for Video Classification . . . . . . . . . . . . . . . . . . . . 17-15
Create Video Classifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-15
Train Video Classifier and Evaluate Results . . . . . . . . . . . . . . . . . . . . . 17-22
Classify Using Deep Learning Video Classifiers . . . . . . . . . . . . . . . . . . . 17-23
xviii Contents
Label Training Data for Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . 17-59
Getting Started with R-CNN, Fast R-CNN, and Faster R-CNN . . . . . . . . 17-61
Object Detection Using R-CNN Algorithms . . . . . . . . . . . . . . . . . . . . . . 17-61
Comparison of R-CNN Object Detectors . . . . . . . . . . . . . . . . . . . . . . . . 17-63
Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-63
Design an R-CNN, Fast R-CNN, and a Faster R-CNN Model . . . . . . . . . . 17-64
Label Training Data for Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . 17-65
xix
Image Classification with Bag of Visual Words . . . . . . . . . . . . . . . . . . . 17-126
Step 1: Set Up Image Category Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 17-126
Step 2: Create Bag of Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-126
Step 3: Train an Image Classifier With Bag of Visual Words . . . . . . . . 17-127
Step 4: Classify an Image or Image Set . . . . . . . . . . . . . . . . . . . . . . . . 17-128
Fixed-Point Design
21
Fixed-Point Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
Fixed-Point Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
Benefits of Fixed-Point Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2
Benefits of Fixed-Point Design with System Toolboxes Software . . . . . . . 21-2
xx Contents
Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-5
Precision and Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-6
Portable C Code Generation for Functions That Use OpenCV Library . . 22-4
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22-4
xxi
Find Minimum Value in ROI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23-25
xxii Contents
Linearly Combine Two Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23-98
Convert Data Type and Color Space of Image from RGB to HSV . . . . . 23-153
xxiii
Perform Chroma Resampling of Image . . . . . . . . . . . . . . . . . . . . . . . . . 23-180
xxiv Contents
1
Monocular visual-inertial odometry estimates the position and orientation of the robot using camera
and inertial measurement unit (IMU) sensor data. Camera-based state estimation is accurate during
low-speed navigation. However, camera-based estimation faces challenges such as motion blur and
track loss at higher speeds. Also monocular camera-based estimation can estimate poses at an
arbitrary scale. On the other hand, inertial navigation can handle high-speed navigation easily and
estimate poses at world scale. You can combine the advantages of both types of sensor data to
achieve better accuracy using tightly coupled factor graph optimization.
Overview
The visual-inertial system implemented in this example consists of a simplified version of the
monocular visual odometry front-end of the VINS [1 on page 1-25] algorithm and a factor graph
back-end.
The visual odometry front-end has responsibilities similar to standard structure from motion (SfM)
algorithms, such as oriented FAST and rotated BRIEF (ORB) and simultaneous localization and
mapping (SLAM). The visual odometry front-end detects and tracks key points across multiple
frames, estimates camera poses, and triangulates 3-D points using multi-view geometry. The factor
graph back-end jointly optimizes the estimated camera poses, 3-D points, IMU velocity, and bias.
Before fusing the camera and IMU measurements, you must align the camera and IMU to compute
the camera pose scale, gravity rotation, and initial IMU velocity and bias.
1-2
Monocular Visual-Inertial Odometry Using Factor Graph
Set Up
This example uses the Blackbird data set (NYC Subway Winter) to demonstrate the visual-inertial
odometry workflow. Download the data set.
data = helperDownloadData();
rng(0)
1-3
1 Camera Calibration and SfM Examples
• Sliding window size (windowSize) - Maximum number of frames in the sliding window.
• Frame rate at which to run the sliding window optimization (optimizationFrequency)
params = helperVIOParameters();
% Set to true if IMU data is available.
useIMU = true;
Initialize variables.
status = struct("firstFrame",true,"isMapInitialized",false,"isIMUAligned",false,"Mediandepth",fal
% Set to true to attempt camera-IMU alignment.
readyToAlignCameraAndIMU = false;
% Set initial scene median depth.
initialSceneMedianDepth = 4;
viewId = 0;
removedFrameIds = [];
allCameraTracks = cell(1,5000);
% Enable visualization.
vis = true;
showMatches = false;
if vis
% Figure variables.
axMatches = [];
axTraj = [];
axMap = [];
end
Set up factor graph for back-end tightly coupled factor graph optimization.
% Set up factor graph for fusion.
slidingWindowFactorGraph = factorGraph;
maxFrames = 10000;
maxLandmarks = 100000;
ids = helperGenerateNodeID(slidingWindowFactorGraph,maxFrames,maxLandmarks);
% Information matrix (measure of accuracy) associated with the camera
% projection factors that relate 3-D points and estimated camera poses.
cameraInformation = ((data.intrinsics.K(1,1)/1.5)^2)*eye(2);
% Initialize IMU parameters. The fusion accuracy depends on these parameters.
imuParams = factorIMUParameters(SampleRate=100,GyroscopeNoise=0.1, ...
GyroscopeBiasNoise=3e-3,AccelerometerNoise=0.3, ...
AccelerometerBiasNoise=1e-3,ReferenceFrame="ENU");
Create the point tracker to track key points across multiple frames.
tracker = vision.PointTracker(MaxBidirectionalError=params.KLT_BiErr, ...
NumPyramidLevels=params.KLT_Levels,BlockSize=params.KLT_Block);
Specify the first and last frames to process from the data set. Then, process the first frame.
1-4
Monocular Visual-Inertial Odometry Using Factor Graph
% In the first frame, detect new key points and initialize the tracker for
% future tracking.
status.firstFrame = false;
I = data.images{startFrameIdx};
if params.Equalize
% Enhance contrast if images are dark.
I = adapthisteq(I,NumTiles=params.NumTiles,ClipLimit=params.ClipLimit);
end
if params.Undistort
% Undistort if images contain perspective distortion.
I = undistortImage(I,data.intrinsics);
end
% Assign a unique view ID for each processed camera frame or image.
viewId = viewId + 1;
currPoints = createNewFeaturePoints(fManager,I);
updateSlidingWindow(fManager,I,currPoints,true(size(currPoints,1),1),viewId);
initialize(tracker, currPoints, I);
prevI = I;
firstI = I;
vSet = addView(vSet,viewId,rigidtform3d);
Image Preprocessing
• Equalize — Enhance the contrast of an image to correct for dim lighting, which can affect feature
extraction and tracking.
• Undistort — Correct for radial and tangential distortions that can impact state estimation.
Feature Tracking
To compute a camera frame pose, you must calculate 2D-2D correspondences (2-D image point tracks
across multiple frames). There are several ways to estimate 2-D feature points that see the same
1-5
1 Camera Calibration and SfM Examples
landmark (key point tracks), but this example uses a Kalman tracker for tracking feature points in
multiple images.
Tracks are not all accurate and can contain outliers. Tracking performance also depends on the
Kalman tracker parameters, such as bidirectional error. Even in an ideal case, you can expect some
invalid tracks, such as those due to repetitive structures. As such, outlier rejection is a critical task in
feature tracking. To reject outliers from tracks, use fundamental matrix decomposition in the feature
point manager while updating the sliding window with the latest feature point tracks.
Visualize the feature point tracks between the last key frame and current frame.
if status.isMapInitialized
svIds = getSlidingWindowIds(fManager);
if length(svIds) > 2
[matches1,matches2] = get2DCorrespondensesBetweenViews(fManager,svIds(end-2),viewId);
The accelerometer and gyroscope readings of the IMU data contain some bias and noise. To estimate
bias values, you must obtain accurate pose estimates between the first few frames. You can achieve
this by using SfM. SfM involves these major steps:
• When there is enough parallax between the first key frame and the current frame, estimate the
relative pose between the two, using 2D-2D correspondences (key point tracks across multiple
frames).
• Triangulate 3-D points using the world poses of key frames and 2D-2D correspondences.
1-6
Monocular Visual-Inertial Odometry Using Factor Graph
• Track the 3-D points in the current frame, and compute the current frame pose using 3D-2D
correspondences.
if ~status.isMapInitialized
if windowState.FirstFewViews
% Accept the first few camera views.
vSet = addView(vSet,viewId,rigidtform3d);
elseif windowState.EnoughParallax
% Estimate relative pose between the first key frame in the
% window and the current frame.
svIds = getSlidingWindowIds(fManager);
[matches1,matches2] = get2DCorrespondensesBetweenViews(fManager,svIds(end-1),svId
valRel = false(size(matches1,1),1);
for k = 1:10
[F1,valRel1] = estimateFundamentalMatrix( ...
matches1,matches2,Method="RANSAC", ...
NumTrials=params.F_Iterations,DistanceThreshold=params.F_Threshold, ...
Confidence=params.F_Confidence);
if length(find(valRel)) < length(find(valRel1))
valRel = valRel1;
F = F1;
end
end
inlierPrePoints = matches1(valRel,:);
inlierCurrPoints = matches2(valRel,:);
relPose = estrelpose(F,data.intrinsics, ...
inlierPrePoints,inlierCurrPoints);
%vSet = addView(vSet,svIds(end-1),currPose);
vSet = addView(vSet,viewId,currPose);
status.isMapInitialized = true;
1-7
1 Camera Calibration and SfM Examples
Camera-IMU Alignment
To optimize camera and IMU measurements, you must align them by bringing them to the same base
coordinate frame and scale. Alignment primarily consists of these major tasks:
• Compute the camera pose scale to make it similar to the IMU or world scale.
• Calculate the gravity rotation required to rotate gravity vector from local navigation reference
frame of IMU to initial camera reference frame. The inverse of this rotation aligns the z-axis of the
camera with the local navigation reference frame.
• Estimate the initial IMU bias.
if ~status.isIMUAligned && readyToAlignCameraAndIMU
svIds = getSlidingWindowIds(fManager);
% Because you have not yet computed the latest frame pose,
% So use only the past few frames for alignment.
svIds = svIds(1:end-1);
[gyro,accel] = helperExtractIMUDataBetweenViews( ...
data.gyroReadings,data.accelReadings,data.timeStamps,allFrameIds(svIds));
[xyz] = getXYZPoints(fManager,xyzIds);
% Align camera with IMU.
camPoses = poses(vSet,svIds);
[gRot,scale,info] = ...
1-8
Monocular Visual-Inertial Odometry Using Factor Graph
estimateGravityRotationAndPoseScale(camPoses,gyro,accel, ...
SensorTransform=data.camToIMUTransform,IMUParameters=imuParams);
disp("Estimated scale: " + scale);
If the alignment is successful, update the camera poses, 3-D points, and add IMU factors between the
initial frames in the current sliding window.
if status.isIMUAligned
% After alignment, add IMU factors to factor graph.
for k = 1:length(gyro)
nId = [ids.pose(svIds(k)),ids.vel(svIds(k)),ids.bias(svIds(k)), ...
ids.pose(svIds(k+1)),ids.vel(svIds(k+1)),ids.bias(svIds(k+1))];
fIMU = factorIMU(nId,gyro{k},accel{k},imuParams,SensorTransform=data.
slidingWindowFactorGraph.addFactor(fIMU);
end
end
Estimate an initial guess for IMU bias by using factor graph optimization with the camera projection
and IMU factors.
1-9
1 Camera Calibration and SfM Examples
addFactor(slidingWindowFactorGraph,fVelPrior);
fixNode(slidingWindowFactorGraph,ids.pose(svIds(1)));
soll = optimize(slidingWindowFactorGraph, ...
params.SolverOpts);
fixNode(slidingWindowFactorGraph,ids.pose(svIds(1)),false);
1-10
Monocular Visual-Inertial Odometry Using Factor Graph
When IMU data is available, you can predict the world pose of the camera by integrating
accelerometer and gyroscope readings. Use factor graph optimization to further refine this
prediction.
imuGuess = false;
if status.isIMUAligned
% Extract gyro and accel reading between current image frame
% and last acquired image frame to create IMU factor.
svIds = getSlidingWindowIds(fManager);
svs = svIds((end-1):end);
[gyro,accel] = helperExtractIMUDataBetweenViews(data.gyroReadings, ...
data.accelReadings,data.timeStamps,allFrameIds(svs));
nodeID = [ids.pose(svs(1)) ...
ids.vel(svs(1)) ...
ids.bias(svs(1)) ...
ids.pose(svs(2)) ...
ids.vel(svs(2)) ...
ids.bias(svs(2))];
% Create the transformation required to trasform a camera pose
% to IMU base frame for the IMU residual computation.
fIMU = factorIMU(nodeID,gyro{1},accel{1},imuParams, ...
SensorTransform=data.camToIMUTransform);
1-11
1 Camera Calibration and SfM Examples
[currPoints,pointIds,isTriangulated] = getKeyPointsInView(fManager,viewId);
cVal = true(size(currPoints,1),1);
cTrf = find(isTriangulated);
If no IMU prediction is available, then use 3D-2D correspondences to estimate the current view pose.
if ~imuGuess
x3D = getXYZPoints(fManager,pointIds(isTriangulated));
c2D = currPoints(isTriangulated,:);
ii = false(size(x3D,1),1);
currPose = rigidtform3d;
for k = 1:params.F_loop
[currPosel,iil] = estworldpose( ...
currPoints(isTriangulated,:),x3D, ...
data.intrinsics,MaxReprojectionError=params.F_Threshold,Confidence=params.F_Confi
MaxNumTrials=params.F_Iterations);
if length(find(ii)) < length(find(iil))
ii = iil;
currPose = currPosel;
end
end
cVal(cTrf(~ii)) = false;
else
Use the IMU predicted pose as an initial guess for motion-only bundle adjustment.
x3D = getXYZPoints(fManager,pointIds(isTriangulated));
c2D = currPoints(isTriangulated,:);
[currPose,velRefined,biasRefined,ii] = helperBundleAdjustmentMotion( ...
x3D,c2D,data.intrinsics,size(I),pp,pv,prevP,prevVel,prevBias,fIMU);
slidingWindowFactorGraph.nodeState( ...
ids.vel(viewId),velRefined);
slidingWindowFactorGraph.nodeState( ...
ids.bias(viewId),biasRefined);
cVal(cTrf(~ii)) = false;
end
setKeyPointValidityInView(fManager,viewId,cVal);
vSet = addView(vSet,viewId,currPose);
Add camera projection factors related to the 3-D point tracks of the current view.
obs2 = pointIds(isTriangulated);
obs2 = obs2(ii);
fCam = factorCameraSE3AndPointXYZ( ...
[ids.pose(viewId*ones(size(obs2))) ids.point3(obs2)], ...
data.intrinsics.K,Measurement=c2D(ii,:), ...
Information=cameraInformation);
allCameraTracks{viewId} = [viewId*ones(size(obs2)) obs2 fCam.Measurement];
1-12
Monocular Visual-Inertial Odometry Using Factor Graph
slidingWindowFactorGraph.addFactor(fCam);
end
When using the latest 2D-2D correspondences for camera-world pose estimation, you must frequently
create new 3-D points.
if status.isMapInitialized
[newXYZ,newXYZID,newPointViews,newPointObs] = triangulateNew3DPoints(fManager,vSet);
Factor graph optimization reduces the error in trajectory or camera pose estimation. Various factors,
like inaccurate tracking and outliers, can contribute to estimation errors.
Graph optimization adjusts camera poses to satisfy various sensor measurement constraints, like
camera observations (3-D point projection onto an image-frame-generating 2-D image point
1-13
1 Camera Calibration and SfM Examples
observation), IMU relative poses, and relative velocity change. You can categorize optimization based
on the type of factors used.
• Estimate the camera pose nodes at different timestamps, and connect them to both the camera
projection and the IMU factors.
• Connect the 3-D point landmark nodes to the camera projection factor.
• Connect the IMU velocity and bias nodes to only IMU factors.
Update the sliding window with the latest 3-D points and camera view pose.
newPointsTriangulated = false;
if ~isempty(newXYZ)
newPointsTriangulated = true;
% Store all new 3D-2D correspondenses.
for pIte = 1:length(newPointViews)
allCameraTracks{newPointViews(pIte)} = [allCameraTracks{newPointViews(pIte)}; new
end
obs = vertcat(allCameraTracks{:});
% Create camera projection factors with the latest
1-14
Monocular Visual-Inertial Odometry Using Factor Graph
Refine the estimated camera frame poses and 3-D points using factor graph optimization. The
optimization is time consuming. So, the optimization is not run after estimating the pose of each
frame. The frame frequency at which the optimization is run can be controlled using a parameter.
if helperDecideToRunGraphOptimization(curIdx,newPointsTriangulated,params)
% Recreate sliding window factor graph with only the latest key
% frames, for performance.
[slidingWindowFactorGraph,xyzIds] = helperRecreateSlidingWindowFactorGraph( ...
slidingWindowFactorGraph,fManager,allCameraTracks,data.intrinsics,cameraInformati
imuParams,data.gyroReadings,data.accelReadings,data.timeStamps,allFrameIds,ids,da
Update the feature manager and view set with your optimization results.
slidingWindowViewIds = getSlidingWindowIds(fManager);
if ~status.Mediandepth
status.Mediandepth = true;
xyz = slidingWindowFactorGraph.nodeState( ...
ids.point3(xyzIds));
medianDepth = median(vecnorm(xyz.'));
[posesUpdated,xyz] = helperTransformToNavigationFrame(helperUpdateCameraPoseTable
1-15
1 Camera Calibration and SfM Examples
slidingWindowFactorGraph.nodeState(ids.pose(slidingWindowViewIds))), ...
xyz,rigidtform3d,initialSceneMedianDepth/medianDepth);
% Set current camera pose node state guess.
slidingWindowFactorGraph.nodeState(ids.pose(slidingWindowViewIds), ...
helperCameraPoseTableToSE3Vector(posesUpdated));
% Add guess for newly triangulated 3-D points node states.
slidingWindowFactorGraph.nodeState( ...
ids.point3(xyzIds),xyz);
else
posesUpdated = helperUpdateCameraPoseTable(poses(vSet,slidingWindowViewIds), ...
slidingWindowFactorGraph.nodeState( ...
ids.pose(slidingWindowViewIds)));
end
Add a new feature point to the Kalman tracker, in case the number of points goes below the feature
tracking threshold.
createNewFeaturePoints(fManager,I);
currPoints = getKeyPointsInView(fManager,viewId);
setPoints(tracker,currPoints);
prevPrevI = prevI;
prevI = I;
1-16
Monocular Visual-Inertial Odometry Using Factor Graph
1-17
1 Camera Calibration and SfM Examples
Plot all key frame camera poses and 3-D points. Observe the landmarks on features such as the
ceiling, floor, and pillars.
helperPlotCameraPosesAndLandmarks(axMap,fManager,vSet,removedFrameIds);
1-18
Monocular Visual-Inertial Odometry Using Factor Graph
1-19
1 Camera Calibration and SfM Examples
• Absolute trajectory error (ATE) - Root Mean Squared Error (RMSE) between computed camera
locations and ground truth camera locations.
• Scale error - Percentage of how far the computed median scale is to original scale.
addedFrameIds = allFrameIds(vSet.Views.ViewId);
axf = axes(figure);
helperPlotAgainstGroundTruth(vSet,data.gTruth,data.camToIMUTransform, ...
addedFrameIds,axf,removedFrameIds);
1-20
Monocular Visual-Inertial Odometry Using Factor Graph
Evaluate the tracking accuracy, based on root mean square error (RMSE) and median scale error.
helperComputeErrorAgainstGroundTruth(data.gTruth,vSet,allFrameIds,removedFrameIds,data.camToIMUTr
Supporting Functions
This section details the short helper functions included in this example. Larger helper functions have
been included in separate files.
1-21
1 Camera Calibration and SfM Examples
helperVisualizeTrajectory updates trajectory plot with latest data stored in view set and
feature manager.
helperPlotAgainstGroundTruth plots estimated trajectory and ground truth trajectory for visual
comparison.
helperGenerateNodeID generates unique factor graph node IDs for fixed number of camera view
poses, IMU velocities, IMU biases, and 3-D point nodes.
helperUpdateCameraPoseTable updates pose table with latest estimated N-by-7 SE(3) poses.
cameraPoseTableUpdated = cameraPoseTable;
R = quat2rotm(cameraPoses(:,4:7));
for k = 1:size(cameraPoses,1)
cameraPoseTableUpdated.AbsolutePose(k).Translation = cameraPoses(k,1:3);
cameraPoseTableUpdated.AbsolutePose(k).R = R(:,:,k);
end
end
1-22
Monocular Visual-Inertial Odometry Using Factor Graph
% If the current frame belongs to the initial set of frames, then run graph
% optimization every frame, because the initial SfM is still running.
% Otherwise, after a number of frames specified by optimization frequency,
% run graph optimization. Lower frequency can result in a more accurate
% estimation, but can increase execution time.
numberOfInitialFrames = 250;
shouldOptimize = (curIdx < numberOfInitialFrames) || (mod(curIdx,params.optimizationFrequency) ==
end
helperTransformToNavigationFrame transforms and scales input poses and XYZ 3-D points to
local navigation reference frame of IMU using gravity rotation and pose scale.
posesUpdated = poses;
% Input gravity rotation transforms the gravity vector from local
% navigation reference frame to initial camera pose reference frame.
% The inverse of this transforms the poses from camera reference frame
% to local navigation reference frame.
Ai = gRot.A';
for k = 1:length(poses.AbsolutePose)
T = Ai*poses.AbsolutePose(k).A;
T(1:3,4) = poseScale*T(1:3,4);
posesUpdated.AbsolutePose(k) = rigidtform3d(T);
end
% Transform points from initial camera pose reference frame to
% local navigation reference frame of IMU.
xyzUpdated = poseScale*gRot.transformPointsInverse(xyz);
end
len = length(frameIds);
gyro = cell(1,len-1);
accel = cell(1,len-1);
for k = 2:len
% Assumes the IMU data is time-synchorized with the camera data. Compute
% indices of accelerometer readings between consecutive view IDs.
[~,ind1] = min(abs(timeStamps.imuTimeStamps - timeStamps.imageTimeStamps(frameIds(k-1))));
[~,ind2] = min(abs(timeStamps.imuTimeStamps - timeStamps.imageTimeStamps(frameIds(k))));
imuIndBetweenFrames = ind1:(ind2-1);
% Extract the data at the computed indices and store in a cell.
gyro{k-1} = gyroReadings(imuIndBetweenFrames,:);
accel{k-1} = accelReadings(imuIndBetweenFrames,:);
end
end
1-23
1 Camera Calibration and SfM Examples
function helperPlotCameraPosesAndLandmarks(axisHandle,fManager,vSet,removedFrameIds,plotCams)
% helperPlotCameraPosesAndLandmarks plots the key frame camera poses and
% triangulated 3-D point landmarks.
if nargin < 5
% By deafult plot trajectory as a line plot. If plotCams is true the
% function uses the plotCamera utility to draw trajectory.
plotCams = false;
end
pcshow(xyzPoints(indToPlot,:),Parent=axisHandle,Projection="orthographic");
hold(axisHandle,"on")
if plotCams
c = table(camPoses.AbsolutePose,VariableNames={'AbsolutePose'});
plotCamera(c,Parent=axisHandle,Size=0.25);
title(axisHandle,"Initial Structure from Motion")
else
traj = vertcat(camPoses.AbsolutePose.Translation);
plot3(traj(:,1),traj(:,2),traj(:,3),"r-",Parent=axisHandle);
view(axisHandle,27.28,-2.81)
title(axisHandle,"Estimated Trajectory and Landmarks")
end
hold off
drawnow
end
1-24
Monocular Visual-Inertial Odometry Using Factor Graph
gLocations = gl(allFrameIds(vId(kfInd)),1:3);
scale = median(vecnorm(gLocations,2,2))/median(vecnorm(locations,2,2));
helperDownloadData downloads data set from specified URL to specified output folder.
vioDataTarFile = matlab.internal.examples.downloadSupportFile(...
'shared_nav_vision/data','BlackbirdVIOData.tar');
vioData = load(fullfile(outputFolder,"BlackbirdVIOData","data.mat"));
end
References
[1] Qin, Tong, Peiliang Li, and Shaojie Shen. “VINS-Mono: A Robust and Versatile Monocular Visual-
Inertial State Estimator.” IEEE Transactions on Robotics 34, no. 4 (August 2018): 1004–20. https://
doi.org/10.1109/TRO.2018.2853729
[2] Antonini, Amado, Winter Guerra, Varun Murali, Thomas Sayre-McCord, and Sertac Karaman. “The
Blackbird Dataset: A Large-Scale Dataset for UAV Perception in Aggressive Flight.” In Proceedings of
the 2018 International Symposium on Experimental Robotics, edited by Jing Xiao, Torsten Kröger, and
Oussama Khatib, 11:130–39. Cham: Springer International Publishing, 2020. https://doi.org/
10.1007/978-3-030-33950-0_12
1-25
1 Camera Calibration and SfM Examples
Visual simultaneous localization and mapping (vSLAM), refers to the process of calculating the
position and orientation of a camera with respect to its surroundings, while simultaneously mapping
the environment.
You can perform vSLAM using a monocular camera. However, the depth cannot be accurately
calculated, and the estimated trajectory is unknown and drifts over time. To produce an initial map,
which cannot be triangulated from the first frame, you must use multiple views of a monocular
camera. A better, more reliable solution is to use an RGB-D camera, which is composed of one RGB
color image and one depth image.
This example shows how to process RGB-D image data to build a map of an indoor environment and
estimate the trajectory of the camera. The example uses a version of the ORB-SLAM2 [1] algorithm,
which is feature-based and supports RGB-D cameras.
The pipeline for RGB-D vSLAM is very similar to the monocular vSLAM pipeline in the “Monocular
Visual Simultaneous Localization and Mapping” on page 1-95 example. The major difference is that
in the Map Initialization stage, the 3-D map points are created from a pair of images consisting of
one color image and one depth image instead of two frames of color images.
• Map Initialization: The initial 3-D world points can be constructed by extracting ORB feature
points from the color image and then computing their 3-D world locations from the depth image.
The color image is stored as the first key frame.
• Tracking: Once a map is initialized, the pose of the camera is estimated for each new RGB-D
image by matching features in the color image to features in the last key frame.
• Local Mapping: If the current color image is identified as a key frame, new 3-D map points are
computed from the depth image. At this stage, bundle adjustment is used to minimize reprojection
errors by adjusting the camera pose and 3-D points.
• Loop Closure: Loops are detected for each key frame by comparing it against all previous key
frames using the bag-of-features approach. Once a loop closure is detected, the pose graph is
optimized to refine the camera poses of all the key frames.
1-26
Random documents with unrelated
content Scribd suggests to you:
made of the exhaustive notes on Yahwe (pp. 243 ff.) and the Ashera (pp.
196 ff.), and the valuable section> on early Hebrew poetry.
[49] Ovid, Fasti, IV., 679 ff.; and cf. Frazer, "Spirits of the Corn," I., p. 297
f.
[50] See Burney, op. cit., additional note on "The mythical element in the
story of Samson."
[51] See "Das Gilgamesch-Epos in der Weltliteratur" (Strassburg, 1906).
[52] "Studien zur Odyssée" in the "Mitteilungen der Vorderasiatischen
Gesellschaft," 1910, Hefte 2-4; 1911, Heft 4.
[53] The fifty-two noble youths, for example, whom Alcinous entrusts with
the task of preparing the ship and escorting Odysseus homewards may
correspond to the fifty-two weeks of the year, sun-heroes who accompany
the sun on his voyage through the year. In the challenge of Euryalus to
Odysseus and the latter's triumph in the discus-throwing, we are to see a
glimmer of the old light-myth. The dance of Halius and Laodamas, with the
purple ball which Polybus made for them, again symbolizes the battle of
light, the colour of the ball being specially significant. Indeed, there are
few limits to be placed to this system of astrological interpretation, since,
according to Dr. Fries, even lawn-tennis goes back to the same idea: he
remarks that "ailes Ballspiel ja bis herab zum Lawn-Tennis auf denselben
Gedanken [der Lichtkampf] zurückgeht" ("Studien zur Odyssée," i., p.
324).
[54] One point, at which the colouring is said to be peculiarly Babylonian,
is the prophecy that death shall come to Odysseus from the sea; for this is
traced to the Babylonian legend of Oannes, the benefactor of mankind,
who ever returns to the sea from which he rose, but here, too, Odysseus is
the god of heaven who sinks at the approach of night.
[55] With regard to its application to the Hebrew narratives, the "Church
Quarterly" reviewer of Dr. Jeremias' work (see above, p. 304, n. 1**)
points out the resemblance between this procedure and Philo's method of
interpretation.
[56] In 1870 the same plan was adopted to discredit Professor Max
Müller's theory of the Solar Myth. The demonstration, though humorous
(since its subject was the professor himself), constituted a legitimate form
of criticism, and it has been borrowed by Dr. Kugler, the Dutch astronomer,
and applied to the astral theory. For the astral theory is in essence the old
Solar Myth revived and grafted on to a Babylonian stem. In his book "Im
Bannkreis Babels" (1910), Dr. Kugler selects at random the historical figure
of Louis IX. of France, and has no difficulty in demonstrating by astral
methods that the extant records of his life and reign are full of solar and
astral motifs.
[57] Cf. Kugler, op. cit.
[58] His interpretation of Euripides' story of the Golden Lamb must share
the fate of the main structure of his theory, but the legend itself may well
have been of Babylonian origin (see above, p. 293).
[59] See above, pp. 106 ff.
[60] For an exhaustive discussion or the astrological material contained in
the omen-literature, see Jastrow, "Religion Babyloniens und Assyriens," II.,
pp. 138 ff. (1909-12). A Neo-Babylonian astronomical treatise, recently
acquired by the British Museum (see Plate XXXII., opposite p. 310),
containing classified and descriptive lists of the principal stars and
constellations, with their heliacal risings and settings, culminations in the
south, etc., does not surest a profound knowledge of astronomy on the
part of its compiler (cf. King, "Cun. Texts," XXXIII., 1912, pp. 30 ff., and
"Proc. Soc. Bibl. Arch.," XXXV., 1913, pp. 41 ff.).
[61] See "Sternkunde und Sterndienst," II., pp. 30 ff.; cf. also Cumont,
"Babylon und der griechische Astrologie," in the "Neue Jahrbücher für das
klassische Altertum," Bd. 27 (1911), pp. Off., and the earlier of his
"American Lectures on the History of Religions," published under the title
"Astrology and Religion among the Greeks and Romans" (1912).
[62] See above, p. 208 f.
[63] They are emphasized by Schiarparelli, in his "Astronomy in the Old
Testament" (Engl. transl.), pp. 39 ff., 99 ff., 104 f.
[64] During their pastoral and agricultural life in Palestine the Hebrews
found it quite sufficient to refer to time by describing the period of the day:
see further, Schiarparelli, op. cit., p. 96.
[65] Amos, v., 20.
[66] Cf. "Greece and Babylon" (published as the Wilde Lectures, 1911).
[67] See his "Cults of the Creek States," Oxford, 1896-1909.
[68] Cf. Hogarth, "Ionia and the East," pp. 27 ff., 64 ff.
APPENDICES
HADES, 308
Hagen, O. E., 283
Hakluyt, Richard, 15
Halius, 309
Hall, H. P., 111, 126, 160, 219, 235, 277
Halys, 5, 229, 279
Hammam, in Syria, 127
Hammurabi, king of First Dynasty,
89 f., 99 ff., 103, 128, 130, 153 ff,
156 f., 290: character of, 100 f.;
empire of, 158 f.; Babylon of, 20,
84 ff.; palace of, 86; Code of, 154,
158 f., 161 ff., 252; letters of, 181,
188 ff.; date of, 94, 110 f.; period
of, 39, 162 ff., 315; in Lists, 319 f.
Hammurabi-khegallum Canal, 155
Hammurabi-nukhush-nishi Canal, 158
Hammurabih, king of Khana, 130
Hananiah, 14
Handcock, P. S. P., 120
Hanging Gardens, of Babylon, 40 ff., 279
Harbour, of Babylon, 30
Harp, Sumerian, 298
Harran, 270, 282
Harûn-ar-Rashîd, 11
Hastings, Dr. James, 102
Haverfield, Prof. F. J., 22
Hebrew religion, 12; traditions. 159; law, 299
Hebrews, altars of, 62: and Babylonian mythology, 280
Helios, 307
Hera, 290
Heracles, 290
Herds, tribute of, 108
Herdsmen, Babylonian, 108 f.
Herodotus. 4 f., 15, 21 f., 24, 20 f.,
38, 61 f., 72, 76 f., 81, 85, 167, 177,
179, 270, 279
Hesiod, 302
Heuzey, Léon. 298 f.
Hezekiah, king of Judah, 270
High places, Canaanite, 126
Hilla, 14, 23
Hilprecht, Prof. II. V., 91 f., 112,
134, 150, 208, 212, 242
Himyarite period, 121
Hincke, Prof. W. J., 246, 250
Hindîya Canal, 16
Hipparchus, of Nicæa, 312
Hire of land, system of, 167
Hit, 174
Hittite correspondence, character of, 239 f.;
invasion, 3, 84, 210;
states, 230; migration, 128
Hittite Empire, rise of, 220;
history of, 229 ff.; fall of, 241;
communications of, 5; as barrier, 314
Hittites, 3, 128, 234 ff., 243;
racial character of, 226 f.;
civilization of, 227 f.;
art of, 228, 233;
inscriptions and records of, 226 ff.
Hogarth, D. G., 4 f., 120, 128, 276, 278, 282, 314;
Carchemish excavations of, 127
Homer, see Odyssey
Homera, mound of, 29, 31, 35; in plan, 23
Horse, introduction of, 122, 198, 215 f.
Horses, export of, 224
House-property, in Babylon, 84
Houses, Babylonian, 184
How, Walter W., 5, 7, 21
Hrozný, F., 97 f., 150
Huber, E., 134
Humped cattle, 175, 202
Huntington, Ellsworth, 121
Hydra, constellation, 292
Hydraulic machine, 48
Hyksos, in Egypt, 132 f.
ebookbell.com