100% found this document useful (3 votes)
43 views

PDF MATLAB Computer Vision Toolbox User S Guide The Mathworks Download

User

Uploaded by

dobijaaeris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
43 views

PDF MATLAB Computer Vision Toolbox User S Guide The Mathworks Download

User

Uploaded by

dobijaaeris
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Download the full version of the textbook now at textbookfull.

com

MATLAB Computer Vision Toolbox User s Guide


The Mathworks

https://textbookfull.com/product/matlab-computer-
vision-toolbox-user-s-guide-the-mathworks/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

MATLAB Econometrics Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-econometrics-toolbox-user-s-
guide-the-mathworks/

textbookfull.com

MATLAB Bioinformatics Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-bioinformatics-toolbox-user-s-
guide-the-mathworks/

textbookfull.com

MATLAB Mapping Toolbox User s Guide The Mathworks

https://textbookfull.com/product/matlab-mapping-toolbox-user-s-guide-
the-mathworks/

textbookfull.com

Geosynthetic Encased Columns for Soft Soil Improvement


Marcio Almeida

https://textbookfull.com/product/geosynthetic-encased-columns-for-
soft-soil-improvement-marcio-almeida/

textbookfull.com
Shadow Princess (Zodiac Academy #4) 1st Edition Caroline
Peckham

https://textbookfull.com/product/shadow-princess-zodiac-academy-4-1st-
edition-caroline-peckham/

textbookfull.com

Wong s Essentials of Pediatric Nursing Marilyn J.


Hockenberry

https://textbookfull.com/product/wong-s-essentials-of-pediatric-
nursing-marilyn-j-hockenberry/

textbookfull.com

Essential of Oral Biology oral anatomy histology


physiology embryology 2nd Edition Maji Jose

https://textbookfull.com/product/essential-of-oral-biology-oral-
anatomy-histology-physiology-embryology-2nd-edition-maji-jose/

textbookfull.com

LifeOS Exploring The System That Executes DNA 1st Edition


Jim Cranford

https://textbookfull.com/product/lifeos-exploring-the-system-that-
executes-dna-1st-edition-jim-cranford/

textbookfull.com

Heinemann Chemistry 1 Chris Commons

https://textbookfull.com/product/heinemann-chemistry-1-chris-commons/

textbookfull.com
Young Stalin 6th Edition Simon Sebag Montefiore

https://textbookfull.com/product/young-stalin-6th-edition-simon-sebag-
montefiore/

textbookfull.com
Computer Vision Toolbox™
User's Guide

R2020a
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
Computer Vision Toolbox™ User's Guide
© COPYRIGHT 2004–2020 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied
only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form
without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through
the federal government of the United States. By accepting delivery of the Program or Documentation, the government
hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer
software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014.
Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain
to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government) and shall
supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is
inconsistent in any respect with federal procurement law, the government agrees to return the Program and
Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for
more information.
Revision History
July 2004 First printing New for Version 1.0 (Release 14)
October 2004 Second printing Revised for Version 1.0.1 (Release 14SP1)
March 2005 Online only Revised for Version 1.1 (Release 14SP2)
September 2005 Online only Revised for Version 1.2 (Release 14SP3)
November 2005 Online only Revised for Version 2.0 (Release 14SP3+)
March 2006 Online only Revised for Version 2.1 (Release 2006a)
September 2006 Online only Revised for Version 2.2 (Release 2006b)
March 2007 Online only Revised for Version 2.3 (Release 2007a)
September 2007 Online only Revised for Version 2.4 (Release 2007b)
March 2008 Online only Revised for Version 2.5 (Release 2008a)
October 2008 Online only Revised for Version 2.6 (Release 2008b)
March 2009 Online only Revised for Version 2.7 (Release 2009a)
September 2009 Online only Revised for Version 2.8 (Release 2009b)
March 2010 Online only Revised for Version 3.0 (Release 2010a)
September 2010 Online only Revised for Version 3.1 (Release 2010b)
April 2011 Online only Revised for Version 4.0 (Release 2011a)
September 2011 Online only Revised for Version 4.1 (Release 2011b)
March 2012 Online only Revised for Version 5.0 (Release 2012a)
September 2012 Online only Revised for Version 5.1 (Release R2012b)
March 2013 Online only Revised for Version 5.2 (Release R2013a)
September 2013 Online only Revised for Version 5.3 (Release R2013b)
March 2014 Online only Revised for Version 6.0 (Release R2014a)
October 2014 Online only Revised for Version 6.1 (Release R2014b)
March 2015 Online only Revised for Version 6.2 (Release R2015a)
September 2015 Online only Revised for Version 7.0 (Release R2015b)
March 2016 Online only Revised for Version 7.1 (Release R2016a)
September 2016 Online only Revised for Version 7.2 (Release R2016b)
March 2017 Online only Revised for Version 7.3 (Release R2017a)
September 2017 Online only Revised for Version 8.0 (Release R2017b)
March 2018 Online only Revised for Version 8.1 (Release R2018a)
September 2018 Online only Revised for Version 8.2 (Release R2018b)
March 2019 Online only Revised for Version 9.0 (Release R2019a)
September 2019 Online only Revised for Version 9.1 (Release R2019b)
March 2020 Online only Revised for Version 9.2 (Release R2020a)
Contents

Featured Examples
1
Localize and Read Multiple Barcodes in Image . . . . . . . . . . . . . . . . . . . . . 1-2

Monocular Visual Odometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22

Track Vehicles Using Lidar: From Point Cloud to Track List . . . . . . . . . . 1-35

Semantic Segmentation Using Dilated Convolutions . . . . . . . . . . . . . . . . 1-55

Define Custom Pixel Classification Layer with Tversky Loss . . . . . . . . . . 1-59

Track a Face in Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66

Create 3-D Stereo Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-71

Measure Distance from Stereo Camera to a Face . . . . . . . . . . . . . . . . . . . 1-72

Reconstruct 3-D Scene from Disparity Map . . . . . . . . . . . . . . . . . . . . . . . 1-74

Visualize Stereo Pair of Camera Extrinsic Parameters . . . . . . . . . . . . . . . 1-77

Remove Distortion from an Image Using the Camera Parameters Object


......................................................... 1-80

Point Cloud Processing


2
Getting Started with Point Clouds Using Deep Learning . . . . . . . . . . . . . . 2-2
Import Point Cloud Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Augment Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Encode Point Cloud Data to Image-like Format . . . . . . . . . . . . . . . . . . . . . 2-3
Train a Deep Learning Classification Network with Encoded Point Cloud
Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

Point Cloud Registration Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4


Point Cloud Registration Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Point Cloud Registration Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6

The PLY Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8


File Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

v
Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
Common Elements and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10

Using the Installer for Computer Vision System Toolbox


Product
3
Install Computer Vision Toolbox Add-on Support Files . . . . . . . . . . . . . . . 3-2

Install OCR Language Data Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3


Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Pretrained Language Data and the ocr function . . . . . . . . . . . . . . . . . . . . 3-3

Install and Use Computer Vision Toolbox OpenCV Interface . . . . . . . . . . . 3-6


Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Support Package Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Create MEX-File from OpenCV C++ file . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Use the OpenCV Interface C++ API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Create Your Own OpenCV MEX-files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Run OpenCV Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8

Install and Use Computer Vision Toolbox OpenCV Interface for Simulink
......................................................... 3-10
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Import OpenCV Code into Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18

Smile Detection by Using OpenCV Code in Simulink . . . . . . . . . . . . . . . . 3-19


Required Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Set Up Your C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Step 1: Import OpenCV Function to Create a Simulink Library . . . . . . . . 3-20
Step 2: Use Generated Subsystem in Simulink Model . . . . . . . . . . . . . . . 3-25
Step 3: Simulate the Smile Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Step 4: Generate C++ Code from the Smile Detector Model . . . . . . . . . . 3-26
Deploy the Smile Detector on the Raspberry Pi Hardware . . . . . . . . . . . . 3-27

Convert RGB Image to Grayscale Image by Using OpenCV Importer . . . 3-29


Required Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Set Up Your C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-29
Step 1: Import OpenCV Function to Create a Simulink Library . . . . . . . . 3-30
Step 2: Use Generated Subsystem in Simulink Model . . . . . . . . . . . . . . . 3-33
Step 3: Simulate the RGB to Gray Convertor . . . . . . . . . . . . . . . . . . . . . . 3-34

Draw Different Shapes by Using OpenCV Code in Simulink . . . . . . . . . . 3-36


Required Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Set Up Your C++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Model Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Step 1: Import OpenCV Function to Create a Simulink Library . . . . . . . . 3-37
Step 2: Use Generated Subsystem in Simulink Model . . . . . . . . . . . . . . . 3-38
Draw Atom on Image by Using C Caller Block . . . . . . . . . . . . . . . . . . . . . 3-38

vi Contents
Input, Output, and Conversions
4
Export to Video Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Setting Block Parameters for this Example . . . . . . . . . . . . . . . . . . . . . . . . 4-2
Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

Import from Video Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4


Setting Block Parameters for this Example . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5

Batch Process Image Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6


Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6

Convert R'G'B' to Intensity Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7

Process Multidimensional Color Video Signals . . . . . . . . . . . . . . . . . . . . . 4-10

Video Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12


Defining Intensity and Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Video Data Stored in Column-Major Format . . . . . . . . . . . . . . . . . . . . . . 4-12

Image Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13


Binary Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
Intensity Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
RGB Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

Display and Graphics


5
Display, Stream, and Preview Videos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
View Streaming Video in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Preview Video in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
View Video in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Draw Shapes and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4


Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Line and Polyline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6
Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6

Registration and Stereo Vision


6
Fisheye Calibration Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Fisheye Camera Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Fisheye Camera Calibration in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

vii
Single Camera Calibrator App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Camera Calibrator Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Single Camera Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Open the Camera Calibrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Prepare the Pattern, Camera, and Images . . . . . . . . . . . . . . . . . . . . . . . . . 6-9
Add Images and Select Camera Model . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
Calibrate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-15
Evaluate Calibration Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17
Improve Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20
Export Camera Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23

Stereo Camera Calibrator App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25


Stereo Camera Calibrator Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25
Stereo Camera Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25
Open the Stereo Camera Calibrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26
Prepare Pattern, Camera, and Images . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26
Add Image Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29
Calibrate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31
Evaluate Calibration Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-31
Improve Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-35
Export Camera Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-37

What Is Camera Calibration? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39


Camera Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-39
Pinhole Camera Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-40
Camera Calibration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-41
Distortion in Camera Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-42

Structure from Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45


Structure from Motion from Two Views . . . . . . . . . . . . . . . . . . . . . . . . . 6-45
Structure from Motion from Multiple Views . . . . . . . . . . . . . . . . . . . . . . 6-46

Object Detection
7
Getting Started with SSD Multibox Detection . . . . . . . . . . . . . . . . . . . . . . 7-2
Predict Objects in the Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Design an SSD Detection Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Train an Object Detector and Detect Objects with an SSD Model . . . . . . . 7-4
Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Label Training Data for Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4

Getting Started with Object Detection Using Deep Learning . . . . . . . . . . 7-6


Create Training Data for Object Detection . . . . . . . . . . . . . . . . . . . . . . . . 7-6
Create Object Detection Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
Train Detector and Evaluate Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
Detect Objects Using Deep Learning Detectors . . . . . . . . . . . . . . . . . . . . . 7-7

How Labeler Apps Store Exported Pixel Labels . . . . . . . . . . . . . . . . . . . . . 7-9


Location of Pixel Label Data Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9
View Exported Pixel Label Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

viii Contents
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

Anchor Boxes for Object Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14


What Is an Anchor Box? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
Advantage of Using Anchor Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-14
How Do Anchor Boxes Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15
Anchor Box Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18

Getting Started with YOLO v2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19


Predicting Objects in the Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19
Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
Design a YOLO v2 Detection Network . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-20
Train an Object Detector and Detect Objects with a YOLO v2 Model . . . . 7-21
Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21
Label Training Data for Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21

Getting Started with R-CNN, Fast R-CNN, and Faster R-CNN . . . . . . . . . 7-23
Object Detection Using R-CNN Algorithms . . . . . . . . . . . . . . . . . . . . . . . 7-23
Comparison of R-CNN Object Detectors . . . . . . . . . . . . . . . . . . . . . . . . . 7-24
Transfer Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-25
Design an R-CNN, Fast R-CNN, and a Faster R-CNN Model . . . . . . . . . . . 7-25
Label Training Data for Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . 7-27

Getting Started with Semantic Segmentation Using Deep Learning . . . 7-29


Train a Semantic Segmentation Network . . . . . . . . . . . . . . . . . . . . . . . . 7-29
Label Training Data for Semantic Segmentation . . . . . . . . . . . . . . . . . . . 7-29

Training Data for Object Detection and Semantic Segmentation . . . . . . 7-31

Create Automation Algorithm for Labeling . . . . . . . . . . . . . . . . . . . . . . . . 7-35


Create New Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-35
Import Existing Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-36
Custom Algorithm Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-36

Label Pixels for Semantic Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39


Start Pixel Labeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-39
Label Pixels Using Flood Fill Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-40
Label Pixels Using Smart Polygon Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 7-41
Label Pixels Using Polygon Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-43
Label Pixels Using Assisted Freehand Tool . . . . . . . . . . . . . . . . . . . . . . . 7-44
Replace Pixel Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-45
Refine Labels Using Brush Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-45
Visualize Pixel Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-46
Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-47

Get Started with the Image Labeler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49


Load Unlabeled Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49
Create Label Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-49
Label Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-56
Export Labeled Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-58
Save App Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-60

Choose an App to Label Ground Truth Data . . . . . . . . . . . . . . . . . . . . . . . 7-62

ix
Get Started with the Video Labeler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-64
Load Unlabeled Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-64
Set Time Interval to Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-64
Create Label Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-65
Label Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-72
Export Labeled Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-74
Label Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-76
Save App Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-77

Use Custom Image Source Reader for Labeling . . . . . . . . . . . . . . . . . . . . 7-79


Create Custom Reader Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-79
Import Data Source into Video Labeler App . . . . . . . . . . . . . . . . . . . . . . 7-79
Import Data Source into Ground Truth Labeler App . . . . . . . . . . . . . . . . 7-80

Use Sublabels and Attributes to Label Ground Truth Data . . . . . . . . . . . 7-81


When to Use Sublabels vs. Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-81
Draw Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-81
Copy and Paste Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-82
Delete Sublabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-83
Sublabel Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-84

Temporal Automation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-85


Create Temporal Automation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 7-85
Run Temporal Automation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-85

View Summary of Ground Truth Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-87


View Label Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-87
Compare Selected Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-89

Share and Store Labeled Ground Truth Data . . . . . . . . . . . . . . . . . . . . . . 7-91


Share Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-91
Move Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-94
Store Ground Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-95

Keyboard Shortcuts and Mouse Actions for Image Labeler . . . . . . . . . . . 7-97


Label Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-97
Image Browsing and Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-97
Labeling Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-97
Polyline Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-98
Polygon Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-98
Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-99
App Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-99

Keyboard Shortcuts and Mouse Actions for Video Labeler . . . . . . . . . . 7-100


Label Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-100
Frame Navigation and Time Interval Settings . . . . . . . . . . . . . . . . . . . . 7-100
Labeling Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-100
Polyline Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-101
Polygon Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-101
Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-102
App Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-102

Point Feature Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-103


Functions That Return Points Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 7-103
Functions That Accept Points Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 7-105

x Contents
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Local Feature Detection and Extraction . . . . . . . . . . . . . . . . . . . . . . . . . 7-109
What Are Local Features? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-109
Benefits and Applications of Local Features . . . . . . . . . . . . . . . . . . . . . 7-109
What Makes a Good Local Feature? . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-110
Feature Detection and Feature Extraction . . . . . . . . . . . . . . . . . . . . . . 7-110
Choose a Feature Detector and Descriptor . . . . . . . . . . . . . . . . . . . . . . 7-111
Use Local Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-112
Image Registration Using Multiple Features . . . . . . . . . . . . . . . . . . . . . 7-114

Train a Cascade Object Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-122


Why Train a Detector? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-122
What Kinds of Objects Can You Detect? . . . . . . . . . . . . . . . . . . . . . . . . 7-122
How Does the Cascade Classifier Work? . . . . . . . . . . . . . . . . . . . . . . . . 7-122
Create a Cascade Classifier Using the trainCascadeObjectDetector . . . 7-123
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-126
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-128
Train Stop Sign Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-132

Train Optical Character Recognition for Custom Fonts . . . . . . . . . . . . . 7-135


Open the OCR Trainer App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-135
Train OCR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-135
App Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-137

Troubleshoot ocr Function Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-139


Performance Options with the ocr Function . . . . . . . . . . . . . . . . . . . . . 7-139

Create a Custom Feature Extractor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-140


Example of a Custom Feature Extractor . . . . . . . . . . . . . . . . . . . . . . . . 7-140

Image Retrieval with Bag of Visual Words . . . . . . . . . . . . . . . . . . . . . . . 7-143


Retrieval System Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-144
Evaluate Image Retrieval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-145

Image Classification with Bag of Visual Words . . . . . . . . . . . . . . . . . . . . 7-146


Step 1: Set Up Image Category Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-146
Step 2: Create Bag of Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-146
Step 3: Train an Image Classifier With Bag of Visual Words . . . . . . . . . 7-147
Step 4: Classify an Image or Image Set . . . . . . . . . . . . . . . . . . . . . . . . . 7-148

Motion Estimation and Tracking


8
Multiple Object Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Prediction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Data Association . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Track Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4

Video Mosaicking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5

Pattern Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10

xi
Pattern Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15

Geometric Transformations
9
Nearest Neighbor, Bilinear, and Bicubic Interpolation Methods . . . . . . . 9-2
Nearest Neighbor Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Bilinear Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Bicubic Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3

Filters, Transforms, and Enhancements


10
Adjust the Contrast of Intensity Images . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2

Adjust the Contrast of Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-6

Remove Salt and Pepper Noise from Images . . . . . . . . . . . . . . . . . . . . . 10-10

Sharpen an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-14

Statistics and Morphological Operations


11
Correct Nonuniform Illumination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2

Count Objects in an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8

Fixed-Point Design
12
Fixed-Point Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Fixed-Point Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Benefits of Fixed-Point Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2
Benefits of Fixed-Point Design with System Toolboxes Software . . . . . . . 12-2

Fixed-Point Concepts and Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4


Fixed-Point Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4
Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
Precision and Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6

xii Contents
Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8
Modulo Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8
Two's Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8
Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9
Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-10
Casts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-12

Fixed-Point Support for MATLAB System Objects . . . . . . . . . . . . . . . . . 12-15


Getting Information About Fixed-Point System Objects . . . . . . . . . . . . . 12-15
Setting System Object Fixed-Point Properties . . . . . . . . . . . . . . . . . . . . 12-15

Specify Fixed-Point Attributes for Blocks . . . . . . . . . . . . . . . . . . . . . . . . 12-17


Fixed-Point Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-17
Specify System-Level Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-19
Inherit via Internal Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-19
Specify Data Types for Fixed-Point Blocks . . . . . . . . . . . . . . . . . . . . . . . 12-26

Code Generation and Shared Library


13
Simulink Shared Library Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2

Accelerating Simulink Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3

Portable C Code Generation for Functions That Use OpenCV Library . . 13-4
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-4

xiii
1

Featured Examples

• “Localize and Read Multiple Barcodes in Image” on page 1-2


• “Monocular Visual Odometry” on page 1-22
• “Track Vehicles Using Lidar: From Point Cloud to Track List” on page 1-35
• “Semantic Segmentation Using Dilated Convolutions” on page 1-55
• “Define Custom Pixel Classification Layer with Tversky Loss” on page 1-59
• “Track a Face in Scene” on page 1-66
• “Create 3-D Stereo Display” on page 1-71
• “Measure Distance from Stereo Camera to a Face” on page 1-72
• “Reconstruct 3-D Scene from Disparity Map” on page 1-74
• “Visualize Stereo Pair of Camera Extrinsic Parameters” on page 1-77
• “Remove Distortion from an Image Using the Camera Parameters Object” on page 1-80
1 Featured Examples

Localize and Read Multiple Barcodes in Image


This example shows how to use the readBarcode function from the Computer Vision Toolbox™ to
detect and decode 1-D and 2-D barcodes in an image. Barcodes are widely used to encode data in a
visual, machine-readable format. They are useful in many applications such as item identification,
warehouse inventory tracking, and compliance tracking. For 1-D barcodes, the readBarcode
function returns the location of the barcode endpoints. For 2-D barcodes, the function returns the
locations of the finder patterns. This example uses two approaches for localizing multiple barcodes in
an image. One approach is clustering-based, which is more robust to different imaging conditions and
requires the Statistics and Machine Learning Toolbox™. The second approach uses a segmentation-
based workflow and might require parameter tuning based on the imaging conditions.

Barcode Detection using the readBarcode Function

Read a QR code from an image.

I = imread("barcodeQR.jpg");

% Search the image for a QR Code.


[msg, ~, loc] = readBarcode(I);

% Annotate the image with the decoded message.


xyText = loc(2,:);
Imsg = insertText(I, xyText, msg, "BoxOpacity", 1, "FontSize", 25);

% Insert filled circles at the finder pattern locations.


Imsg = insertShape(Imsg, "FilledCircle", [loc, ...
repmat(10, length(loc), 1)], "Color", "red", "Opacity", 1);

% Display image.
imshow(Imsg)

1-2
Localize and Read Multiple Barcodes in Image

Read a 1-D barcode from an image.

I = imread("barcode1D.jpg");

% Read the 1-D barcode and determine the format..


[msg, format, locs] = readBarcode(I);

% Display the detected message and format.


disp("Detected format and message: " + format + ", " + msg)

Detected format and message: EAN-13, 1234567890128

% Insert a line to show the scan row of the barcode.


xyBegin = locs(1,:); imSize = size(I);
I = insertShape(I,"Line",[1 xyBegin(2) imSize(2) xyBegin(2)], ...
"LineWidth", 7);

% Insert markers at the end locations of the barcode.


I = insertShape(I, "FilledCircle", [locs, ...
repmat(10, length(locs), 1)], "Color", "red", "Opacity", 1);

1-3
1 Featured Examples

% Display image.
imshow(I)

Improving Barcode Detection

For a successful detection, the barcode must be clearly visible. The barcode must also be as closely
aligned to a horizontal or vertical position as possible. The readBarcode function is inherently more
robust to rotations for 2-D or matrix codes than it is to 1-D or linear barcodes. For example, the
barcode cannot be detected in this image.

I = imread("rotated1DBarcode.jpg");

% Display the image.


imshow(I)

1-4
Localize and Read Multiple Barcodes in Image

% Pass the image to the readBarcode function.


readBarcode(I)

ans =
""

Rotate the image using the imrotate so that the barcode is roughly horizontal. Use readBarcode
on the rotated image.

% Rotate the image by 30 degrees clockwise.


Irot = imrotate(I, -30);

% Display the rotated image.


imshow(Irot)

1-5
1 Featured Examples

% Pass the rotated image to the readBarcode function.


readBarcode(Irot)

ans =
"012345678905"

Detect Multiple Barcodes

The readBarcode function detects only a single barcode in each image. In order to detect multiple
barcodes, you must specify a region-of-interest (ROI). To specify an ROI, you can use the
drawrectangle function to interactively determine the ROIs. You can also use image analysis
techniques to detect the ROI of multiple barcodes in the image.

1-6
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Localize and Read Multiple Barcodes in Image

Interactively determine ROIs

I = imread("multiple1DBarcodes.jpg");

1-7
1 Featured Examples

Use the drawrectangle function to draw and obtain rectangle parameters.

roi1 = drawrectangle;

pos = roi1.Position;

% ROIs obtained using drawrectangle


roi = [350 190 690 370
350 640 690 360
350 1090 690 340];

imSize = size(I);
for i = 1:size(roi,1)
[msg, format, locs] = readBarcode(I, roi(i,:));
disp("Decoded format and message: " + format + ", " + msg)

% Insert a line to indicate the scan row of the barcode.


xyBegin = locs(1,:);
I = insertShape(I,"Line",[1 xyBegin(2) imSize(2) xyBegin(2)], ...
"LineWidth", 7);

% Annotate image with decoded message.


I = insertText(I, xyBegin, msg, "BoxOpacity", 1, "FontSize", 30);
end

Decoded format and message: UPC-A, 012345678905


Decoded format and message: EAN-13, 4567891324562
Decoded format and message: CODE-39, ABC-123

imshow(I)

1-8
Localize and Read Multiple Barcodes in Image

Image analysis to determine ROIs

Use image analysis techniques to automate the detection of multiple barcodes. This requires
localizing multiple barcodes in an image, determining their orientation, and correcting for the
orientation. Without preprocessing, barcodes cannot be detected in the image containing multiple
rotated barcodes.

1-9
1 Featured Examples

I = imread("multiple1DBarcodesRotated.jpg");
Igray = rgb2gray(I);

% Display the image.


imshow(I)

% Pass the unprocessed image to the readBarcode function.


readBarcode(Igray, '1D')

ans =
""

Detection on the unprocessed image resulted in no detection.

Step 1: Detect candidate regions for the barcodes using MSER

Detect regions of interest in the image using the detectMSERFeatures function. Then, you can
eliminate regions of interest based on a specific criteria such as the aspect ratio. You can use the
binary image from the filtered results for further processing.

1-10
Localize and Read Multiple Barcodes in Image

% Detect MSER features.


[~, cc] = detectMSERFeatures(Igray);

% Compute region properties MajorAxisLength and MinorAxisLength.


regionStatistics = regionprops(cc, 'MajorAxisLength', 'MinorAxisLength');

% Filter out components that have a low aspect ratio as unsuitable


% candidates for the bars in the barcode.
minAspectRatio = 10;
candidateRegions = find(([regionStatistics.MajorAxisLength]./[regionStatistics.MinorAxisLength])

% Binary image to store the filtered components.


BW = false(size(Igray));

% Update the binary image.


for i = 1:length(candidateRegions)
BW(cc.PixelIdxList{candidateRegions(i)}) = true;
end

% Display the binary image with the filtered components.


imshow(BW)
title("Candidate regions for the barcodes")

1-11
Random documents with unrelated
content Scribd suggests to you:
is hollow. It is a worthless canoe;
a hollow canoe. A canoe that will
never reach the ocean.”

When Keawenuiaumi heard this A lohe o Keawenuiaumi i keia


call from the birds the tree-felling leo o na manu, haalele i ke oki
was abandoned. As the birds ana i ke koa, no ke kahea mau o
kept up this calling continually na manu pea i na la a pau loa;
Keawenuiaumi became vexed nolaila, uluhua o Keawenuiaumi,
and thereupon made up his mind a manao iho la oia e imi i kanaka
to go in search of a skillful archer akamai i ka pana pua i make na
to come and kill the birds. About manu. Ua hiki aku ke kaulana o
this time the fame of Mainele as Mainele ma Hawaii a puni i ka
an archer reached Hawaii, so pana iole, nolaila olelo o
Keawenuiaumi made a vow, Keawenuiaumi me ka hoohiki:
“That if Mainele would kill the “Ina e make na manu ia Mainele,
birds he should receive the alaila, lilo kana kaihamahine i
king’s daughter in marriage 15 wahine na Mainele, a me kekahi
together with a portion of the aoao o Hawaii.”
island of Hawaii.” Upon the
arrival of Keawenuiaumi’s A hiki na elele a Keawenuiaumi i
messengers in Oahu, Mainele Oahu nei, hai ia Mainele i na
was informed of the wish of the olelo a Keawenuiaumi. Ia lohe
king. As soon as Mainele heard ana o Mainele i keia holo ona i
that he was wanted on Hawaii, Hawaii, hoomakaukau iho la ia i
he immediately prepared his na waa a me na kanaka holo pu
double canoe and got together me ia. [461]
his men who were to accompany
him. [460]

When Kauakahi, the man who O Kauakahi, ke kanaka nana i


found Pikoiakaalala sleeping on lawe o Pikoiakaalala, ia ia e moe
the sand, heard of the ana ma ka ae one mahope o
contemplated trip to be made by kona pae ana mai Kauai mai,
Mainele to Hawaii, he went to olelo aku la ia ia Pikoiakaalala:
Pikoiakaalala and told him of “E holo ana o Mainele i Hawaii e
what he had heard, saying: pana ai i na manu, ua hiki mai
“Mainele is going to Hawaii to nei na elele a Keawenuiaumi.”
shoot birds for Keawenuiaumi; “Ae, ina oe e manao e holo au, e
the messengers have just pii oe i ie, a ulana hokeo, i wahi
arrived from Hawaii.” no’u e noho ai, i ole au e ike ia e
Pikoiakaalala answered: “If you Mainele, a e olelo no hoi oe, he
wish me to go along you had hokeo akua nou. Pela au e hiki
better go up and get some ie ai.” Hana iho la o Kauakahi e like
vines and make a basket in the me na olelo a Pikoiakaalala, a
shape of a calabash for me to makaukau ka hinai ie, a me ka
hide in, so that I may not be holo o Mainele.
seen by Mainele, and you can
say that it is a basket for the safe
keeping of your god. This will be
the means of getting me to
Hawaii.” Kauakahi then followed
out the instructions given by
Pikoiakaalala and had the basket
made, and the trip with Mainele
arranged.

When Mainele’s preparations I aku o Mainele ia Kauakahi: “E


were finally completed, he holo kaua i Hawaii.” Ae mai o
approached Kauakahi and said: Kauakahi: “Ae, he ae no ko’u i
“Let us sail to Hawaii.” Kauakahi ka holo me oe i Hawaii, aia nae
replied: “All right, I am willing to a ae oe i ka’u olelo.” “Heaha ia ia
go to Hawaii with you providing olelo?” wahi a Mainele. “He
you give me your consent to do hokeo akua no’u, he kapu kona
what I want.” “What is it you waa e kau ai, aohe kanaka e kau
want?” asked Mainele. “I have a ma kona waa, owau wale no.”
basket where my god is kept. Ua pono ia olelo ia Mainele. I ka
The canoe in which this god is to la o lakou i holo ai i Hawaii, kau
be taken, as I want to take it aku la o Mainele ma kona mau
along, must be tabued and no kaulua, me na ohua a me na
one must be allowed to take hoewaa; o Kauakahi me
passage in it outside of myself.” Pikoiakaalala i loko o ka hokeo
This was satisfactory to Mainele. ie ma ko laua waa, mahope ka
On the day agreed on for the hokeo, mamua o Kauakahi.
voyage to start for Hawaii,
Mainele, his followers and
paddlers boarded their double
canoe, while Kuakahi and
Pikoiakaalala, who was in the
basket, boarded their canoe, the
basket in the after part and
Kuakahi in the fore part of the
canoe.

A few words of explanation Olelo hoakaka no ka hokeo ie.


relating to the basket. This was No ka hakahaka o ka ulana ana,
made with several openings komo ka makani i loko, aole e
which allowed a free current of pau ke aho, nolaila i komo ai o
air and enabled Pikoiakaalala to Pikoiakaalala i loko e noho ai. A
sit therein. After leaving Oahu to hala o Oahu nei mahope o
their rear, the canoes after a lakou, hoalulu na waa o lakou
quick passage, were laid to off mawaho o ka pali o Kaholo, i
the cliffs of Kaholo, at Lanai, on Lanai, a ahiahi, hina ke kehau o
the afternoon of that same day. Kahalapalaoa mahope o na waa,
In the evening the breeze from holo aku la lakou mai ia ahiahi a
Kahalepalaoa which came owakawaka kai ao o ke
directly from behind them sent kakahiaka nui, nana aku la lakou
their canoes flying along at such i ka wailele o Kawaikapu i na pali
a rate of speed that by dawn of hulaana, e kupono ana i
the next morning they were able Makaukiu ma Kohala i Hawaii.
to make out the waterfall of Aia hoi, he hulaana, o
Kawaikapu on the steep cliffs of Kuukuunaakaiole ka inoa e
Makaukiu, Kohala, Hawaii. At hamama mai ana kona waha i
this place is a sort of a bay kahi a na waa e holo aku nei. I
surrounded by high cliffs which aku o Pikoiakaalala ia Kauakahi:
opens directly to the sea and “E olelo aku oe ia Mainele e
which was right ahead of the pana aku i ka waha o ka iole e
canoes as they were pouliuli mai nei.” A lohe o
approaching land; the name of Mainele i ka olelo a Kauakahi,
the place is Kuukuunaakaiole. hoole maila: “Aohe iole, he pali
Pikoiakaalala upon seeing where ia; he kanaka lalau oe.”
they were said to Kauakahi: “Tell
Mainele to shoot at the mouth of
the rat which is dimly seen
ahead of us.” When Mainele
heard this he replied to
Kauakahi: “That is not a rat, that
is a cliff, you are mistaken.”

Upon passing the cliffs they A haalele lakou i na pali


continued on their way to Hilo, at hulaana, po a ao hiki lakou ma
which place they arrived the next Hilo a pae ma ke awa o
day and landed at Kaipalaoa. Kaipalao; pii na mea a pau a hiki
Everybody upon landing i kahi o Keawenuiaumi, koe o
proceeded to the place where Kauakahi me ka hokeo ie ana. I
Keawenuiaumi was at that time aku o Mainele: “E pii kaua.”
residing with the exception of Olelo mai o Kauakahi: “Aole au e
Kauakahi and his basket. When pii a hiki kuu hokeo akua. Ia lohe
Mainele saw that Kauakahi was ana o Mainele, kauoha aku la o
left behind he asked him: “Let us Mainele ia Keawenuiaumi i
go on up?” Kauakahi replied: “I kanaka no ka hokeo akua e hiki
will not go on up unless the ai i uka. Kena mai la o
basket which my god is in goes Keawenuiaumi eha kanaka, amo
with me.” When Mainele heard aku la i ka hokeo ie a hiki i ka
this, he requested of hale, olelo aku o Kauakahi ia
Keawenuiaumi that men be Mainele: “Aole kakou e pono ke
furnished to carry the basket noho ma ka hale hookahi me ke
along up to the house, ’kua o kaua, e aho e olelo oe ia
whereupon Keawenuiaumi Keawenuiaumi i wahi hale no
ordered four men to pack the maua.” Olelo aku la o Mainele ia
basket to the house. Upon their Keawenuiaumi, i [463]hale no ke
arrival at the house, Kauakahi akua o laua me Kauakahi;
spoke to Mainele: “I don’t think it mahope oia lohe ana, aohe i
right for us to live in the same upuupu iho paa ka hale,
house with our god; it is best that haawale o Kauakahi me ka
you ask Keawenuiaumi that a hokeo ie. O keia mau hana a
small house be given me where I pau loa, na Pikoiakaalala wale
can live with the god.” Mainele no, i ole oia e ike ia e Mainele a
therefore requested of me na kanaka.
Keawenuiaumi for [462]a house
for the god and Kauakahi. As
soon as the king heard this,
orders were given that a small
house be built, which was
finished in no time, where
Kauakahi moved in with his
basket. This request was really
made at the wish of
Pikoiakaalala, in order that he
might not be seen by Mainele
and the people.

On the second day of their I ka lua o ka la o lakou ma Hilo,


arrival at Hilo, Keawenuiaumi, pii o Keawenuiaumi me Mainele i
Mainele and the people kahi o ke koa waa, a na manu e
proceeded up into the koa forest hea ai, me ka auamo ia o ka
where the tree that had been hokeo ie. A hiki pono lakou
already picked out was situated. malalo o ke kumu o ua koa nei,
On this trip the basket was noho kaawale aku la o Kauakahi
carried along, and when they me ka hokeo ie. Ia wa, ooki na
arrived at the tree, Kauakahi and kalai waa a Keawenuiaumi i ke
his basket remained at a little kumu o ke koa, kau ana na
distance from the others. The manu, kahea ana: “E,
king’s canoe makers then Keawenuiaumi e! Aohe waa, he
proceeded to cut down the tree. puha. He waa ino, he waa puha.
Just as soon as this was done He waa hiki ole i ka moana.”
the birds lit on the tree and
called out: “Say, Keawenuiaumi!
You cannot make a canoe [out of
this tree], it is hollow. It is a
worthless canoe, a hollow
canoe. A canoe that will never
reach the ocean.”

As soon as the people heard the Lohe na mea a pau loa, pana o
call, Mainele shot at the birds, Mainele i ka pua, aohe launa ae
but his arrow did not come i na manu. Hana ke olokea he
anywhere near them on account alanui e pii ae ai a waena o ke
of the height of the tree. A koa pana ae, aohe no he launa
staging was then built up which ae i na manu. Hawanawana aku
reached about half way up the o Pikoiakaalala ia Kauakahi: “E
tree, but even then Mainele’s ninau alu oe ia Mainele a me
arrow did not reach the birds. Keawenuiaumi heaha keia ku
Pikoiakaalala then whispered to ole o na manu? He pana ole ia
Kauakahi: “Ask Mainele and paha i ka pua, ina paha e pana
Keawenuiaumi why the birds are ia ku na manu.” A lohe o Mainele
not hit. Perhaps Mainele was not i keia olelo a Kauakahi, i mai la:
shooting at them, if he did he “Aole no la hoi e pana ae; aia no
would hit them.” When Mainele hoi ka manu ke kau mai la, eia
heard the remarks of Kauakahi, ka pua, pana ae no hoi paha,
he replied: “Why don’t you shoot malama o ku ia oe.” I aku o
at them yourself? There are the Kauakahi: “Ae, e olelo ae au i
birds, here is the bow and here kuu akua a nana e pana na
are the arrows, go ahead and manu.” Ia wa ku ana o
shoot, may be you will hit them.” Pikoiakaalala mai loko ae o ka
At this Kauakahi replied: “All hokeo ie me kana pua pana iole.
right, I will ask my god to shoot Alaila, ike o Mainele a me na
the birds.” Pikoiakaalala then kanaka o Oahu aku nei he
came out of the basket with his kanaka ko loko o ka hokeo ie.
rat shooting arrows to the Olelo aku o Pikoiakaalala ia
surprise of Mainele and the Keawenuiaumi: “I poi wai, e lawe
Oahu people that accompanied mai a malalo o ke kumu o ke koa
him, for they had not known that nei kukulu.” I loko oia wa pana o
a man had been in this basket all Pikoiakaalala i na manu; kulou
this time. Upon coming up to iho la kona poo i loko o ke poi
Keawenuiaumi, Pikoiakaalala wai, e nana ana i ke aka o na
requested that a basin of water manu i kupono ka pua ke pana,
be brought and made to stand o ka lima me ka pua iluna kahi i
under the tree. As soon as this pana ai, o na maka i loko o ke
was done Pikoiakaalala came poi kahi i hooponopono ai i ke
and stood over the basin; while kupono. Ia pana ana, ku na
he looked into the basin at the manu a elua, pahu ana i lalo,
reflection of the birds in the uwa ka aha kanaka i ke akamai
water, he held his arms above o Pikoiakaalala.
his head with his bow bent and
his arrow aimed at the birds; as
soon as he saw that the birds
were in line he let fly his arrow
which flew true to the mark
hitting both birds and they came
tumbling down to the ground.
The people upon seeing this
great skill shown by
Pikoiakaalala gave a mighty
shout.

Keawenuiaumi, true to his word Lilo ke kaikamahine a


gave his daughter to Keawenuiaumi ia Pikoiakaalala a
Pikoiakaalala to wife and also me kekahi aoao o Hawaii waiwai
gave him a portion of Hawaii, o Kauakahi, hilahila o Mainele a
which made Kauakahi a very rich hoi mai i Oahu nei. [464]
man. Mainele was so ashamed
that he immediately returned to
Oahu. [451]

1 This name, showing Pikoi’s descent,


is a departure from the customary
form, being not only of, or from, Alala,
but is more definite as from ka (the)
Alala. ↑
2 Kaulamawaho, outside rope;
Kekakapuomaluihi, “the arrow
shooting of Maluihi”. ↑
3 Ike ole laua, as translated here, may
also mean “they did not know”, or
“were unaware”, etc. ↑
4 Olohu, name of a stone disk for a
rolling game, which takes the same
name. ↑
5 Pahee, a favorite betting game of
sliding a stick along a grass or
gravel course. ↑
6 Koieie, probably the same as koieiei,
a play at a flowing stream where the
incoming tide or current will return the
object thrown. The sport of sliding down
the rapids, as in Samoa or other islands
of Polynesia, takes the same name. ↑
7 E moe ana might mean simply “lying
down”, from his exhausted
condition. ↑
8 Rat shooting was a pastime of the
aliis. ↑
9 Kaukau alii, probably a prince, since
the term applied to a class of chiefs
below the king. ↑
10 The kalolo prayer was a petition
supplicating favors. ↑
11Aweoweo, a shrubby plant at various
altitudes (Chenopodium
sandwicheum). ↑
12Haumakaiole, an epithet applied to
one who is blear-eyed, from old
age. ↑
13 Hau, frost or misty; maka, eye; iole,
rat. ↑
14 Kuaiole, the upper ridge-pole of a
house. ↑
15 A stereotyped form of royal
recompense. ↑
[Contents]

Legend of Kaao No Kalelealuaka


Kalelealuaka and a Me
Keinohoomanawanui. Keinohoomanawanui.

The land where Kalelealuaka Oka aina i noho ai o


and Keinohoomanawanui lived Kalelealuaka a me
was Lihue, situated below and to Keinohoomanawanui, o Lihue e
the east of the Kaala mountains waiho ana malalo hikina o ka
on Oahu. The ground upon mauna o Kaala i Oahu. O ke
which the house stood is kahua hale nae, o Oahunui. O
“Oahunui”. At this time Kakuhihewa ke ’lii o Ewa a me
Kakuhihewa was the king of Ewa na aina e pili ana me ia; o
and of the districts adjoining; Pueonui ko Kona nei, oia mai
while Pueonui was the king of Moanalua a Makapuu, e noho
the district of Kona, embracing ana laua me ka paonioni a me
that stretch of country from ke kaua, kokoke e pau loa o
Moanalua to Makapuu. At this Ewa ia Pueonui.
time these two kings were
contending in war with each
other whereby Pueonui was
acquiring the Ewa lands.
Kalelealuaka was a very brave
and fearless man in battle and in
fighting. Kalelealuaka and
Keinohoomanawanui often spent
their time wishing for certain
things. The house in which they
lived faced directly towards Ewa.

Usually after partaking of their He kanaka koa loa o


evening meal they would light Kalelealuaka ma ke kaua a me
their kukui nut lamp and then lie ka hakaka. O ka laua hana me
down with their heads on their Keinohoomanawanui, o ke kuko.
pillows, look up at the roof, O ko laua hale, ua kupono ka
Kalelealuaka at one gable of the puka i kai o Ewa, o ko laua
house and Keinohoomanawanui manawa e kuko ai, o ka wa pau
at the other, when Kalelealuaka o ka paina ana o ke ahiahi e
would call out to pupuhi ana kukui, aia a hoi e
Keinohoomanawanui: “Let us moe, kau ke poo i ka uluna, huli
name our wishes.” ke alo iluna nana i kaupoku o ka
Keinohoomanawanui would then hale. Moe o Kalelealuaka ma
reply: “My wish is this: that we kona kala, moe o
sleep until the first crowing of the Keinohoomanawanui, ma kona
cock, then wake up and proceed kala, kahea aku o Kalelealuaka
down to the plain, pull up some ia Keinohoomanawanui: “O ke
ahuhu, 1 gather them together, kuko a kaua.” I mai o
continue on down to the beach, Keinohoomanawanui: “O ka’u
pound until soft, put the stuff into kuko, o ka moe o kaua a kani ka
the cracks, catch an eel, return moa kuakahi, iho a ke kula,
home, put the eel in banana huhuki auhuhu, a loaa, iho aku a
leaves, cook it in the oven kahakai, kui a wali, hoo aku i ka
underground; then at the second mawae o ka ala, make ka puhi,
crowing of the cock uncover the hoi mai a uka nei, haihai i ka lau
oven and place the cooked eel to maia, kalua, a kani ka moa, huai
one side to cool; after it is cooled ae a hoomaalili ma kapa. A
we will then proceed eating until maalili, ai kaua a maona, hoi aku
we have had our fill; when we a luna o ka hua moena, kau ke
will retire to our mats, place our poo i ka uluna, huli ae ke alo
heads on our pillows, face up to iluna, nana ae i kaupoku o ka
the roof and watch the rats race hale, liilii ka maka o ka iole, oia
along the battens. That is my ka’u kuko la i lohe oe.”
wish, I want you to know.”

Kalelealuaka would then reply: I aku o Kalelealuaka: “Aole kau


“That is no wish, I have the he kuko; o ka’u no ke kuko.”
proper wish.” “What is your “Pehea kau kuko?” wahi a
wish?” Keinohoomanawanui Keinohoomanawanui. “O na ilio
would ask. “That we may eat the nahu maka o Kakuhihewa na
dogs of Kakuhihewa that bite the kaua e ai; ka puaa kea o ka
face of people; that we may bake niho, na kaua e kalua; ke awa
the hog whose tusks are nui o na loko na kaua e ai, na
crossed; that we may eat the fat puawa ona na kaua e inu. Na
awa 2 of the fish ponds; that we Kakuhihewa no e mama a wali,
may drink of the best and most e hoka a loko o ke kanoa, e
intoxicating awa; that hoohee a loko o na apu; nana no
Kakuhihewa himself shall chew e hooinu i na waha o kaua, ona
the awa, strain it into the kaua, moe i ka ona awa a huli
containers, pour it out into the ae; nana no e lawe mai i na
cups, place the cups to our lips; kaikamahine ana a ma na aoao
and after we have slept off the o kaua hoomoe: oia ka’u kuko la
effects of the awa, that he bring i lohe oe.” “Kahaha, make kaua;
his daughters and make them kai no paha ma na mea e ae
our wives. That is my wish, I kaua e kuko ai, eia ka o ke ’lii
want you to know.” kau kuko; ina pela kou manao
Keinohoomanawanui then mamake kaua,” pela aku o
replied: “Say, we will get killed. I Keinohoomanawanui. Pela ko
thought we were to wish on other laua hana mau ana a hala ke
subjects; but I see your wish is in anahulu o na po a me na po
relation to the king. If that is your helelei, oia he mau po keu. O
wish we will surely get killed.” anahulu a me helelei. Anahulu,
This was carried on by these two he umi ia. Helelei, he keu
for ten nights and over. 3 mawaho o ka umi; oia ke ano
ma ka olelo kahiko o Hawaii nei.
Eia ke ano o keia mau inoa.

As their lamp was seen burning No keia a mau o ke kukui i na po


for several nights, Kakuhihewa a pau, uluhua o Kakuhihewa,
got vexed and ordered one of his kena i ke kiu e pii e nana i keia
spies to go on up and see what kukui a o ke aumoe. A hiki ke kiu
this midnight lamp was for. As ma waho, e olelo ana o
the [466]spy arrived and stood on Keinohoomanawanui [467]i kana
the outside of the house he a pau ia, olelo o Kalelealuaka i
heard Keinohoomanawanui kana a pau, hoomaha iho la
name his wish, which was laua. Kukulu iho la ke kanaka kiu
followed by Kalelealuaka, after i ka pahoa ma ka puka o ka hale
this the two became quiet. The a hoi mai la a hiki ia. Ninau aku
spy then stuck a short wooden la ke ’lii: “He kukui aha kela au i
dagger in the ground at the pii aku nei?” Hai mai la ke kiu i
entrance 4 of the house and na olelo a pau loa ana i lohe ai,
returned to the king. At his arrival a lohe ke ’lii i keia mau olelo. Aia
the king asked: “What was that me ke ’lii he kahuna; ui ae la ke
lamp burning for that you went ’lii: “Pehea kela kanaka o
up to see?” The spy then Kalelealuaka, he pono anei kana
repeated all he had heard. While olelo, aole anei?” I aku ke
the spy was repeating what he kahuna: “He pono kana olelo; o
had heard to the king, a priest ke kanaka ia puni ko aina; o na
was at this time with the king. At mea a pau ana i olelo mai ai, e
the conclusion of the recital, the hooko oe, o oe ponoi no ke hana
king turned to the priest and e like me ka olelo a ua kanaka
asked him: “What about that ala.” O keia mau olelo a pau loa,
man Kalelealuaka? Do you think ua hooko o Kakuhihewa ke ’lii;
his wish proper or not?” The eia nae, olelo aku ke kahuna i ke
priest replied: “What he has said ’lii: “I mau hale elua, i hookahi
should be carried out, because hale ai, i hookahi hale moe,
he will be the man to gain the hookahi la paa, alaila, kii ia o
conquest for you, so that you will Kalelealuaka a lawe mai.”
own the whole island. You must,
however, carry out every detail of
his wish with your own hands.”
On the advice of the priest,
Kakuhihewa 5 proceeded to carry
out in detail the wish made by
Kalelealuaka. The priest had,
however, instructed the king to
build two houses, one to serve
as an eating house and the other
a sleeping house; both to be built
and completed in one day and
then Kalelealuaka was to be sent
for and brought down.

When Kalelealuaka 6 and O Kalelealuaka a me


Keinohoomanawanui 7 woke up Keinohoomanawanui, i ko laua
in the morning and went out of ala ana i ke kakahiaka a hele
doors, they saw a wooden iwaho o ka hale, iko iho la laua
dagger sticking in the ground just he pahoa e ku ana ma ka puka o
outside of the entrance. At ka hale, ua kukuluia. I aku o
seeing this Keinohoomanawanui Keinohoomanawanui ia
said to Kalelealuaka: “We are Kalelealuaka: “Make kaua! Eia la
going to be killed. Here is a he pahoa ma ka puka o ka hale
wooden dagger at our door. We o kaua! Ua loaa. Aloha ino kaua
have been discovered. What a i ka make; o ka’u no ia e olelo
pity that we are to be killed. You aku ana ia oe e waiho ke ’lii,
can now see the consequences aohe make olelo.”
of disobeying my advice, not to
speak anything in connection
with the king.”

While they were discussing the Ia laua e kamailio ana no ka


dagger found at their door, they pahoa i kukulu ia ma ka puka o
looked down toward Ewa and ka hale, nana aku la laua i ka
saw a company of people moe mai o ke kaoo huakai
coming up toward them from the kanaka, mai kahi o ke ’lii a
king’s house all armed with kokoke i ko laua nei wahi, me na
stone axes from front to rear of koi lipi mai mua a hope o ka
the procession. At the sight of huakai. “Aia hoi paha ka make o
the people Keinohoomanawanui kaua la,” pela aku o
remarked: “There perhaps is our Keinohoomanawanui ia
death coming?” Kalelealuaka Kalelealuaka; makau wale. O
replied: “You coward.” The keia huakai, he poe ooki laau
company they saw coming was hale, e like me na olelo a ke
on their way to cut timber for the kahuna i ke ’lii, hookahi la ua
erection of the two houses as paa na hale elua.
advised by the priest. These
houses were completed in one
day.

how kalelealuaka and no ke kii ana ia


keinohoomanawanui kalelealuaka a me
were sent for and keinohoomanawanui, e
how they were taken lawe i kai o ewa imua o
to king kakuhihewa at ke ’lii o kakuhihewa.
ewa.

On the following day Ia po a ao ae, nana hou aku la o


Keinohoomanawanui again saw Keinohoomanawanui i nei
a large company of people huakai nui e pii mai ana mai kai
coming up from Ewa, all armed mai o Ewa, me na pololu, me ka
with spears and other ihe me ke kuia, me ka elau, me
instruments of war; some had na mahiole, me ka ahuula, me
war helmets and feather capes ka manele auamo. Hai aku o
while some had a litter for Keinohoomanawanui ia
carrying people. Upon seeing the Kalelealuaka, eia ka make o
people Keinohoomanawanui kaua ke kiina mai nei. Wahi a
turned to Kalelealuaka and said: Kalelealuaka: “Nana ia aku.” O
“Our death is now close upon Kalelealuaka, ke moi nei no me
us.” Kalelealuaka replied: “Keep kana laau palau, me ka maka’u
your eye on them.” Kalelealuaka ole me ka aa no e hakaka.
all this time was lying down with
his war club, showing no fear A hiki ka huakai ma waho o ka
and acting as though willing to hale o laua nei, eono poe
fight. When the people arrived kanaka ka puni o ka hale me ka
outside of the house, six of them makaukau i na mea make. Ia wa
surrounded the house all armed ala mai o Kalelealuaka me kana
with death weapons. Soon after laau [469]palau a uhau iho la i ka
this Kalelealuaka got up, hale, kaawale ae la elua mahele
stepped [468]outside with his war me ka lele liilii i o i anei. Olelo
club in hand, raised it and struck mai ka luna o na kanaka: “Aole
it on the house cutting it in two ka makou huakai he kaua a he
and scattering the grass and make; i kii mai nei makou ia oe e
timbers in all directions. The iho i kai o Ewa, ma ke kauoha a
officer in command of the ke ’lii a Kakuhihewa. Eia hoi ka
soldiers spoke up saying: “We manele la kau mai iluna.”
did not come here to inflict
death, but we have been sent to
bring you to Ewa by the orders of
Kakuhihewa, the king. Here is
the litter, get in.”

Before their arrival at Ewa, A hiki lakou nei i kai o Ewa, ua


Kakuhihewa had in the hoomakaukau ponoi o
meantime prepared with his own Kakuhihewa ke ’lii i na mea a
hands everything as advised by pau, e like me ka olelo a ke
the priest, as already set forth in kahuna i olelo mua ia ma ka
this story. The reason why hoomaka ana o keia kaao. O ke
Kakuhihewa had followed the kumu o keia hana ponoi a
instructions was because he Kakuhihewa, no ke ake e lilo nui
wanted to gain possession of all ko Pueonui aina ia ia, a no ka
of Pueonui’s lands, and also olelo kekahi a ke kahuna. Lilo ae
because the priest had advised la o Kalelealuaka i hunona na ke
him so. Kalelealuaka and ’lii a me Keinohoomanawanui,
Keinohoomanawanui were from hookahi hana a Kalelealuaka he
this time on taken as the king’s hiamoe i loko o ka hale me ka
sons-in-law. All Kalelealuaka did wahine, ke kaikamahine a
after this was to retire with the Kakuhihewa.
daughter of Kakuhihewa in one
of the houses prepared for them.

While they were living together I loko o keia wa a lakou e noho


at this time, war was again nei, hoomaka ke kaua o na ’lii, o
resumed between the two kings, Kakuhihewa a me Pueonui. O
Kakuhihewa and Pueonui. 8 Keinohoomanawanui lilo ae la ia
Keinohoomanawanui was at i luna koa, oia kekahi i hele i ke
once made one of the king’s kaua, ua lanakila ko lakou aoao
officers and he went out to take ma ke kaua ana me Pueonui. O
part in one of the battles, and in Kakuhihewa a me na koa kai
which Pueonui was beaten. hele i ke kaua i ke ao, ua nui ka
Kakuhihewa and his men went make ma ko Pueonui aoao, ua
out to fight during the daytime lanakila loa o
and they slew a great many of Keinohoomanawanui ma keia
Pueonui’s men. mau kaua ana, a ua manao ke
Keinohoomanawanui always ’lii o Kakuhihewa nana keia
gained the victory in these make.
battles so that in time the king
began to give
Keinohoomanawanui the credit
of such splendid results.

Kalelealuaka in the meantime No Kalelealuaka. I ke ao, moe


retired during the daytime, but at oia a kani ka moa kuakahi o ka
the first crow of the cock at early wanaao, hele e pepehi i na ’lii
dawn, he would get up and go koa o Pueonui. Mai lalo mai o
out and slay the officers in the Ewa e holo ai, a loaa na ’lii koa a
army of Pueonui. He would run me ke kaua i Kapukaki e nana
from Ewa to Kapukaki, the ala ia Halawa. Lawe kela i ka
heights looking down at Halawa, mahiole a me ka ahuula o na ’lii
where he would meet the officers a me na koa, hookahi laau palau
of the opposing army and fight e uhau ai ma ka akau, a pela ma
them single handed, striking on ka hema, ua pau loa ia poe
the right and then on the left. kaua; pela kana hana mau ana i
After slaying the enemy by the na po a pau me ka ike ole ia. A i
use of his war club he would kekahi po ana i hoi hou ai, ike ia
carry off their war helmets and e ke kanaka mahiai i Halawa. Ua
feather capes. This was carried luku aku o Kalelealuaka i na koa
on by him for several nights o Pueonui a pau i ka make, ua
without the knowledge of loaa ka ahuula a me ka mahiole,
anyone. One night as he was e huli hoi ana ia, a no kona
returning a farmer at Halawa mama loa aole maopopo kona
saw him. Kalelealuaka had slain mau helehelena. Nolaila,
several of Pueonui’s men, and hoomakakiu ua kanaka mahiai
secured some feather capes and nei i kekahi po hou mai, a ike ia
war helmets and was on his way ia Kalelealuaka e hele ae ana
home; but he was traveling at me ka mama loa, ia wa, pahu
such speed that the farmer was kela i ka ihe laumeki kohe o mua
unable to make out who he was. a ku i ka lima, i ka peahi mahope
On the night following the farmer mai, paa loa i loko ka upe o ka
thought he would lie in wait for ihe. Lalau iho la o Kalelealuaka i
this man; sure enough he saw ka ihe a uhaki ae la, paa no ka
Kalelealuaka going along at a upe i loko o ka lima.
very great rate of speed, so
taking up his spear whose point
was fixed like a hook, he threw it
and hit the man in the arm just
above the wrist; the spear point
entered and was made fast.
Kalelealuaka seizing the spear
tried to pull it out, but was unable
on account of the peculiar point,
so he broke it, leaving the point
still in the arm.

Pueonui was defeated and O Pueonui ua pio kona aoao, a


Kakuhihewa took possession of ua pau loa kona aina ia
all his lands. Kakuhihewa all this Kakuhihewa, ua manao hoi o
time thought Kakuhihewa na
Keinohoomanawanui was the Keinohoomanawanui keia pio o
cause of these victories over Pueonui, a me keia make o na
Pueonui and the slaughter of the kanaka. No ke kanaka mahiai.
men. In the meantime the farmer Hoole oia ia
refused to give Keinohoomanawanui: “Aole
Keinohoomanawanui the credit nana keia make o Pueonui, he
of these victories and declared kanaka e wale no ke kanaka
that the final defeat and death of nana e luku nei, aia a kokoke e
Pueonui was the work of a ao [471]hele keia kanaka. He
different man altogether, who kanaka mama loa, aohe lua, me
went out to fight only in the early ka laau palau i ka lima, a i ka hoi
morning. He described this ana mai me ka mahiole a me ka
unknown man as a very fast ahuula, ua pahu ia e a’u i ka ihe,
runner of whom he knew no a paa ka upe o ka ihe i loko o ka
equal; the man always carried a lima. Oia ka hoailona o ua
war club, and on his return would kanaka ala.”
come with war helmets and
feather capes. “I have wounded
him in the arm and I think [470]the
spear point is still in his arm. It
will be the means by which the
man could be recognized.”

When Kakuhihewa heard this, he A lohe o Kakuhihewa i keia mau


issued a call for everybody to olelo kukala aku la ia i kana olelo
come together, no man, woman kuahaua: “Aohe kanaka noho,
or child to remain at home, aohe wahine, aohe keiki. O ka
excepting those who when they mea ku ae a hina iho, oia ke
fell down were unable to get up noho aku, o ka mea mai hiki ole
again, and those who were so ke hele.” A akoakoa na mea a
sick that they could not walk. pau loa i kahi hookahi, hele ua
After everybody had come kanaka nei e nana i ka lima,
together, the farmer proceeded aohe loaa iki. Ninau aku la ia
to look for his man by looking at Kakuhihewa: “Aohe kanaka i
their arms; but he was unable to koe?” “Aole,” pela aku ke ’lii.
locate him. He then asked “Aka, o kuu hunona wale no koe
Kakuhihewa: “Is there no one e moe la i ka hale, aohe ana
left?” “None,” said the king, hana e loaa.” “E kii aku, e lawe
“except my son-in-law who is mai e nana aku au,” pela aku ke
asleep at home, and has done kanaka mahiai. A hiki mai la o
nothing requiring him.” “Send for Kalelealuaka, hoike mai la i kona
him and let me see [his arm],” lima, i nana iho ka hana e paa
said the farmer. When ana ka upe o ka ihe i ka lima.
Kalelealuaka came up to the “He oiaio, o keia kanaka ka mea
farmer and held up his arm the nana i luku ko Pueonui aoao a
point of the spear was found. pau i ka make. O ke kanaka keia
The farmer then remarked: a’u i hoomakaukiu ai i ke

You might also like